TARGA.H 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef VQMTARGA_H
  19. #define VQMTARGA_H
  20. /****************************************************************************
  21. *
  22. * C O N F I D E N T I A L --- W E S T W O O D S T U D I O S
  23. *
  24. *----------------------------------------------------------------------------
  25. *
  26. * FILE
  27. * Targa.h (32-Bit protected mode)
  28. *
  29. * DESCRIPTION
  30. * Targa Image File definitions.
  31. *
  32. * PROGRAMMER
  33. * Denzil E. Long, Jr.
  34. *
  35. * DATE
  36. * January 26, 1995
  37. *
  38. ****************************************************************************/
  39. /*---------------------------------------------------------------------------
  40. * Targa Header definitions
  41. *-------------------------------------------------------------------------*/
  42. /* TGAHeader - Targa Image File header.
  43. *
  44. * IDLength - Size of Image ID field
  45. * ColorMapType - Color map type.
  46. * ImageType - Image type code.
  47. * CMapStart - Color map origin.
  48. * CMapLength - Color map length.
  49. * CMapDepth - Depth of color map entries.
  50. * XOffset - X origin of image.
  51. * YOffset - Y origin of image.
  52. * Width - Width of image.
  53. * Height - Height of image.
  54. * PixelDepth - Image pixel size
  55. * ImageDescriptor - Image descriptor byte.
  56. */
  57. typedef struct _TGAHeader {
  58. char IDLength;
  59. char ColorMapType;
  60. char ImageType;
  61. short CMapStart;
  62. short CMapLength;
  63. char CMapDepth;
  64. short XOffset;
  65. short YOffset;
  66. short Width;
  67. short Height;
  68. char PixelDepth;
  69. char ImageDescriptor;
  70. } TGAHeader;
  71. /* ImageType definiton */
  72. #define TGA_NOIMAGE 0 /* No image data included in file */
  73. #define TGA_CMAPPED 1 /* Color-mapped image data */
  74. #define TGA_TRUECOLOR 2 /* Truecolor image data */
  75. #define TGA_MONO 3 /* Monochrome image data */
  76. #define TGA_CMAPPED_ENCODED 9 /* Color-mapped image data (Encoded) */
  77. #define TGA_TRUECOLOR_ENCODED 10 /* Truecolor image data (Encoded) */
  78. #define TGA_MONO_ENCODED 11 /* Monochrome image data (Encoded) */
  79. /* ImageDescriptor definition */
  80. #define TGAF_ATTRIB_BITS (0x0F<<0) /* Number of attribute bits per pixel */
  81. #define TGAF_XORIGIN (1<<4)
  82. #define TGAF_YORIGIN (1<<5)
  83. /*---------------------------------------------------------------------------
  84. * Targa Handle definitions
  85. *-------------------------------------------------------------------------*/
  86. /* TGAHandle - Targa Image File handle.
  87. *
  88. * fh - File handle returned by open().
  89. * mode - Access mode.
  90. * header - TGAHeader structure.
  91. */
  92. typedef struct _TGAHandle {
  93. short fh;
  94. unsigned short mode;
  95. TGAHeader header;
  96. } TGAHandle;
  97. /* Access modes. */
  98. #define TGA_READMODE 0
  99. #define TGA_WRITEMODE 1
  100. #define TGA_RDWRMODE 2
  101. /* Error codes */
  102. #define TGAERR_OPEN -1
  103. #define TGAERR_READ -2
  104. #define TGAERR_WRITE -3
  105. #define TGAERR_SYNTAX -4
  106. #define TGAERR_NOMEM -5
  107. #define TGAERR_NOTSUPPORTED -6
  108. /*---------------------------------------------------------------------------
  109. * Function prototypes
  110. *-------------------------------------------------------------------------*/
  111. TGAHandle *OpenTarga(char *, unsigned short);
  112. void CloseTarga(TGAHandle *);
  113. long LoadTarga(char *, char *, char *);
  114. long SaveTarga(char *, TGAHeader *, char *, char *);
  115. void XFlipTarga(TGAHeader *, char *);
  116. void YFlipTarga(TGAHeader *, char *);
  117. #endif /* VQMTARGA_H */