Module: GD2::GD2FFI

Extended by:
FFI::Library
Defined in:
lib/gd2-ffij.rb

Constant Summary collapse

FFI_LAYOUT =
{
  :gdImageCreate                      => [ :pointer,  :int, :int ],
  :gdImageCreateTrueColor             => [ :pointer,  :int, :int ],
  :gdImageCreatePaletteFromTrueColor  => [ :pointer,  :pointer, :int, :int ],
  :gdImageCreateFromJpeg              => [ :pointer,  :pointer ],
  :gdImageCreateFromJpegPtr           => [ :pointer,  :int, :pointer ],
  :gdImageCreateFromPng               => [ :pointer,  :pointer ],
  :gdImageCreateFromPngPtr            => [ :pointer,  :int, :pointer ],
  :gdImageCreateFromGif               => [ :pointer,  :pointer ],
  :gdImageCreateFromGifPtr            => [ :pointer,  :int, :pointer ],
  :gdImageCreateFromWBMP              => [ :pointer,  :pointer ],
  :gdImageCreateFromWBMPPtr           => [ :pointer,  :int, :pointer ],
  :gdImageCreateFromGd                => [ :pointer,  :pointer ],
  :gdImageCreateFromGdPtr             => [ :pointer,  :int, :pointer ],
  :gdImageCreateFromGd2               => [ :pointer,  :pointer ],
  :gdImageCreateFromGd2Ptr            => [ :pointer,  :int, :pointer ],
  :gdImageCreateFromGd2Part           => [ :pointer,  :pointer, :int, :int, :int, :int ],
  :gdImageCreateFromXbm               => [ :pointer,  :pointer ],
  :gdImageCreateFromXpm               => [ :pointer,  :pointer ],
  :gdImagePaletteCopy                 => [ :void,     :pointer, :pointer ],
  :gdImageCompare                     => [ :int,      :pointer, :pointer ],
  :gdImageJpeg                        => [ :void,     :pointer, :pointer, :int ],
  :gdImageJpegPtr                     => [ :pointer,  :pointer, :pointer, :int ],
  :gdImagePngEx                       => [ :void,     :pointer, :pointer, :int ],
  :gdImagePngPtrEx                    => [ :pointer,  :pointer, :pointer, :int ],
  :gdImageGif                         => [ :void,     :pointer, :pointer ],
  :gdImageGifPtr                      => [ :pointer,  :pointer, :pointer ],
  :gdImageWBMP                        => [ :void,     :pointer, :int, :pointer ],
  :gdImageWBMPPtr                     => [ :pointer,  :pointer, :pointer, :int ],
  :gdImageGd                          => [ :void,     :pointer, :pointer ],
  :gdImageGdPtr                       => [ :pointer,  :pointer, :pointer ],
  :gdImageGd2                         => [ :void,     :pointer, :pointer, :int, :int ],
  :gdImageGd2Ptr                      => [ :pointer,  :pointer, :int, :int, :pointer ],
  :gdImageDestroy                     => [ :void,     :pointer ],
  :gdImageSetPixel                    => [ :void,     :pointer, :int, :int, :int ],
  :gdImageGetPixel                    => [ :int,      :pointer, :int, :int ],
  :gdImageGetTrueColorPixel           => [ :int,      :pointer, :int, :int ],
  :gdImageLine                        => [ :void,     :pointer, :int, :int, :int, :int, :int ],
  :gdImageRectangle                   => [ :void,     :pointer, :int, :int, :int, :int, :int ],
  :gdImageFilledRectangle             => [ :void,     :pointer, :int, :int, :int, :int, :int ],
  :gdImagePolygon                     => [ :void,     :pointer, :pointer, :int, :int ],
  :gdImageOpenPolygon                 => [ :void,     :pointer, :pointer, :int, :int ],
  :gdImageFilledPolygon               => [ :void,     :pointer, :pointer, :int, :int ],
  :gdImageArc                         => [ :void,     :pointer, :int, :int, :int, :int, :int, :int, :int ],
  :gdImageFilledArc                   => [ :void,     :pointer, :int, :int, :int, :int, :int, :int, :int, :int ],
  #   :gdImageEllipse                     => [ :void,     :pointer, :int, :int, :int, :int, :int ],
  :gdImageFilledEllipse               => [ :void,     :pointer, :int, :int, :int, :int, :int ],
  :gdImageFill                        => [ :void,     :pointer, :int, :int, :int ],
  :gdImageFillToBorder                => [ :void,     :pointer, :int, :int, :int, :int ],
  :gdImageSetClip                     => [ :void,     :pointer, :int, :int, :int, :int ],
  :gdImageGetClip                     => [ :void,     :pointer, :pointer, :pointer, :pointer, :pointer ],
  :gdImageBoundsSafe                  => [ :int,      :pointer, :int, :int ],
  :gdImageSetBrush                    => [ :void,     :pointer, :pointer ],
  :gdImageSetTile                     => [ :void,     :pointer, :pointer ],
  :gdImageSetAntiAliased              => [ :void,     :pointer, :int ],
  :gdImageSetAntiAliasedDontBlend     => [ :void,     :pointer, :int, :int ],
  :gdImageSetStyle                    => [ :void,     :pointer, :pointer, :int ],
  :gdImageSetThickness                => [ :void,     :pointer, :int ],
  :gdImageInterlace                   => [ :void,     :pointer, :int ],
  :gdImageAlphaBlending               => [ :void,     :pointer, :int ],
  :gdImageSaveAlpha                   => [ :void,     :pointer, :int ],
  :gdImageColorTransparent            => [ :void,     :pointer, :int ],
  :gdImageColorResolveAlpha           => [ :int,      :pointer, :int, :int, :int, :int ],
  :gdImageColorExactAlpha             => [ :int,      :pointer, :int, :int, :int, :int ],
  :gdImageColorClosestAlpha           => [ :int,      :pointer, :int, :int, :int, :int ],
  :gdImageColorClosestHWB             => [ :int,      :pointer, :int, :int, :int ],
  :gdImageColorAllocate               => [ :int,      :pointer, :int, :int, :int ],
  :gdImageColorAllocateAlpha          => [ :int,      :pointer, :int, :int, :int, :int ],
  :gdImageColorDeallocate             => [ :void,     :pointer, :int ],
  :gdAlphaBlend                       => [ :int,      :int, :int ],
  :gdImageCopy                        => [ :void,     :pointer, :pointer, :int, :int, :int, :int, :int, :int ],
  :gdImageCopyResized                 => [ :void,     :pointer, :pointer, :int, :int, :int, :int, :int, :int, :int, :int ],
  :gdImageCopyResampled               => [ :void,     :pointer, :pointer, :int, :int, :int, :int, :int, :int, :int, :int ],
  :gdImageCopyRotated                 => [ :void,     :pointer, :pointer, :double, :double, :int, :int, :int, :int, :int ],
  :gdImageCopyMerge                   => [ :void,     :pointer, :pointer, :int, :int, :int, :int, :int, :int, :int ],
  :gdImageCopyMergeGray               => [ :void,     :pointer, :pointer, :int, :int, :int, :int, :int, :int, :int ],
  :gdImageSquareToCircle              => [ :pointer,  :pointer, :int ],
  :gdImageSharpen                     => [ :void,     :pointer, :int ],
  :gdImageChar                        => [ :void,     :pointer, :pointer, :int, :int, :int, :int ],
  :gdImageCharUp                      => [ :void,     :pointer, :pointer, :int, :int, :int, :int ],
  :gdImageString                      => [ :void,     :pointer, :pointer, :int, :int, :pointer, :int ],
  :gdImageStringUp                    => [ :void,     :pointer, :pointer, :int, :int, :pointer, :int ],
  :gdImageStringFTEx                  => [ :pointer,  :pointer, :pointer, :int, :pointer, :double, :double, :int, :int, :pointer, :pointer ],
  :gdImageStringFTCircle              => [ :pointer,  :pointer, :int, :int, :double, :double, :double, :pointer, :double, :pointer, :pointer, :int ],
  :gdImageGifAnimBeginPtr             => [ :pointer,  :pointer, :pointer, :int, :int ],
  :gdImageGifAnimBegin                => [ :void,     :pointer, :pointer, :int, :int ],
  :gdImageGifAnimAddPtr               => [ :pointer,  :pointer, :pointer, :int, :int, :int, :int, :int, :pointer ],
  :gdImageGifAnimAdd                  => [ :void,     :pointer, :pointer, :int, :int, :int, :int, :int, :pointer ],
  :gdImageGifAnimEnd                  => [ :void,     :pointer ],
  :gdImageGifAnimEndPtr               => [ :pointer,  :pointer ],
  :gdFontGetSmall                     => [ :pointer ],
  :gdFontGetLarge                     => [ :pointer ],
  :gdFontGetMediumBold                => [ :pointer ],
  :gdFontGetGiant                     => [ :pointer ],
  :gdFontGetTiny                      => [ :pointer ],
  :gdFontCacheSetup                   => [ :int ],
  :gdFontCacheShutdown                => [ :void ],
  :gdFTUseFontConfig                  => [ :int,      :int ],
  :gdFree                             => [ :void,     :pointer ]
}

Class Method Summary collapse

Class Method Details

.gd_library_nameObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gd2-ffij.rb', line 11

def self.gd_library_name
  return @gd_library_name if defined?(@gd_library_name)

  @gd_library_name = if RbConfig::CONFIG['host_os'] == 'cygwin'
    'cyggd-2.dll'
  elsif RbConfig::CONFIG['host_os'] =~ /mingw/
    ffi_convention(:stdcall)
    'bgd.dll'
  else
    paths = if ENV['GD2_LIBRARY_PATH']
      [ ENV['GD2_LIBRARY_PATH'] ]
    else
      [ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}', '/usr/lib/{x86_64,i386}-linux-gnu' ]
    end

    lib = if [
      RbConfig::CONFIG['arch'],
      RbConfig::CONFIG['host_os']
    ].detect { |c| c =~ /darwin/ }
      'libgd.dylib'
    else
      'libgd.so'
    end

    Dir.glob(paths.collect { |path|
      "#{path}/#{lib}{.*,}"
    }).first
  end
end