7de0d120a9ffdff35abaf7702c238de7aec72116
1 {
2 $Id: ImagingTypes.pas 171 2009-09-02 01:34:19Z galfar $
3 Vampyre Imaging Library
4 by Marek Mauder
5 http://imaginglib.sourceforge.net
7 The contents of this file are used with permission, subject to the Mozilla
8 Public License Version 1.1 (the "License"); you may not use this file except
9 in compliance with the License. You may obtain a copy of the License at
10 http://www.mozilla.org/MPL/MPL-1.1.html
12 Software distributed under the License is distributed on an "AS IS" basis,
13 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14 the specific language governing rights and limitations under the License.
16 Alternatively, the contents of this file may be used under the terms of the
17 GNU Lesser General Public License (the "LGPL License"), in which case the
18 provisions of the LGPL License are applicable instead of those above.
19 If you wish to allow use of your version of this file only under the terms
20 of the LGPL License and not to allow others to use your version of this file
21 under the MPL, indicate your decision by deleting the provisions above and
22 replace them with the notice and other provisions required by the LGPL
23 License. If you do not delete the provisions above, a recipient may use
24 your version of this file under either the MPL or the LGPL License.
26 For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html
27 }
29 { This unit contains basic types and constants used by Imaging library.}
32 {$I ImagingOptions.inc}
34 interface
36 const
37 { Current Major version of Imaging.}
39 { Current Minor version of Imaging.}
41 { Current patch of Imaging.}
44 { Imaging Option Ids whose values can be set/get by SetOption/
45 GetOption functions.}
47 { Defines Jpeg compression quality, ranges from 1 (ugly/small) to 100 (nice/large).
48 Default value is 90.}
50 { Specifies whether Jpeg images are saved in progressive format,
51 can be 0 or 1. Default value is 0.}
54 { Specifies whether Windows Bitmaps are saved using RLE compression
55 (only for 1/4/8 bit images), can be 0 or 1. Default value is 1.}
58 { Specifies whether Targa images are saved using RLE compression,
59 can be 0 or 1. Default value is 0.}
62 { Value of this option is non-zero if last loaded DDS file was cube map.}
64 { Value of this option is non-zero if last loaded DDS file was volume texture.}
66 { Value of this option is number of mipmap levels of last loaded DDS image.}
68 { Value of this option is depth (slices of volume texture or faces of
69 cube map) of last loaded DDS image.}
71 { If it is non-zero next saved DDS file should be stored as cube map.}
73 { If it is non-zero next saved DDS file should be stored as volume texture.}
75 { Sets the number of mipmaps which should be stored in the next saved DDS file.
76 Only applies to cube maps and volumes, ordinary 2D textures save all
77 levels present in input.}
79 { Sets the depth (slices of volume texture or faces of cube map)
80 of the next saved DDS file.}
83 { Sets precompression filter used when saving PNG images. Allowed values
84 are: 0 (none), 1 (sub), 2 (up), 3 (average), 4 (paeth),
85 5 (use 0 for indexed/gray images and 4 for RGB/ARGB images),
86 6 (adaptive filtering - use best filter for each scanline - very slow).
87 Note that filters 3 and 4 are much slower than filters 1 and 2.
88 Default value is 5.}
90 { Sets ZLib compression level used when saving PNG images.
91 Allowed values are in range 0 (no compresstion) to 9 (best compression).
92 Default value is 5.}
94 { Boolean option that specifies whether PNG images with more frames (APNG format)
95 are animated by Imaging (according to frame disposal/blend methods) or just
96 raw frames are loaded and sent to user (if you want to animate APNG yourself).
97 Default value is 1.}
100 { Specifies whether MNG animation frames are saved with lossy or lossless
101 compression. Lossless frames are saved as PNG images and lossy frames are
102 saved as JNG images. Allowed values are 0 (False) and 1 (True).
103 Default value is 0.}
105 { Defines whether alpha channel of lossy compressed MNG frames
106 (when ImagingMNGLossyCompression is 1) is lossy compressed too.
107 Allowed values are 0 (False) and 1 (True). Default value is 0.}
109 { Sets precompression filter used when saving MNG frames as PNG images.
110 For details look at ImagingPNGPreFilter.}
112 { Sets ZLib compression level used when saving MNG frames as PNG images.
113 For details look at ImagingPNGCompressLevel.}
115 { Specifies compression quality used when saving MNG frames as JNG images.
116 For details look at ImagingJpegQuality.}
118 { Specifies whether images are saved in progressive format when saving MNG
119 frames as JNG images. For details look at ImagingJpegProgressive.}
122 { Specifies whether alpha channels of JNG images are lossy compressed.
123 Allowed values are 0 (False) and 1 (True). Default value is 0.}
125 { Sets precompression filter used when saving lossless alpha channels.
126 For details look at ImagingPNGPreFilter.}
128 { Sets ZLib compression level used when saving lossless alpha channels.
129 For details look at ImagingPNGCompressLevel.}
131 { Defines compression quality used when saving JNG images (and lossy alpha channels).
132 For details look at ImagingJpegQuality.}
134 { Specifies whether JNG images are saved in progressive format.
135 For details look at ImagingJpegProgressive.}
137 { Specifies whether PGM files are stored in text or in binary format.
138 Allowed values are 0 (store as text - very! large files) and 1 (save binary).
139 Default value is 1.}
141 { Specifies whether PPM 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.}
145 { Boolean option that specifies whether GIF images with more frames
146 are animated by Imaging (according to frame disposal methods) or just
147 raw frames are loaded and sent to user (if you want to animate GIF yourself).
148 Default value is 1.
149 Raw frames are 256 color indexed images (ifIndex8), whereas
150 animated frames are always in 32bit ifA8R8G8B8 format (simplifies animating).}
153 { This option is used when reducing number of colors used in
154 image (mainly when converting from ARGB image to indexed
155 format). Mask is 'anded' (bitwise AND) with every pixel's
156 channel value when creating color histogram. If $FF is used
157 all 8bits of color channels are used which can result in very
158 slow proccessing of large images with many colors so you can
159 use lower masks to speed it up (FC, F8 and F0 are good
160 choices). Allowed values are in range <0, $FF> and default is
161 $FE. }
163 { This option can be used to override image data format during image
164 loading. If set to format different from ifUnknown all loaded images
165 are automaticaly converted to this format. Useful when you have
166 many files in various formats but you want them all in one format for
167 further proccessing. Allowed values are in
168 range <Ord(Low(TImageFormat)), Ord(High(TImageFormat))> and
169 default value is ifUnknown.}
171 { This option can be used to override image data format during image
172 saving. If set to format different from ifUnknown all images
173 to be saved are automaticaly internaly converted to this format.
174 Note that image file formats support only a subset of Imaging data formats
175 so final saved file may in different format than this override.
176 Allowed values are in range <Ord(Low(TImageFormat)), Ord(High(TImageFormat))>
177 and default value is ifUnknown.}
179 { Specifies resampling filter used when generating mipmaps. It is used
180 in GenerateMipMaps low level function and Direct3D and OpenGL extensions.
181 Allowed values are in range
182 <Ord(Low(ImagingFormats.TSamplingFilter)), Ord(High(ImagingFormats.TSamplingFilter))>
183 and default value is 1 (linear filter).}
186 { Returned by GetOption if given Option Id is invalid.}
189 { Indices that can be used to access channel values in array parts
190 of structures like TColor32Rec. Note that this order can be
191 used only for ARGB images. For ABGR image you must swap Red and Blue.}
197 type
198 { Enum defining image data format. In formats with more channels,
199 first channel after "if" is stored in the most significant bits and channel
200 before end is stored in the least significant.}
201 TImageFormat = (
204 { Indexed formats using palette.}
206 { Grayscale/Luminance formats.}
213 { ARGB formats.}
228 { Floating point formats.}
235 { Special formats.}
243 { Color value for 32 bit images.}
247 { Color value for 64 bit images.}
251 { Color record for 24 bit images, which allows access to individual color
252 channels.}
262 { Color record for 32 bit images, which allows access to individual color
263 channels.}
275 { Color record for 48 bit images, which allows access to individual color
276 channels.}
286 { Color record for 64 bit images, which allows access to individual color
287 channels.}
299 { Color record for 128 bit floating point images, which allows access to
300 individual color channels.}
310 { 16 bit floating-point value. It has 1 sign bit, 5 exponent bits,
311 and 10 mantissa bits.}
315 { Color record for 64 bit floating point images, which allows access to
316 individual color channels.}
326 { Palette for indexed mode images with 32 bit colors.}
331 { Palette for indexd mode images with 24 bit colors.}
336 { Record that stores single image data and information describing it.}
347 { Pixel format information used in conversions to/from 16 and 8 bit ARGB
348 image formats.}
359 { Look at TImageFormatInfo.GetPixelsSize for details.}
362 { Look at TImageFormatInfo.CheckDimensions for details.}
365 { Function for getting pixel colors. Native pixel is read from Image and
366 then translated to 32 bit ARGB.}
369 { Function for getting pixel colors. Native pixel is read from Image and
370 then translated to FP ARGB.}
373 { Procedure for setting pixel colors. Input 32 bit ARGB color is translated to
374 native format and then written to Image.}
377 { Procedure for setting pixel colors. Input FP ARGB color is translated to
378 native format and then written to Image.}
382 { Additional information for each TImageFormat value.}
387 // 0 for formats where BitsPerPixel < 8 (e.g. DXT).
388 // Use GetPixelsSize function to get size of
389 // image data.
397 // e.g. A16B16G16R16 has IsRBSwapped True
399 // Red and Blue channels, ifUnknown if such
400 // format does not exist
405 // Width * Height pixels of image
407 // values of Width and Height. This
408 // procedure checks and changes dimensions
409 // to be valid for given format.
415 // compressing/decompressing special images
416 // as source/target
419 { Handle to list of image data records.}
423 { Handle to input/output.}
426 { Filters used in functions that resize images or their portions.}
427 TResizeFilter = (
432 { Seek origin mode for IO function Seek.}
433 TSeekMode = (
438 { IO functions used for reading and writing images from/to input/output.}
448 implementation
450 {
451 File Notes:
453 -- TODOS ----------------------------------------------------
454 - add lookup tables to pixel formats for fast conversions
456 -- 0.24.3 Changes/Bug Fixes ---------------------------------
457 - Added ifATI1N and ifATI2N image data formats.
459 -- 0.23 Changes/Bug Fixes -----------------------------------
460 - Added ifBTC image format and SpecialNearestFormat field
461 to TImageFormatInfo.
463 -- 0.21 Changes/Bug Fixes -----------------------------------
464 - Added option constants for PGM and PPM file formats.
465 - Added TPalette32Size256 and TPalette24Size256 types.
467 -- 0.19 Changes/Bug Fixes -----------------------------------
468 - added ImagingVersionPatch constant so bug fix only releases
469 can be distinguished from ordinary major/minor releases
470 - renamed TPixelFormat to TPixelFormatInfo to avoid name collisions
471 with Graphics.TPixelFormat
472 - added new image data formats: ifR16F, ifA16R16G16B16F,
473 ifA16B16G16R16F
474 - added pixel get/set function pointers to TImageFormatInfo
475 - added 16bit half float type and color record
476 - renamed TColorFRec to TColorFPRec (and related types too)
478 -- 0.17 Changes/Bug Fixes -----------------------------------
479 - added option ImagingMipMapFilter which now controls resampling filter
480 used when generating mipmaps
481 - added TResizeFilter type
482 - added ChannelCount to TImageFormatInfo
483 - added new option constants for MNG and JNG images
485 -- 0.15 Changes/Bug Fixes -----------------------------------
486 - added RBSwapFormat to TImageFormatInfo for faster conversions
487 between swapped formats (it just calls SwapChannels now if
488 RBSwapFormat is not ifUnknown)
489 - moved TImageFormatInfo and required types from Imaging unit
490 here, removed TImageFormatShortInfo
491 - added new options: ImagingLoadOverrideFormat, ImagingSaveOverrideFormat
493 -- 0.13 Changes/Bug Fixes -----------------------------------
494 - new ImagingColorReductionMask option added
495 - new image format added: ifA16Gray16
497 }