pngcomn.pp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 by the Free Pascal development team
  4. PNG reader/writer common code.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$mode objfpc}{$h+}
  12. unit PNGcomn;
  13. interface
  14. uses SysUtils, FPImage, FPImgCmn;
  15. type
  16. PNGImageException = class (FPImageException);
  17. TChunkTypes = (
  18. ctIHDR, ctcHRM, ctgAMA, ctsBIT,
  19. ctPLTE, ctbKGD, cthIST, cttRNS,
  20. ctoFFs, ctpHYs, ctIDAT, cttIME,
  21. ctsCAL, cttEXt, ctzTXt, ctIEND,
  22. ctsRGB, ctiCCP, ctiTXt, ctsPLT,
  23. ctUnknown
  24. );
  25. EightLong = array[0..7] of longword;
  26. TChunkCode = array[0..3] of char;
  27. TChunk = record
  28. acapacity, alength, CRC : longword;
  29. ReadType : TChunkCode;
  30. data : PByteArray;
  31. aType : TChunkTypes;
  32. end;
  33. TChunkHeader = record
  34. CLength : longword;
  35. CType : TChunkCode;
  36. end;
  37. THeaderChunk = record
  38. Width, height : longword;
  39. BitDepth, ColorType, Compression, Filter, Interlace : byte;
  40. end;
  41. const
  42. Signature : Array[0..7] of Byte = ($89, $50, $4E, $47, $0D, $0A, $1A, $0A);
  43. MaxChunkLength = $7FFFFFFF;
  44. All1Bits : longword = $FFFFFFFF;
  45. ChunkTypes : array[TChunkTypes] of TChunkCode = (
  46. 'IHDR', 'cHRM', 'gAMA', 'sBIT',
  47. 'PLTE', 'bKGD', 'hIST', 'tRNS',
  48. 'oFFs', 'pHYs', 'IDAT', 'tIME',
  49. 'sCAL', 'tEXt', 'zTXt', 'IEND',
  50. 'sRGB', 'iCCP', 'iTXt', 'sPLT',
  51. 'Unkn'
  52. );
  53. ChunkAncillary = $10000000;
  54. ChunkPrivate = $00100000;
  55. ChunkReserved = $00001000;
  56. ChunkSafeCopy = $00000010;
  57. StartRow : Array[0..7] of Integer = (0, 0, 0, 4, 0, 2, 0, 1);
  58. StartCol : Array[0..7] of Integer = (0, 0, 4, 0, 2, 0, 1, 0);
  59. RowInc : Array[0..7] of Integer = (1, 8, 8, 8, 4, 4, 2, 2);
  60. ColInc : Array[0..7] of Integer = (1, 8, 8, 4, 4, 2, 2, 1);
  61. BlockHght : Array[0..7] of Integer = (1, 8, 8, 4, 4, 2, 2, 1);
  62. BlockWdth : Array[0..7] of Integer = (1, 8, 4, 4, 2, 2, 1, 1);
  63. implementation
  64. end.