il_targa.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //-----------------------------------------------------------------------------
  2. //
  3. // ImageLib Sources
  4. // Copyright (C) 2000-2002 by Denton Woods
  5. // Last modified: 05/25/2001 <--Y2K Compliant! =]
  6. //
  7. // Filename: src-IL/include/il_targa.h
  8. //
  9. // Description: Targa (.tga) functions
  10. //
  11. //-----------------------------------------------------------------------------
  12. #ifndef TARGA_H
  13. #define TARGA_H
  14. #include "il_internal.h"
  15. #ifdef _MSC_VER
  16. #pragma pack(push, tga_struct, 1)
  17. #elif defined(MACOSX) || defined(__GNUC__)
  18. #pragma pack(1)
  19. #endif
  20. typedef struct TARGAHEAD
  21. {
  22. ILubyte IDLen;
  23. ILubyte ColMapPresent;
  24. ILubyte ImageType;
  25. ILshort FirstEntry;
  26. ILshort ColMapLen;
  27. ILubyte ColMapEntSize;
  28. ILshort OriginX;
  29. ILshort OriginY;
  30. ILushort Width;
  31. ILushort Height;
  32. ILubyte Bpp;
  33. ILubyte ImageDesc;
  34. } IL_PACKSTRUCT TARGAHEAD;
  35. typedef struct TARGAFOOTER
  36. {
  37. ILuint ExtOff; // Extension Area Offset
  38. ILuint DevDirOff; // Developer Directory Offset
  39. ILbyte Signature[16]; // TRUEVISION-XFILE
  40. ILbyte Reserved; // ASCII period '.'
  41. ILbyte NullChar; // NULL
  42. } IL_PACKSTRUCT TARGAFOOTER;
  43. #if defined(MACOSX) || defined(__GNUC__)
  44. #pragma pack()
  45. #elif _MSC_VER
  46. #pragma pack(pop, tga_struct)
  47. #endif
  48. #define TGA_EXT_LEN 495
  49. typedef struct TARGAEXT
  50. {
  51. // Dev Directory
  52. // We don't mess with this
  53. // Extension Area
  54. ILshort Size; // should be TGA_EXT_LEN
  55. ILbyte AuthName[41]; // the image author's name
  56. ILbyte AuthComments[324]; // author's comments
  57. ILshort Month, Day, Year, Hour, Minute, Second; // internal date of file
  58. ILbyte JobID[41]; // the job description (if any)
  59. ILshort JobHour, JobMin, JobSecs; // the job's time
  60. ILbyte SoftwareID[41]; // the software that created this
  61. ILshort SoftwareVer; // the software version number * 100
  62. ILbyte SoftwareVerByte; // the software version letter
  63. ILint KeyColor; // the transparent colour
  64. } TARGAEXT;
  65. // Different Targa formats
  66. #define TGA_NO_DATA 0
  67. #define TGA_COLMAP_UNCOMP 1
  68. #define TGA_UNMAP_UNCOMP 2
  69. #define TGA_BW_UNCOMP 3
  70. #define TGA_COLMAP_COMP 9
  71. #define TGA_UNMAP_COMP 10
  72. #define TGA_BW_COMP 11
  73. // Targa origins
  74. #define IMAGEDESC_ORIGIN_MASK 0x30
  75. #define IMAGEDESC_TOPLEFT 0x20
  76. #define IMAGEDESC_BOTLEFT 0x00
  77. #define IMAGEDESC_BOTRIGHT 0x10
  78. #define IMAGEDESC_TOPRIGHT 0x30
  79. // Internal functions
  80. ILboolean iIsValidTarga();
  81. ILboolean iGetTgaHead(TARGAHEAD *Header);
  82. ILboolean iCheckTarga(TARGAHEAD *Header);
  83. ILboolean iLoadTargaInternal(void);
  84. ILboolean iSaveTargaInternal(void);
  85. //ILvoid iMakeString(char *Str);
  86. ILboolean iReadBwTga(TARGAHEAD *Header);
  87. ILboolean iReadColMapTga(TARGAHEAD *Header);
  88. ILboolean iReadUnmapTga(TARGAHEAD *Header);
  89. ILboolean iUncompressTgaData(ILimage *Image);
  90. ILboolean i16BitTarga(ILimage *Image);
  91. void iGetDateTime(ILuint *Month, ILuint *Day, ILuint *Yr, ILuint *Hr, ILuint *Min, ILuint *Sec);
  92. #endif//TARGA_H