Module: FreeImage
- Extended by:
- FFI::Library
- Defined in:
- lib/free-image.rb,
lib/free-image/bitmap.rb,
lib/free-image/errors.rb,
lib/free-image/palette.rb,
lib/free-image/scanline.rb,
lib/free-image/types/ffi.rb,
lib/free-image/sources/io.rb,
lib/free-image/types/rgbf.rb,
lib/free-image/modules/icc.rb,
lib/free-image/types/rgb16.rb,
lib/free-image/types/rgbaf.rb,
lib/free-image/sources/file.rb,
lib/free-image/types/rgba16.rb,
lib/free-image/enums/dithers.rb,
lib/free-image/enums/filters.rb,
lib/free-image/enums/formats.rb,
lib/free-image/types/boolean.rb,
lib/free-image/types/complex.rb,
lib/free-image/modules/helper.rb,
lib/free-image/modules/modify.rb,
lib/free-image/modules/pixels.rb,
lib/free-image/sources/memory.rb,
lib/free-image/types/rgb_quad.rb,
lib/free-image/types/rgb_triple.rb,
lib/free-image/enums/color_types.rb,
lib/free-image/enums/image_types.rb,
lib/free-image/types/info_header.rb,
lib/free-image/modules/transforms.rb,
lib/free-image/modules/conversions.rb,
lib/free-image/modules/information.rb,
lib/free-image/sources/abstract_source.rb
Defined Under Namespace
Modules: Conversions, ICC, Information, Modify, Pixels, Transforms Classes: AbstractSource, Bitmap, Boolean, Complex, Error, File, IO, IOStruct, InfoHeader, Memory, MemoryStream, Palette, RGB16, RGB16BF565, RGBA16, RGBAF, RGBF, RGBQuad, RGBTriple, Scanline
Constant Summary collapse
- LAST_ERROR =
'free_image_error'
- 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. = ptr.get_string(0) Thread.current[LAST_ERROR] = Error.new(format, ) end
- COLOR_IS_RGB_COLOR =
RGBQUAD color is a RGB color (contains no valid alpha channel)
0x00
- COLOR_IS_RGBA_COLOR =
RGBQUAD color is a RGBA color (contains a valid alpha channel)
0x01
- COLOR_FIND_EQUAL_COLOR =
For palettized images: lookup equal RGB color from palette
0x02
- COLOR_ALPHA_IS_INDEX =
The color’s rgbReserved member (alpha) contains the palette index to be used
0x04
- COLOR_PALETTE_SEARCH_MASK =
No color lookup is performed
(COLOR_FIND_EQUAL_COLOR | COLOR_ALPHA_IS_INDEX)
- RGB =
BI_RGB
0
- BITFIELDS =
BI_BITFIELDS
3
Class Method Summary collapse
- .check_last_error ⇒ Object
-
.copyright ⇒ Object
:call-seq: copyright -> string.
- .find_lib(lib) ⇒ Object
- .free_image_library_paths ⇒ Object
- .icc_supported ⇒ Object
-
.little_endian? ⇒ Boolean
:call-seq: is_little_endian? -> boolean.
- .msvc? ⇒ Boolean
- .search_paths ⇒ Object
-
.version ⇒ Object
:call-seq: version -> string.
Instance Method Summary collapse
-
#color_type ⇒ Object
FreeImage supports the following color types:.
-
#dither ⇒ Object
FreeImage supports the following dithering algorithms:.
-
#filter ⇒ Object
FreeImage supports the following rescaling filters:.
-
#format ⇒ Object
FreeImage supports over 30 bitmap types, which are indentified via symbols.
-
#image_type ⇒ Object
FreeImage supports the following image types:.
Class Method Details
.check_last_error ⇒ Object
38 39 40 41 42 |
# 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 |
.copyright ⇒ Object
:call-seq:
copyright -> string
Returns a standard copyright message you can show in your program.
27 28 29 |
# File 'lib/free-image/modules/helper.rb', line 27 def self.copyright FreeImage.FreeImage_GetCopyrightMessage end |
.find_lib(lib) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/free-image.rb', line 29 def self.find_lib(lib) files = search_paths.inject(Array.new) do |array, path| file_name = File.(File.join(path, "#{lib}.#{FFI::Platform::LIBSUFFIX}")) array << Dir.glob(file_name) array end files.flatten.compact.first end |
.free_image_library_paths ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/free-image.rb', line 38 def self.free_image_library_paths @free_image_library_paths ||= begin libs = %w{libfreeimage libfreeimage.3 libfreeimage-3 FreeImage} libs.map do |lib| find_lib(lib) end.compact end end |
.icc_supported ⇒ Object
.little_endian? ⇒ Boolean
:call-seq:
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).
39 40 41 |
# File 'lib/free-image/modules/helper.rb', line 39 def self.little_endian? FreeImage.FreeImage_IsLittleEndian end |
.msvc? ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/free-image.rb', line 6 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 ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/free-image.rb', line 17 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 ⇒ Object
:call-seq:
version -> string
Returns the current version of the FreeImage library
17 18 19 |
# File 'lib/free-image/modules/helper.rb', line 17 def self.version FreeImage.FreeImage_GetVersion end |
Instance Method Details
#color_type ⇒ Object
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)
:method: color_types
18 19 20 21 22 23 |
# File 'lib/free-image/enums/color_types.rb', line 18 FreeImage.enum :color_type, [:minis_white, 0, :minis_black, 1, :rgb, 2, :palette, 3, :rgb_alpha, 4, :cmyk, 5] |
#dither ⇒ Object
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)
:method: dithers
17 18 19 20 21 22 23 |
# File 'lib/free-image/enums/dithers.rb', line 17 FreeImage.enum :dither, [:fs, 0, :bayer4x4, 1, :bayer8x8, 2, :cluster6x6, 3, :cluster8x8, 4, :cluster16x16, 5, :bayer16x16, 6] |
#filter ⇒ Object
FreeImage supports the following rescaling filters:
:method: filters
6 7 8 9 10 11 |
# File 'lib/free-image/enums/filters.rb', line 6 enum :filter, [:box, 0, :bicubic, 1, :bilinear, 2, :bspline, 3, :catmullrom, 4, :lanczos3, 5] |
#format ⇒ Object
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)
:method: formats
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/free-image/enums/formats.rb', line 47 FreeImage.enum :format, [:unknown, -1, :bmp, 0, :ico , 1, :jpeg, 2, :jng , 3, :koala, 4, :lbm, 5, :iff, 5, # Yes this is intentional! :mng, 6, :pbm, 7, :pbmraw, 8, :pcd, 9, :pcsx, 10, :pgm, 11, :pgmraw, 12, :png, 13, :ppm, 14, :ppmraw, 15, :ras, 16, :targa, 17, :tiff, 18, :wbmp, 19, :psd, 20, :cut, 21, :xbm, 22, :xpm, 23, :dds, 24, :gif, 25, :hdr, 26, :faxg3, 27, :sgi, 28, :exr, 29, :j2k, 30, :jp2, 31, :pfm, 32, :pict, 33, :raw, 34] |
#image_type ⇒ Object
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
:method: image_types
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/free-image/enums/image_types.rb', line 23 FreeImage.enum :image_type, [:unknown, :bitmap, :uint16, :int16, :uint32, :int32, :float, :double, :complex, :rgb16, :rgba16, :rgbf, :rgbaf] |