module FreeImage

  1. lib/free-image.rb
  2. lib/free-image/bitmap.rb
  3. lib/free-image/enums/color_types.rb
  4. lib/free-image/enums/dithers.rb
  5. lib/free-image/enums/filters.rb
  6. lib/free-image/enums/formats.rb
  7. lib/free-image/enums/image_types.rb
  8. lib/free-image/errors.rb
  9. lib/free-image/modules/conversions.rb
  10. lib/free-image/modules/helper.rb
  11. lib/free-image/modules/icc.rb
  12. lib/free-image/modules/information.rb
  13. lib/free-image/modules/modify.rb
  14. lib/free-image/modules/pixels.rb
  15. lib/free-image/modules/transforms.rb
  16. lib/free-image/palette.rb
  17. lib/free-image/scanline.rb
  18. lib/free-image/sources/abstract_source.rb
  19. lib/free-image/sources/file.rb
  20. lib/free-image/sources/io.rb
  21. lib/free-image/sources/memory.rb
  22. lib/free-image/types/boolean.rb
  23. lib/free-image/types/complex.rb
  24. lib/free-image/types/ffi.rb
  25. lib/free-image/types/info_header.rb
  26. lib/free-image/types/rgb16.rb
  27. lib/free-image/types/rgb_quad.rb
  28. lib/free-image/types/rgb_triple.rb
  29. lib/free-image/types/rgba16.rb
  30. lib/free-image/types/rgbaf.rb
  31. lib/free-image/types/rgbf.rb
  32. show all

Constants

BITFIELDS = 3  

BI_BITFIELDS

CALLBACK = Proc.new do |format, ptr| # Create an exception object and stash it away. We can't raise it here # because FreeImage won't be able to clean up any resources it needs to. # Instead, the calling code must call check_last_error. message = ptr.get_string(0) Thread.current[LAST_ERROR] = Error.new(format, message) end  
COLOR_ALPHA_IS_INDEX = 0x04  

The color's rgbReserved member (alpha) contains the palette index to be used

COLOR_FIND_EQUAL_COLOR = 0x02  

For palettized images: lookup equal RGB color from palette

COLOR_IS_RGBA_COLOR = 0x01  

RGBQUAD color is a RGBA color (contains a valid alpha channel)

COLOR_IS_RGB_COLOR = 0x00  

RGBQUAD color is a RGB color (contains no valid alpha channel)

COLOR_PALETTE_SEARCH_MASK = (COLOR_FIND_EQUAL_COLOR | COLOR_ALPHA_IS_INDEX)  

No color lookup is performed

LAST_ERROR = 'free_image_error'  
RGB = 0  

BI_RGB

Public Class methods

check_last_error ()
[show source]
# File lib/free-image/errors.rb, line 38
def check_last_error
  error = Thread.current[LAST_ERROR]
  Thread.current[LAST_ERROR] = nil
  raise(error) if error
end
find_lib (lib)
[show source]
# File lib/free-image.rb, line 28
def self.find_lib(lib)
  files = search_paths.inject(Array.new) do |array, path|
    file_name = File.expand_path(File.join(path, "#{lib}.#{FFI::Platform::LIBSUFFIX}"))
    array << Dir.glob(file_name)
    array
  end
  files.flatten.compact.first
end
free_image_library_paths ()
[show source]
# File lib/free-image.rb, line 37
def self.free_image_library_paths
  @free_image_library_paths ||= begin
    libs = %w{libfreeimage libfreeimage.3 FreeImage}

    libs.map do |lib|
      find_lib(lib)
    end.compact
  end
end
is_little_endian? -> boolean

Returns TRUE if the platform running FreeImage uses the Little Endian convention (Intel processors) and returns FALSE if it uses the Big Endian (Motorola processors).

[show source]
# File lib/free-image/modules/helper.rb, line 39
def self.little_endian?
  FreeImage.FreeImage_IsLittleEndian
end
msvc? ()
[show source]
# File lib/free-image.rb, line 5
def self.msvc?
  # If this is windows we assume FreeImage was compiled with
  # MSVC since that is the binary distibution provided on
  # the web site.  If you have compiled FreeImage yourself
  # on windows using another compiler, set this to false.
  #
  # This is important because FreeImage defines different
  # type sizes for MSVC - see types/ffi.rb
  FFI::Platform.windows?
end
search_paths ()
[show source]
# File lib/free-image.rb, line 16
def self.search_paths
  @search_paths ||= begin
    if ENV['FREE_IMAGE_LIBRARY_PATH']
      [ ENV['FREE_IMAGE_LIBRARY_PATH'] ]
    elsif FFI::Platform::IS_WINDOWS
      ENV['PATH'].split(File::PATH_SEPARATOR)
    else
      [ '/usr/local/{lib64,lib32,lib}', '/opt/local/{lib64,lib32,lib}', '/usr/{lib64,lib32,lib}' ]
    end
  end
end
version -> string

Returns the current version of the FreeImage library

[show source]
# File lib/free-image/modules/helper.rb, line 17
def self.version
  FreeImage.FreeImage_GetVersion
end

Public Instance methods

color_types

FreeImage supports the following color types:

:minis_black

Monochrome bitmap (1-bit) -> first palette entry is black. Palletised bitmap (4 or 8-bit) and single channel non standard bitmap -> the bitmap has a greyscale palette

:minis_white

Monochrome bitmap (1-bit) -> first palette entry is white. Palletised bitmap (4 or 8-bit) and single channel non standard bitmap -> the bitmap has an inverted greyscale palette

:palette

Palettized bitmap (1, 4 or 8 bit)

:rgb

High-color bitmap (16, 24 or 32 bit), RGB16 or RGBF

:rgb_alpha

High-color bitmap with an alpha channel (32 bit bitmap, RGBA16 or RGBAF)

:cmyk

CMYK bitmap (32 bit only)

[show source]
# File lib/free-image/enums/color_types.rb, line 17
  
dithers

FreeImage supports the following dithering algorithms:

:fs

Floyd & Steinberg error diffusion algorithm

:bayer4x4

Bayer ordered dispersed dot dithering (order 2 – 4x4 -dithering matrix)

:bayer8x8

Bayer ordered dispersed dot dithering (order 3 – 8x8 -dithering matrix)

:bayer16x16

Bayer ordered dispersed dot dithering (order 4 – 16x16 dithering matrix)

:cluster6x6

Ordered clustered dot dithering (order 3 - 6x6 matrix)

:cluster8x8

Ordered clustered dot dithering (order 4 - 8x8 matrix)

:cluster16x16

Ordered clustered dot dithering (order 8 - 16x16 matrix)

[show source]
# File lib/free-image/enums/dithers.rb, line 16
  
filters

FreeImage supports the following rescaling filters:

[show source]
# File lib/free-image/enums/filters.rb, line 6
enum :filter, [:box, 0,
               :bicubic, 1,
               :bilinear, 2,
               :bspline, 3,
               :catmullrom, 4,
               :lanczos3, 5]
formats

FreeImage supports over 30 bitmap types, which are indentified via symbols. Supported formats include:

:bmp

Windows or OS/2 Bitmap File (*.BMP)

:cut

Dr. Halo (*.CUT)

:dds

DirectDraw Surface (*.DDS)

:exr

ILM OpenEXR (*.EXR)

:faxg3

Raw Fax format CCITT G3 (*.G3)

:gif

Graphics Interchange Format (*.GIF)

:hdr

High Dynamic Range (*.HDR)

:ico

Windows Icon (*.ICO)

:iff

Amiga IFF (*.IFF, *.LBM)

:jpeg

Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE)

:jng

JPEG Network Graphics (*.JNG)

:j2k

JPEG-2000 codestream (*.J2K, *.J2C)

:jp2

JPEG-2000 File Format (*.JP2)

:koala

Commodore 64 Koala format (*.KOA)

:lbm

Amiga IFF (*.IFF, *.LBM)

:mng

Multiple Network Graphics (*.MNG)

:pbm

Portable Bitmap (ASCII) (*.PBM)

:pbmraw

Portable Bitmap (BINARY) (*.PBM)

:pcd

Kodak PhotoCD (*.PCD)

:pcsx

Zsoft Paintbrush PCX bitmap format (*.PCX)

:pfm

Portable Floatmap (*.PFM)

:pgm

Portable Graymap (ASCII) (*.PGM)

:pgmraw

Portable Graymap (BINARY) (*.PGM)

:pict

Macintosh PICT (*.PCT, *.PICT, *.PIC)

:png

Portable Network Graphics (*.PNG)

:ppm

Portable Pixelmap (ASCII) (*.PPM)

:ppmraw

Portable Pixelmap (BINARY) (*.PPM)

:psd

Adobe Photoshop (*.PSD)

:ras

Sun Rasterfile (*.RAS)

:raw

RAW camera image (many extensions)

:sgi

Silicon Graphics SGI image format (*.SGI)

:targa

Truevision Targa files (*.TGA, *.TARGA)

:tiff

Tagged Image File Format (*.TIF, *.TIFF)

:wbmp

Wireless Bitmap (*.WBMP)

:xbm

X11 Bitmap Format (*.XBM)

:xpm

X11 Pitmap Format (*.XPM)

[show source]
# File lib/free-image/enums/formats.rb, line 46
  
image_types

FreeImage supports the following image types:

:unknown

Unknown format (returned value only, never use it as input value)

:bitmap

Standard image: 1-, 4-, 8-, 16-, 24-, 32-bit

:uint16

Array of unsigned short: unsigned 16-bit

:int16

Array of short: signed 16-bit

:uint32

Array of unsigned long: unsigned 32-bit

:int32

Array of long: signed 32-bit

:float

Array of float: 32-bit IEEE floating point

:double

Array of double: 64-bit IEEE floating point

:complex

Array of FICOMPLEX: 2 x 64-bit IEEE floating point

:rgb16

48-bit rgb image: 3 x 16-bit

:rgba16

64-bit rgba image: 4 x 16-bit

:rgbf

96-bit rgb float image: 3 x 32-bit IEEE floating point

:rgbaf

128-bit rgba float image: 4 x 32-bit IEEE floating point

[show source]
# File lib/free-image/enums/image_types.rb, line 22