Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
3.8 KiB

  1. // Copyright (C) Microsoft Corporation 1996-1997, All Rights reserved.
  2. #include "cstream.h"
  3. #pragma pack(push, 1)
  4. typedef struct {
  5. WORD log_width;
  6. WORD log_height;
  7. struct {
  8. BYTE ceGCT:3;
  9. BYTE fSort:1;
  10. BYTE cPrimaries:3;
  11. BYTE fGCT:1;
  12. } b;
  13. BYTE iBackground;
  14. BYTE wAspect;
  15. } LSD;
  16. #pragma pack(pop)
  17. // IFFERROR: Possible errors
  18. typedef int IFFERROR;
  19. const int IFFERR_NONE = 0; // no error
  20. const int IFFERR_HANDLELIMIT = 1; // too many open files
  21. const int IFFERR_PARAMETER = 2; // programmer error
  22. const int IFFERR_NOTSUPPORTED = 3; // feature not supported by format
  23. const int IFFERR_NOTAVAILABLE = 4; // item not available
  24. const int IFFERR_MEMORY = 5; // insufficient memory
  25. const int IFFERR_IMAGE = 6; // bad image data (decompression error)
  26. const int IFFERR_HEADER = 7; // header has bad fields
  27. const int IFFERR_IO_OPEN = 8; // error on open()
  28. const int IFFERR_IO_CLOSE = 9; // error on close()
  29. const int IFFERR_IO_READ = 10; // error on read()
  30. const int IFFERR_IO_WRITE = 11; // error on write()
  31. const int IFFERR_IO_SEEK = 12; // error on lseek()
  32. typedef enum {
  33. IFFCL_BILEVEL, // 1 BPP
  34. IFFCL_GRAY, // 2,4,6,8 BPP
  35. IFFCL_PALETTE, // 2,4,6,8 BPP
  36. IFFCL_RGB, // 24 BPP chunky
  37. IFFCL_RGBPLANAR, // 24 BPP in 8 bit planes
  38. IFFCL_RGBA, // 32 BPP chunky
  39. IFFCL_RGBAPLANAR, // 32 BPP in four 8 bit planes*/
  40. IFFCL_CMYK,
  41. IFFCL_YCC,
  42. IFFCL_CIELAB,
  43. } IFFCLASS;
  44. // IFFCOMPRESSION: Compression options
  45. typedef enum {
  46. IFFCOMP_NONE, // no compression
  47. IFFCOMP_DEFAULT, // whatever is defined for the format
  48. IFFCOMP_LZW, // Lempel-Zif
  49. } IFFCOMPRESSION;
  50. // IFFSEQUENCE: Line sequences
  51. typedef enum {
  52. IFFSEQ_TOPDOWN,
  53. IFFSEQ_BOTTOMUP, // BMP and TGA compressed
  54. IFFSEQ_INTERLACED, // for GIF
  55. } IFFSEQUENCE;
  56. typedef struct {
  57. int CharSize; // size of input data
  58. int CodeSize; // Max bits in a code
  59. int ClearCode; // based on CharSize
  60. int CurBits; // current size of a code
  61. int BitPos; // range = 0 - 7, 0 is MSB
  62. int OldCode; // continuity data for STREAMEXPAND
  63. int TableEntry;
  64. UINT LastChar;
  65. int OutString; // offset into Stack
  66. int CodeJump;
  67. int *CodeTable; // Compress and Expand
  68. PBYTE StringTable; // Expand only
  69. int *HashTable; // Compress only
  70. PBYTE Stack; // Expand only
  71. LPBYTE CodeInput;
  72. LPBYTE CodeOutput;
  73. } LZDATA;
  74. typedef struct
  75. {
  76. IFFCLASS Class; // Class of file
  77. int Bits;
  78. int DimX;
  79. int DimY;
  80. int LineOffset; // Offset between lines in output buffer
  81. int LineBytes; // Bytes per line w/o padding - LineBytes <= LineOffset
  82. int PackMode; // Packing.
  83. int curline; // Current line number
  84. int linelen; // For seeking and other stuff (<0 if not seekable)
  85. IFFERROR Error; // file format error
  86. CStream* prstream; // read stream
  87. // End of required fields
  88. int BytesPerLine;
  89. IFFSEQUENCE Sequence;
  90. int BytesInRWBuffer; // number of bytes in rwbuffer
  91. int CompBufferSize;
  92. int DecompBufferSize;
  93. LPBYTE RWBuffer; // allocated buffer
  94. LPBYTE rw_ptr;
  95. LPBYTE DecompBuffer;
  96. LPBYTE dcmp_ptr;
  97. int ReadItAll;
  98. int BytesLeft;
  99. int StripLines;
  100. int LinesPerStrip;
  101. int ActualLinesPerStrip;
  102. int PaletteSize;
  103. LPBYTE Palette;
  104. LZDATA* plzData;
  105. BOOL BlackOnWhite;
  106. LSD lsd;
  107. } IFF_FID, IFF_GIF;
  108. FSERR SetupForRead(int pos, int iWhichImage, IFF_FID* piff);
  109. typedef IFF_FID *IFFPTR;
  110. // IFFPACKMODE: Packing modes
  111. typedef enum {
  112. IFFPM_PACKED,
  113. IFFPM_UNPACKED,
  114. IFFPM_LEFTJUSTIFIED,
  115. IFFPM_NORMALIZED,
  116. IFFPM_RAW,
  117. } IFFPACKMODE;
  118. #ifndef _MAC_
  119. #define MYCPU 0
  120. #define INTELSWAP16(X)
  121. #define INTELSWAP32(X)
  122. #else
  123. #define MYCPU 1
  124. #define INTELSWAP16(X) { unsigned char c, *p=(unsigned char *)&X; c=p[0]; p[0]=p[1]; p[1]=c; }
  125. #define INTELSWAP32(X) { unsigned char c, *p=(unsigned char *)&X; c=p[0]; p[0]=p[3]; p[3]=c; c = p[1]; p[1] = p[2]; p[2] = c; }
  126. #endif
  127. enum CPUTYPE {
  128. INTEL = 0,
  129. MOTOROLA=1
  130. };
  131. #define MAXSIZE 8192
  132. #ifndef RWBUFFSIZE
  133. #define RWBUFFSIZE (8 * 4096)
  134. #endif