ImagingTypes.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. {
  2. Vampyre Imaging Library
  3. by Marek Mauder
  4. https://github.com/galfar/imaginglib
  5. https://imaginglib.sourceforge.io
  6. - - - - -
  7. This Source Code Form is subject to the terms of the Mozilla Public
  8. License, v. 2.0. If a copy of the MPL was not distributed with this
  9. file, You can obtain one at https://mozilla.org/MPL/2.0.
  10. }
  11. { This unit contains basic types and constants used by Imaging library.}
  12. unit ImagingTypes;
  13. {$I ImagingOptions.inc}
  14. interface
  15. const
  16. { Current Major version of Imaging.}
  17. ImagingVersionMajor = 0;
  18. { Current Minor version of Imaging.}
  19. ImagingVersionMinor = 82;
  20. { Imaging Option Ids whose values can be set/get by SetOption/
  21. GetOption functions.}
  22. { Defines Jpeg compression quality, ranges from 1 (ugly/small) to 100 (nice/large).
  23. Default value is 90.}
  24. ImagingJpegQuality = 10;
  25. { Specifies whether Jpeg images are saved in progressive format,
  26. can be 0 or 1. Default value is 0.}
  27. ImagingJpegProgressive = 11;
  28. { Specifies whether Windows Bitmaps are saved using RLE compression
  29. (only for 1/4/8 bit images), can be 0 or 1. Default value is 1.}
  30. ImagingBitmapRLE = 12;
  31. { Specifies whether Targa images are saved using RLE compression,
  32. can be 0 or 1. Default value is 0.}
  33. ImagingTargaRLE = 13;
  34. { Value of this option is non-zero if last loaded DDS file was cube map.}
  35. ImagingDDSLoadedCubeMap = 14;
  36. { Value of this option is non-zero if last loaded DDS file was volume texture.}
  37. ImagingDDSLoadedVolume = 15;
  38. { Value of this option is number of mipmap levels of last loaded DDS image.}
  39. ImagingDDSLoadedMipMapCount = 16;
  40. { Value of this option is depth (slices of volume texture or faces of
  41. cube map) of last loaded DDS image.}
  42. ImagingDDSLoadedDepth = 17;
  43. { If it is non-zero next saved DDS file should be stored as cube map.}
  44. ImagingDDSSaveCubeMap = 18;
  45. { If it is non-zero next saved DDS file should be stored as volume texture.}
  46. ImagingDDSSaveVolume = 19;
  47. { Sets the number of mipmaps which should be stored in the next saved DDS file.
  48. Only applies to cube maps and volumes, ordinary 2D textures save all
  49. levels present in input.}
  50. ImagingDDSSaveMipMapCount = 20;
  51. { Sets the depth (slices of volume texture or faces of cube map)
  52. of the next saved DDS file.}
  53. ImagingDDSSaveDepth = 21;
  54. { Sets precompression filter used when saving PNG images. Allowed values
  55. are: 0 (none), 1 (sub), 2 (up), 3 (average), 4 (paeth),
  56. 5 (use 0 for indexed/gray images and 4 for RGB/ARGB images),
  57. 6 (adaptive filtering - use best filter for each scanline - very slow).
  58. Note that filters 3 and 4 are much slower than filters 1 and 2.
  59. Default value is 5.}
  60. ImagingPNGPreFilter = 25;
  61. { Sets ZLib compression level used when saving PNG images.
  62. Allowed values are in range 0 (no compression) to 9 (best compression).
  63. Default value is 5.}
  64. ImagingPNGCompressLevel = 26;
  65. { Boolean option that specifies whether PNG images with more frames (APNG format)
  66. are animated by Imaging (according to frame disposal/blend methods) or just
  67. raw frames are loaded and sent to user (if you want to animate APNG yourself).
  68. Default value is 1.}
  69. ImagingPNGLoadAnimated = 27;
  70. { Sets ZLib compression strategy used when saving PNG files (see deflateInit2()
  71. in ZLib for details). Allowed values are: 0 (default), 1 (filtered),
  72. 2 (huffman only). Default value is 0.}
  73. ImagingPNGZLibStrategy = 28;
  74. { Specifies whether MNG animation frames are saved with lossy or lossless
  75. compression. Lossless frames are saved as PNG images and lossy frames are
  76. saved as JNG images. Allowed values are 0 (False) and 1 (True).
  77. Default value is 0.}
  78. ImagingMNGLossyCompression = 32;
  79. { Defines whether alpha channel of lossy compressed MNG frames
  80. (when ImagingMNGLossyCompression is 1) is lossy compressed too.
  81. Allowed values are 0 (False) and 1 (True). Default value is 0.}
  82. ImagingMNGLossyAlpha = 33;
  83. { Sets precompression filter used when saving MNG frames as PNG images.
  84. For details look at ImagingPNGPreFilter.}
  85. ImagingMNGPreFilter = 34;
  86. { Sets ZLib compression level used when saving MNG frames as PNG images.
  87. For details look at ImagingPNGCompressLevel.}
  88. ImagingMNGCompressLevel = 35;
  89. { Specifies compression quality used when saving MNG frames as JNG images.
  90. For details look at ImagingJpegQuality.}
  91. ImagingMNGQuality = 36;
  92. { Specifies whether images are saved in progressive format when saving MNG
  93. frames as JNG images. For details look at ImagingJpegProgressive.}
  94. ImagingMNGProgressive = 37;
  95. { Specifies whether alpha channels of JNG images are lossy compressed.
  96. Allowed values are 0 (False) and 1 (True). Default value is 0.}
  97. ImagingJNGLossyAlpha = 40;
  98. { Sets precompression filter used when saving lossless alpha channels.
  99. For details look at ImagingPNGPreFilter.}
  100. ImagingJNGAlphaPreFilter = 41;
  101. { Sets ZLib compression level used when saving lossless alpha channels.
  102. For details look at ImagingPNGCompressLevel.}
  103. ImagingJNGAlphaCompressLevel = 42;
  104. { Defines compression quality used when saving JNG images (and lossy alpha channels).
  105. For details look at ImagingJpegQuality.}
  106. ImagingJNGQuality = 43;
  107. { Specifies whether JNG images are saved in progressive format.
  108. For details look at ImagingJpegProgressive.}
  109. ImagingJNGProgressive = 44;
  110. { Specifies whether PGM files are stored in text or in binary format.
  111. Allowed values are 0 (store as text - very! large files) and 1 (save binary).
  112. Default value is 1.}
  113. ImagingPGMSaveBinary = 50;
  114. { Specifies whether PPM files are stored in text or in binary format.
  115. Allowed values are 0 (store as text - very! large files) and 1 (save binary).
  116. Default value is 1.}
  117. ImagingPPMSaveBinary = 51;
  118. { Boolean option that specifies whether GIF images with more frames
  119. are animated by Imaging (according to frame disposal methods) or just
  120. raw frames are loaded and sent to user (if you want to animate GIF yourself).
  121. Default value is 1.
  122. Raw frames are 256 color indexed images (ifIndex8), whereas
  123. animated frames are always in 32bit ifA8R8G8B8 format (simplifies animating).}
  124. ImagingGIFLoadAnimated = 56;
  125. { This option is used when reducing number of colors used in
  126. image (mainly when converting from ARGB image to indexed
  127. format). Mask is 'anded' (bitwise AND) with every pixel's
  128. channel value when creating color histogram. If $FF is used
  129. all 8bits of color channels are used which can result in very
  130. slow processing of large images with many colors so you can
  131. use lower masks to speed it up (FC, F8 and F0 are good
  132. choices). Allowed values are in range <0, $FF> and default is
  133. $FE. }
  134. ImagingColorReductionMask = 128;
  135. { This option can be used to override image data format during image
  136. loading. If set to format different from ifUnknown all loaded images
  137. are automatically converted to this format. Useful when you have
  138. many files in various formats but you want them all in one format for
  139. further processing. Allowed values are in
  140. range <Ord(Low(TImageFormat)), Ord(High(TImageFormat))> and
  141. default value is ifUnknown.}
  142. ImagingLoadOverrideFormat = 129;
  143. { This option can be used to override image data format during image
  144. saving. If set to format different from ifUnknown all images
  145. to be saved are automatically internally converted to this format.
  146. Note that image file formats support only a subset of Imaging data formats
  147. so final saved file may in different format than this override.
  148. Allowed values are in range <Ord(Low(TImageFormat)), Ord(High(TImageFormat))>
  149. and default value is ifUnknown.}
  150. ImagingSaveOverrideFormat = 130;
  151. { Specifies resampling filter used when generating mipmaps. It is used
  152. in GenerateMipMaps low level function and Direct3D and OpenGL extensions.
  153. Allowed values are in range
  154. <Ord(Low(ImagingFormats.TSamplingFilter)), Ord(High(ImagingFormats.TSamplingFilter))>
  155. and default value is 1 (linear filter).}
  156. ImagingMipMapFilter = 131;
  157. { Specifies threshold value used when automatically converting images to
  158. ifBinary format. For adaptive thresholding see ImagingBinary.pas unit.
  159. Default value is 128 and allowed range is 0..255.}
  160. ImagingBinaryThreshold = 132;
  161. { Returned by GetOption if given Option Id is invalid.}
  162. InvalidOption = -$7FFFFFFF;
  163. { Indices that can be used to access channel values in array parts
  164. of structures like TColor32Rec. Note that this order can be
  165. used only for ARGB images. For ABGR image you must swap Red and Blue.}
  166. ChannelBlue = 0;
  167. ChannelGreen = 1;
  168. ChannelRed = 2;
  169. ChannelAlpha = 3;
  170. type
  171. {$IFDEF DCC}
  172. {$IF CompilerVersion <= 18.5}
  173. PtrUInt = Cardinal;
  174. PtrInt = Integer;
  175. { Some new Delphi platforms (64bit POSIX) have 64bit LongInt/LongWord so rather use
  176. Int32/UInt32 where you really want 32bits.
  177. FPC has LongInt always 32 bit. }
  178. Int32 = Integer;
  179. UInt32 = Cardinal;
  180. Int16 = SmallInt;
  181. { In Delphi 7-2007 NativeInt is incorrectly defined to have size of 8 bytes,
  182. redeclare it correctly. }
  183. NativeInt = Integer;
  184. NativeUInt = Cardinal;
  185. {$ELSE}
  186. PtrUInt = NativeUInt;
  187. PtrInt = NativeInt;
  188. {$IFEND}
  189. { Not sure which Delphi version defined these (e.g. XE3 has UInt32 but not PUInt32). }
  190. {$IF not Defined(PInt32) or not Defined(PUInt32)}
  191. PInt32 = ^Int32;
  192. PUInt32 = ^UInt32;
  193. {$IFEND}
  194. {$ENDIF}
  195. { Enum defining image data format. In formats with more channels,
  196. first channel after "if" is stored in the most significant bits and channel
  197. before end is stored in the least significant.}
  198. TImageFormat = (
  199. ifUnknown = 0,
  200. ifDefault = 1,
  201. { Indexed formats using palette }
  202. ifIndex8 = 10,
  203. { Grayscale/Luminance formats }
  204. ifGray8 = 40,
  205. ifA8Gray8 = 41,
  206. ifGray16 = 42,
  207. ifGray32 = 43,
  208. ifGray64 = 44,
  209. ifA16Gray16 = 45,
  210. { ARGB formats }
  211. ifX5R1G1B1 = 80,
  212. ifR3G3B2 = 81,
  213. ifR5G6B5 = 82,
  214. ifA1R5G5B5 = 83,
  215. ifA4R4G4B4 = 84,
  216. ifX1R5G5B5 = 85,
  217. ifX4R4G4B4 = 86,
  218. ifR8G8B8 = 87,
  219. ifA8R8G8B8 = 88,
  220. ifX8R8G8B8 = 89,
  221. ifR16G16B16 = 90,
  222. ifA16R16G16B16 = 91,
  223. ifB16G16R16 = 92,
  224. ifA16B16G16R16 = 93,
  225. { Floating point formats }
  226. ifR32F = 160,
  227. ifA32R32G32B32F = 161,
  228. ifA32B32G32R32F = 162,
  229. ifR16F = 163,
  230. ifA16R16G16B16F = 164,
  231. ifA16B16G16R16F = 165,
  232. ifR32G32B32F = 166,
  233. ifB32G32R32F = 167,
  234. { Special formats }
  235. ifDXT1 = 200,
  236. ifDXT3 = 201,
  237. ifDXT5 = 202,
  238. ifBTC = 203,
  239. ifATI1N = 204,
  240. ifATI2N = 205,
  241. ifBinary = 206,
  242. { Passthrough formats }
  243. {ifETC1 = 220,
  244. ifETC2RGB = 221,
  245. ifETC2RGBA = 222,
  246. ifETC2PA = 223,
  247. ifDXBC6 = 224,
  248. ifDXBC7 = 225}
  249. ifLast = 255
  250. );
  251. { Color value for 32 bit images.}
  252. TColor32 = UInt32;
  253. PColor32 = ^TColor32;
  254. { Color value for 64 bit images.}
  255. TColor64 = type Int64;
  256. PColor64 = ^TColor64;
  257. { Color record for 24 bit images, which allows access to individual color
  258. channels.}
  259. TColor24Rec = packed record
  260. case Byte of
  261. 0: (B, G, R: Byte);
  262. 1: (Channels: array[0..2] of Byte);
  263. end;
  264. PColor24Rec = ^TColor24Rec;
  265. TColor24RecArray = array[0..MaxInt div SizeOf(TColor24Rec) - 1] of TColor24Rec;
  266. PColor24RecArray = ^TColor24RecArray;
  267. { Color record for 32 bit images, which allows access to individual color
  268. channels.}
  269. TColor32Rec = packed record
  270. case Byte of
  271. 0: (Color: TColor32);
  272. 1: (B, G, R, A: Byte);
  273. 2: (Channels: array[0..3] of Byte);
  274. 3: (Color24Rec: TColor24Rec);
  275. end;
  276. PColor32Rec = ^TColor32Rec;
  277. TColor32RecArray = array[0..MaxInt div SizeOf(TColor32Rec) - 1] of TColor32Rec;
  278. PColor32RecArray = ^TColor32RecArray;
  279. { Color record for 48 bit images, which allows access to individual color
  280. channels.}
  281. TColor48Rec = packed record
  282. case Byte of
  283. 0: (B, G, R: Word);
  284. 1: (Channels: array[0..2] of Word);
  285. end;
  286. PColor48Rec = ^TColor48Rec;
  287. TColor48RecArray = array[0..MaxInt div SizeOf(TColor48Rec) - 1] of TColor48Rec;
  288. PColor48RecArray = ^TColor48RecArray;
  289. { Color record for 64 bit images, which allows access to individual color
  290. channels.}
  291. TColor64Rec = packed record
  292. case Byte of
  293. 0: (Color: TColor64);
  294. 1: (B, G, R, A: Word);
  295. 2: (Channels: array[0..3] of Word);
  296. 3: (Color48Rec: TColor48Rec);
  297. end;
  298. PColor64Rec = ^TColor64Rec;
  299. TColor64RecArray = array[0..MaxInt div SizeOf(TColor64Rec) - 1] of TColor64Rec;
  300. PColor64RecArray = ^TColor64RecArray;
  301. { Color record for 96 bit floating point images, which allows access to
  302. individual color channels.}
  303. TColor96FPRec = packed record
  304. case Byte of
  305. 0: (B, G, R: Single);
  306. 1: (Channels: array[0..2] of Single);
  307. end;
  308. PColor96FPRec = ^TColor96FPRec;
  309. TColor96FPRecArray = array[0..MaxInt div SizeOf(TColor96FPRec) - 1] of TColor96FPRec;
  310. PColor96FPRecArray = ^TColor96FPRecArray;
  311. { Color record for 128 bit floating point images, which allows access to
  312. individual color channels.}
  313. TColorFPRec = packed record
  314. case Byte of
  315. 0: (B, G, R, A: Single);
  316. 1: (Channels: array[0..3] of Single);
  317. 2: (Color96Rec: TColor96FPRec);
  318. end;
  319. PColorFPRec = ^TColorFPRec;
  320. TColorFPRecArray = array[0..MaxInt div SizeOf(TColorFPRec) - 1] of TColorFPRec;
  321. PColorFPRecArray = ^TColorFPRecArray;
  322. { 16 bit floating-point value. It has 1 sign bit, 5 exponent bits,
  323. and 10 mantissa bits.}
  324. THalfFloat = type Word;
  325. PHalfFloat = ^THalfFloat;
  326. { Color record for 64 bit floating point images, which allows access to
  327. individual color channels.}
  328. TColorHFRec = packed record
  329. case Byte of
  330. 0: (B, G, R, A: THalfFloat);
  331. 1: (Channels: array[0..3] of THalfFloat);
  332. end;
  333. PColorHFRec = ^TColorHFRec;
  334. TColorHFRecArray = array[0..MaxInt div SizeOf(TColorHFRec) - 1] of TColorHFRec;
  335. PColorHFRecArray = ^TColorHFRecArray;
  336. { Palette for indexed mode images with 32 bit colors.}
  337. TPalette32 = TColor32RecArray;
  338. TPalette32Size256 = array[0..255] of TColor32Rec;
  339. PPalette32 = ^TPalette32;
  340. { Palette for indexd mode images with 24 bit colors.}
  341. TPalette24 = TColor24RecArray;
  342. TPalette24Size256 = array[0..255] of TColor24Rec;
  343. PPalette24 = ^TPalette24;
  344. { Record that stores single image data and information describing it.
  345. Width and Height are 32 bit integers, the image size in bytes is Int64
  346. (for older Delphi without UInt64) but total number of pixels
  347. should still fit into 32 bits for safety - not all code (e.g. iterating over NumPixels)
  348. has been updated yet.
  349. The types used should be:
  350. - width and height: Integer (32 bit always)
  351. - size in bytes: Int64
  352. - num pixels: NativeInt (so older Delphi can use it in for loops)
  353. Remember, that in Pascal when multiplying integers you need to cast (one or all operands,
  354. not the result!) to 64 bit even when the receiveng variable is 64 bit:
  355. Size64 := Int64(Width) * Height * Bpp;
  356. }
  357. TImageData = packed record
  358. Width: Integer; // Width of image in pixels
  359. Height: Integer; // Height of image in pixels
  360. Format: TImageFormat; // Data format of image
  361. Size: Int64; // Size of image bits in Bytes
  362. Bits: Pointer; // Pointer to memory containing image bits
  363. Palette: PPalette32; // Image palette for indexed images
  364. Tag: Pointer; // User data
  365. end;
  366. PImageData = ^TImageData;
  367. { Pixel format information used in conversions to/from 16 and 8 bit ARGB
  368. image formats.}
  369. TPixelFormatInfo = packed record
  370. ABitCount, RBitCount, GBitCount, BBitCount: Byte;
  371. ABitMask, RBitMask, GBitMask, BBitMask: UInt32;
  372. AShift, RShift, GShift, BShift: Byte;
  373. ARecDiv, RRecDiv, GRecDiv, BRecDiv: Byte;
  374. end;
  375. PPixelFormatInfo = ^TPixelFormatInfo;
  376. PImageFormatInfo = ^TImageFormatInfo;
  377. { Look at TImageFormatInfo.GetPixelsSize for details.}
  378. TFormatGetPixelsSizeFunc = function(Format: TImageFormat; Width,
  379. Height: Integer): Int64;
  380. { Look at TImageFormatInfo.CheckDimensions for details.}
  381. TFormatCheckDimensionsProc = procedure(Format: TImageFormat; var Width,
  382. Height: Integer);
  383. { Function for getting pixel colors. Native pixel is read from Image and
  384. then translated to 32 bit ARGB.}
  385. TGetPixel32Func = function(Bits: Pointer; Info: PImageFormatInfo;
  386. Palette: PPalette32): TColor32Rec;
  387. { Function for getting pixel colors. Native pixel is read from Image and
  388. then translated to FP ARGB.}
  389. TGetPixelFPFunc = function(Bits: Pointer; Info: PImageFormatInfo;
  390. Palette: PPalette32): TColorFPRec;
  391. { Procedure for setting pixel colors. Input 32 bit ARGB color is translated to
  392. native format and then written to Image.}
  393. TSetPixel32Proc = procedure(Bits: Pointer; Info: PImageFormatInfo;
  394. Palette: PPalette32;const Color: TColor32Rec);
  395. { Procedure for setting pixel colors. Input FP ARGB color is translated to
  396. native format and then written to Image.}
  397. TSetPixelFPProc = procedure(Bits: Pointer; Info: PImageFormatInfo;
  398. Palette: PPalette32; const Color: TColorFPRec);
  399. { Additional information for each TImageFormat value.}
  400. TImageFormatInfo = packed record
  401. Format: TImageFormat; // Format described by this record
  402. Name: array[0..15] of Char; // Symbolic name of format
  403. BytesPerPixel: Byte; // Number of bytes per pixel (note: it is
  404. // 0 for formats where BitsPerPixel < 8 (e.g. DXT).
  405. // Use GetPixelsSize function to get size of
  406. // image data.
  407. ChannelCount: Byte; // Number of image channels (R, G, B, A, Gray)
  408. PaletteEntries: Word; // Number of palette entries
  409. HasGrayChannel: Boolean; // True if image has grayscale channel
  410. HasAlphaChannel: Boolean; // True if image has alpha channel
  411. IsFloatingPoint: Boolean; // True if image has floating point pixels
  412. UsePixelFormat: Boolean; // True if image uses pixel format
  413. IsRBSwapped: Boolean; // True if Red and Blue channels are swapped
  414. // e.g. A16B16G16R16 has IsRBSwapped True
  415. RBSwapFormat: TImageFormat; // Indicates supported format with swapped
  416. // Red and Blue channels, ifUnknown if such
  417. // format does not exist
  418. IsIndexed: Boolean; // True if image uses palette
  419. IsSpecial: Boolean; // True if image is in special format
  420. IsPassthrough: Boolean; // True if image is in passthrough program (Imaging
  421. // itself doesn't know how to decode and encode it -
  422. // complex texture compressions etc.)
  423. PixelFormat: PPixelFormatInfo; // Pixel format structure
  424. GetPixelsSize: TFormatGetPixelsSizeFunc; // Returns size in bytes of
  425. // Width * Height pixels of image
  426. CheckDimensions: TFormatCheckDimensionsProc; // some formats have limited
  427. // values of Width and Height. This
  428. // procedure checks and changes dimensions
  429. // to be valid for given format.
  430. GetPixel32: TGetPixel32Func; // 32bit ARGB pixel get function
  431. GetPixelFP: TGetPixelFPFunc; // FP ARGB pixel get function
  432. SetPixel32: TSetPixel32Proc; // 32bit ARGB pixel set procedure
  433. SetPixelFP: TSetPixelFPProc; // FP ARGB pixel set procedure
  434. SpecialNearestFormat: TImageFormat; // Regular image format used when
  435. // compressing/decompressing special images
  436. // as source/target
  437. end;
  438. { Handle to input/output.}
  439. TImagingHandle = Pointer;
  440. { Filters used in functions that resize images or their portions.}
  441. TResizeFilter = (
  442. rfNearest = 0,
  443. rfBilinear = 1,
  444. rfBicubic = 2,
  445. rfLanczos = 3);
  446. { Seek origin mode for IO function Seek.}
  447. TSeekMode = (
  448. smFromBeginning = 0,
  449. smFromCurrent = 1,
  450. smFromEnd = 2);
  451. TOpenMode = (
  452. omReadOnly = 0, // Opens file for reading only
  453. omCreate = 1, // Creates new file (overwriting any existing) and opens it for writing
  454. omReadWrite = 2 // Opens for reading and writing. Non existing file is created.
  455. );
  456. { IO functions used for reading and writing images from/to input/output.}
  457. {$IFDEF DELPHI}
  458. TIOReadWriteCount = NativeInt;
  459. {$ELSE}
  460. // FPC 3.2.2 still has only TStream with Read/Write count as LongInt
  461. TIOReadWriteCount = LongInt;
  462. {$ENDIF}
  463. TOpenProc = function(Source: PChar; Mode: TOpenMode): TImagingHandle; cdecl;
  464. TCloseProc = procedure(Handle: TImagingHandle); cdecl;
  465. TEofProc = function(Handle: TImagingHandle): Boolean; cdecl;
  466. TSeekProc = function(Handle: TImagingHandle; Offset: Int64; Mode: TSeekMode): Int64; cdecl;
  467. TTellProc = function(Handle: TImagingHandle): Int64; cdecl;
  468. TReadProc = function(Handle: TImagingHandle; Buffer: Pointer; Count: TIOReadWriteCount): TIOReadWriteCount; cdecl;
  469. TWriteProc = function(Handle: TImagingHandle; Buffer: Pointer; Count: TIOReadWriteCount): TIOReadWriteCount; cdecl;
  470. implementation
  471. {
  472. File Notes:
  473. * More recent changes are in VCS history *
  474. -- 0.80 -----------------------------------------------------
  475. - Dropped "patch version".
  476. -- 0.77.3 ---------------------------------------------------
  477. - IO functions now have 64bit sizes and offsets.
  478. -- 0.77.1 ---------------------------------------------------
  479. - Added Tag to TImageData for storing user data.
  480. - Added ImagingPNGZLibStrategy option.
  481. - Changed IO functions. Merged open functions to one
  482. and added third open mode R/W (for TIFF append etc.).
  483. - Added new image data formats and related structures:
  484. ifR32G32B32F, ifB32G32G32F.
  485. -- 0.26.5 Changes/Bug Fixes ---------------------------------
  486. - Added ifBinary image format and ImagingBinaryThreshold option.
  487. - Lanczos filter added to TResizeFilter enum.
  488. -- 0.24.3 Changes/Bug Fixes ---------------------------------
  489. - Added ifATI1N and ifATI2N image data formats.
  490. -- 0.23 Changes/Bug Fixes -----------------------------------
  491. - Added ifBTC image format and SpecialNearestFormat field
  492. to TImageFormatInfo.
  493. -- 0.21 Changes/Bug Fixes -----------------------------------
  494. - Added option constants for PGM and PPM file formats.
  495. - Added TPalette32Size256 and TPalette24Size256 types.
  496. -- 0.19 Changes/Bug Fixes -----------------------------------
  497. - added ImagingVersionPatch constant so bug fix only releases
  498. can be distinguished from ordinary major/minor releases
  499. - renamed TPixelFormat to TPixelFormatInfo to avoid name collisions
  500. with Graphics.TPixelFormat
  501. - added new image data formats: ifR16F, ifA16R16G16B16F,
  502. ifA16B16G16R16F
  503. - added pixel get/set function pointers to TImageFormatInfo
  504. - added 16bit half float type and color record
  505. - renamed TColorFRec to TColorFPRec (and related types too)
  506. -- 0.17 Changes/Bug Fixes -----------------------------------
  507. - added option ImagingMipMapFilter which now controls resampling filter
  508. used when generating mipmaps
  509. - added TResizeFilter type
  510. - added ChannelCount to TImageFormatInfo
  511. - added new option constants for MNG and JNG images
  512. -- 0.15 Changes/Bug Fixes -----------------------------------
  513. - added RBSwapFormat to TImageFormatInfo for faster conversions
  514. between swapped formats (it just calls SwapChannels now if
  515. RBSwapFormat is not ifUnknown)
  516. - moved TImageFormatInfo and required types from Imaging unit
  517. here, removed TImageFormatShortInfo
  518. - added new options: ImagingLoadOverrideFormat, ImagingSaveOverrideFormat
  519. -- 0.13 Changes/Bug Fixes -----------------------------------
  520. - new ImagingColorReductionMask option added
  521. - new image format added: ifA16Gray16
  522. }
  523. end.