1 {
2 Vampyre Imaging Library
3 by Marek Mauder
4 http://imaginglib.sourceforge.net
6 The contents of this file are used with permission, subject to the Mozilla
7 Public License Version 1.1 (the "License"); you may not use this file except
8 in compliance with the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/MPL-1.1.html
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
13 the specific language governing rights and limitations under the License.
15 Alternatively, the contents of this file may be used under the terms of the
16 GNU Lesser General Public License (the "LGPL License"), in which case the
17 provisions of the LGPL License are applicable instead of those above.
18 If you wish to allow use of your version of this file only under the terms
19 of the LGPL License and not to allow others to use your version of this file
20 under the MPL, indicate your decision by deleting the provisions above and
21 replace them with the notice and other provisions required by the LGPL
22 License. If you do not delete the provisions above, a recipient may use
23 your version of this file under either the MPL or the LGPL License.
25 For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html
26 }
28 { This unit contains basic types and constants used by Imaging library.}
31 {$I ImagingOptions.inc}
33 interface
35 const
36 { Current Major version of Imaging.}
38 { Current Minor version of Imaging.}
40 { Current patch of Imaging.}
43 { Imaging Option Ids whose values can be set/get by SetOption/
44 GetOption functions.}
46 { Defines Jpeg compression quality, ranges from 1 (ugly/small) to 100 (nice/large).
47 Default value is 90.}
49 { Specifies whether Jpeg images are saved in progressive format,
50 can be 0 or 1. Default value is 0.}
53 { Specifies whether Windows Bitmaps are saved using RLE compression
54 (only for 1/4/8 bit images), can be 0 or 1. Default value is 1.}
57 { Specifies whether Targa images are saved using RLE compression,
58 can be 0 or 1. Default value is 0.}
61 { Value of this option is non-zero if last loaded DDS file was cube map.}
63 { Value of this option is non-zero if last loaded DDS file was volume texture.}
65 { Value of this option is number of mipmap levels of last loaded DDS image.}
67 { Value of this option is depth (slices of volume texture or faces of
68 cube map) of last loaded DDS image.}
70 { If it is non-zero next saved DDS file should be stored as cube map.}
72 { If it is non-zero next saved DDS file should be stored as volume texture.}
74 { Sets the number of mipmaps which should be stored in the next saved DDS file.
75 Only applies to cube maps and volumes, ordinary 2D textures save all
76 levels present in input.}
78 { Sets the depth (slices of volume texture or faces of cube map)
79 of the next saved DDS file.}
82 { Sets precompression filter used when saving PNG images. Allowed values
83 are: 0 (none), 1 (sub), 2 (up), 3 (average), 4 (paeth),
84 5 (use 0 for indexed/gray images and 4 for RGB/ARGB images),
85 6 (adaptive filtering - use best filter for each scanline - very slow).
86 Note that filters 3 and 4 are much slower than filters 1 and 2.
87 Default value is 5.}
89 { Sets ZLib compression level used when saving PNG images.
90 Allowed values are in range 0 (no compresstion) to 9 (best compression).
91 Default value is 5.}
93 { Boolean option that specifies whether PNG images with more frames (APNG format)
94 are animated by Imaging (according to frame disposal/blend methods) or just
95 raw frames are loaded and sent to user (if you want to animate APNG yourself).
96 Default value is 1.}
98 { Sets ZLib compression strategy used when saving PNG files (see deflateInit2()
99 in ZLib for details). Allowed values are: 0 (default), 1 (filtered),
100 2 (huffman only). Default value is 0.}
103 { Specifies whether MNG animation frames are saved with lossy or lossless
104 compression. Lossless frames are saved as PNG images and lossy frames are
105 saved as JNG images. Allowed values are 0 (False) and 1 (True).
106 Default value is 0.}
108 { Defines whether alpha channel of lossy compressed MNG frames
109 (when ImagingMNGLossyCompression is 1) is lossy compressed too.
110 Allowed values are 0 (False) and 1 (True). Default value is 0.}
112 { Sets precompression filter used when saving MNG frames as PNG images.
113 For details look at ImagingPNGPreFilter.}
115 { Sets ZLib compression level used when saving MNG frames as PNG images.
116 For details look at ImagingPNGCompressLevel.}
118 { Specifies compression quality used when saving MNG frames as JNG images.
119 For details look at ImagingJpegQuality.}
121 { Specifies whether images are saved in progressive format when saving MNG
122 frames as JNG images. For details look at ImagingJpegProgressive.}
125 { Specifies whether alpha channels of JNG images are lossy compressed.
126 Allowed values are 0 (False) and 1 (True). Default value is 0.}
128 { Sets precompression filter used when saving lossless alpha channels.
129 For details look at ImagingPNGPreFilter.}
131 { Sets ZLib compression level used when saving lossless alpha channels.
132 For details look at ImagingPNGCompressLevel.}
134 { Defines compression quality used when saving JNG images (and lossy alpha channels).
135 For details look at ImagingJpegQuality.}
137 { Specifies whether JNG images are saved in progressive format.
138 For details look at ImagingJpegProgressive.}
141 { Specifies whether PGM files are stored in text or in binary format.
142 Allowed values are 0 (store as text - very! large files) and 1 (save binary).
143 Default value is 1.}
146 { Specifies whether PPM files are stored in text or in binary format.
147 Allowed values are 0 (store as text - very! large files) and 1 (save binary).
148 Default value is 1.}
151 { Boolean option that specifies whether GIF images with more frames
152 are animated by Imaging (according to frame disposal methods) or just
153 raw frames are loaded and sent to user (if you want to animate GIF yourself).
154 Default value is 1.
155 Raw frames are 256 color indexed images (ifIndex8), whereas
156 animated frames are always in 32bit ifA8R8G8B8 format (simplifies animating).}
159 { This option is used when reducing number of colors used in
160 image (mainly when converting from ARGB image to indexed
161 format). Mask is 'anded' (bitwise AND) with every pixel's
162 channel value when creating color histogram. If $FF is used
163 all 8bits of color channels are used which can result in very
164 slow proccessing of large images with many colors so you can
165 use lower masks to speed it up (FC, F8 and F0 are good
166 choices). Allowed values are in range <0, $FF> and default is
167 $FE. }
169 { This option can be used to override image data format during image
170 loading. If set to format different from ifUnknown all loaded images
171 are automaticaly converted to this format. Useful when you have
172 many files in various formats but you want them all in one format for
173 further proccessing. Allowed values are in
174 range <Ord(Low(TImageFormat)), Ord(High(TImageFormat))> and
175 default value is ifUnknown.}
177 { This option can be used to override image data format during image
178 saving. If set to format different from ifUnknown all images
179 to be saved are automaticaly internaly converted to this format.
180 Note that image file formats support only a subset of Imaging data formats
181 so final saved file may in different format than this override.
182 Allowed values are in range <Ord(Low(TImageFormat)), Ord(High(TImageFormat))>
183 and default value is ifUnknown.}
185 { Specifies resampling filter used when generating mipmaps. It is used
186 in GenerateMipMaps low level function and Direct3D and OpenGL extensions.
187 Allowed values are in range
188 <Ord(Low(ImagingFormats.TSamplingFilter)), Ord(High(ImagingFormats.TSamplingFilter))>
189 and default value is 1 (linear filter).}
191 { Specifies treshold value used when automatically converting images to
192 ifBinary format. For adaptive tresholding see ImagingBinary.pas unit.
193 Default value is 128 and allowed range is 0..255.}
196 { Returned by GetOption if given Option Id is invalid.}
199 { Indices that can be used to access channel values in array parts
200 of structures like TColor32Rec. Note that this order can be
201 used only for ARGB images. For ABGR image you must swap Red and Blue.}
207 type
208 { Enum defining image data format. In formats with more channels,
209 first channel after "if" is stored in the most significant bits and channel
210 before end is stored in the least significant.}
211 TImageFormat = (
214 { Indexed formats using palette }
216 { Grayscale/Luminance formats }
223 { ARGB formats }
238 { Floating point formats }
247 { Special formats }
255 { Passtrough formats }
256 {ifETC1 = 220,
257 ifETC2RGB = 221,
258 ifETC2RGBA = 222,
259 ifETC2PA = 223,
260 ifDXBC6 = 224,
261 ifDXBC7 = 225}
262 );
264 { Color value for 32 bit images.}
268 { Color value for 64 bit images.}
272 { Color record for 24 bit images, which allows access to individual color
273 channels.}
283 { Color record for 32 bit images, which allows access to individual color
284 channels.}
296 { Color record for 48 bit images, which allows access to individual color
297 channels.}
307 { Color record for 64 bit images, which allows access to individual color
308 channels.}
320 { Color record for 96 bit floating point images, which allows access to
321 individual color channels.}
331 { Color record for 128 bit floating point images, which allows access to
332 individual color channels.}
343 { 16 bit floating-point value. It has 1 sign bit, 5 exponent bits,
344 and 10 mantissa bits.}
348 { Color record for 64 bit floating point images, which allows access to
349 individual color channels.}
359 { Palette for indexed mode images with 32 bit colors.}
364 { Palette for indexd mode images with 24 bit colors.}
369 { Record that stores single image data and information describing it.}
381 { Pixel format information used in conversions to/from 16 and 8 bit ARGB
382 image formats.}
393 { Look at TImageFormatInfo.GetPixelsSize for details.}
396 { Look at TImageFormatInfo.CheckDimensions for details.}
399 { Function for getting pixel colors. Native pixel is read from Image and
400 then translated to 32 bit ARGB.}
403 { Function for getting pixel colors. Native pixel is read from Image and
404 then translated to FP ARGB.}
407 { Procedure for setting pixel colors. Input 32 bit ARGB color is translated to
408 native format and then written to Image.}
411 { Procedure for setting pixel colors. Input FP ARGB color is translated to
412 native format and then written to Image.}
416 { Additional information for each TImageFormat value.}
421 // 0 for formats where BitsPerPixel < 8 (e.g. DXT).
422 // Use GetPixelsSize function to get size of
423 // image data.
431 // e.g. A16B16G16R16 has IsRBSwapped True
433 // Red and Blue channels, ifUnknown if such
434 // format does not exist
438 // iself doesn't know how to decode and encode it -
439 // complex texture compressions etc.)
442 // Width * Height pixels of image
444 // values of Width and Height. This
445 // procedure checks and changes dimensions
446 // to be valid for given format.
452 // compressing/decompressing special images
453 // as source/target
456 { Handle to list of image data records.}
460 { Handle to input/output.}
463 { Filters used in functions that resize images or their portions.}
464 TResizeFilter = (
470 { Seek origin mode for IO function Seek.}
471 TSeekMode = (
476 TOpenMode = (
480 );
482 { IO functions used for reading and writing images from/to input/output.}
491 {$IFNDEF FPC}
492 type
493 {$IF CompilerVersion <= 18.5}
495 {$ELSE}
497 {$IFEND}
498 {$ENDIF}
500 implementation
502 {
503 File Notes:
505 -- TODOS ----------------------------------------------------
506 - add lookup tables to pixel formats for fast conversions
508 -- 0.77.1 ---------------------------------------------------
509 - Added "Passtrough" image data formats.
510 - Added Tag to TImageData for storing user data.
511 - Added ImagingPNGZLibStrategy option.
512 - Changed IO functions. Merged open functions to one
513 and added third open mode R/W (for TIFF append etc.).
514 - Added new image data formats and related structures:
515 ifR32G32B32F, ifB32G32G32F.
517 -- 0.26.5 Changes/Bug Fixes ---------------------------------
518 - Added ifBinary image format and ImagingBinaryTreshold option.
519 - Lanczos filter added to TResizeFilter enum.
521 -- 0.24.3 Changes/Bug Fixes ---------------------------------
522 - Added ifATI1N and ifATI2N image data formats.
524 -- 0.23 Changes/Bug Fixes -----------------------------------
525 - Added ifBTC image format and SpecialNearestFormat field
526 to TImageFormatInfo.
528 -- 0.21 Changes/Bug Fixes -----------------------------------
529 - Added option constants for PGM and PPM file formats.
530 - Added TPalette32Size256 and TPalette24Size256 types.
532 -- 0.19 Changes/Bug Fixes -----------------------------------
533 - added ImagingVersionPatch constant so bug fix only releases
534 can be distinguished from ordinary major/minor releases
535 - renamed TPixelFormat to TPixelFormatInfo to avoid name collisions
536 with Graphics.TPixelFormat
537 - added new image data formats: ifR16F, ifA16R16G16B16F,
538 ifA16B16G16R16F
539 - added pixel get/set function pointers to TImageFormatInfo
540 - added 16bit half float type and color record
541 - renamed TColorFRec to TColorFPRec (and related types too)
543 -- 0.17 Changes/Bug Fixes -----------------------------------
544 - added option ImagingMipMapFilter which now controls resampling filter
545 used when generating mipmaps
546 - added TResizeFilter type
547 - added ChannelCount to TImageFormatInfo
548 - added new option constants for MNG and JNG images
550 -- 0.15 Changes/Bug Fixes -----------------------------------
551 - added RBSwapFormat to TImageFormatInfo for faster conversions
552 between swapped formats (it just calls SwapChannels now if
553 RBSwapFormat is not ifUnknown)
554 - moved TImageFormatInfo and required types from Imaging unit
555 here, removed TImageFormatShortInfo
556 - added new options: ImagingLoadOverrideFormat, ImagingSaveOverrideFormat
558 -- 0.13 Changes/Bug Fixes -----------------------------------
559 - new ImagingColorReductionMask option added
560 - new image format added: ifA16Gray16
562 }