added capability to open 15, 16, 24, and 32-bit "true color" TGA images and 8-bit color mapped TGA images

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1051 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber 2002-09-16 03:33:15 +00:00
parent 794887f87f
commit 343a35cc2d

View File

@ -40,7 +40,7 @@
#define TGA_TRANSLATOR_VERSION 100 #define TGA_TRANSLATOR_VERSION 100
#define TGA_IN_QUALITY 1.0 #define TGA_IN_QUALITY 1.0
// high in quality becuase this code supports all TGA features // high in quality becuase this code supports all TGA features
#define TGA_IN_CAPABILITY 0.8 #define TGA_IN_CAPABILITY 0.6
// high in capability because this code opens basically all TGAs // high in capability because this code opens basically all TGAs
#define TGA_OUT_QUALITY 1.0 #define TGA_OUT_QUALITY 1.0
// high out quality because this code outputs fully standard TGAs // high out quality because this code outputs fully standard TGAs
@ -58,11 +58,11 @@
// TGA files are stored in the Intel byte order :) // TGA files are stored in the Intel byte order :)
struct TGAFileHeader { struct TGAFileHeader {
uint8 idlength; // Number of bytes in the Image ID field uint8 idlength;
// Number of bytes in the Image ID field
uint8 colormaptype; uint8 colormaptype;
// 0 Has NO color-map (palette) // 0 Has NO color-map (palette)
// 1 Has color-map (palette) // 1 Has color-map (palette)
uint8 imagetype; uint8 imagetype;
// 0 No Image Data Included // 0 No Image Data Included
// 1 Uncompressed, Color-mapped image // 1 Uncompressed, Color-mapped image
@ -81,27 +81,25 @@ struct TGAFileHeader {
#define TGA_NOCOMP_COLORMAP 1 #define TGA_NOCOMP_COLORMAP 1
#define TGA_NOCOMP_TRUECOLOR 2 #define TGA_NOCOMP_TRUECOLOR 2
#define TGA_NOCOMP_BW 3 #define TGA_NOCOMP_BW 3
#define TGA_RLE_COLORMAP 9 #define TGA_RLE_COLORMAP 9
#define TGA_RLE_TRUECOLOR 10 #define TGA_RLE_TRUECOLOR 10
#define TGA_RLE_BW 11 #define TGA_RLE_BW 11
// Information about the color map (palette) // Information about the color map (palette). These bytes are
// these bytes are always present, but are zero if no color map // always present, but are zero if no color map is present
// is present
struct TGAColorMapSpec { struct TGAColorMapSpec {
uint16 firstentry; // first useful entry in the color map uint16 firstentry; // first useful entry in the color map
uint16 length; // number of color map entries uint16 length; // number of color map entries
uint8 entrysize; // number of bits per entry uint8 entrysize; // number of bits per entry
}; };
// Information about the image data
struct TGAImageSpec { struct TGAImageSpec {
uint16 xorigin; uint16 xorigin;
uint16 yorigin; uint16 yorigin;
uint16 width; uint16 width;
uint16 height; uint16 height;
uint8 depth; // pixel depth includes alpha! uint8 depth;
// pixel depth includes alpha bits!
uint8 descriptor; uint8 descriptor;
// bits 3-0: number of attribute bits per pixel // bits 3-0: number of attribute bits per pixel
// bits 5&4: order pixels are drawn to the screen // bits 5&4: order pixels are drawn to the screen
@ -123,6 +121,9 @@ struct TGAImageSpec {
#define TGA_ORIGIN_LEFT 0 #define TGA_ORIGIN_LEFT 0
#define TGA_ORIGIN_RIGHT 1 #define TGA_ORIGIN_RIGHT 1
#define TGA_DESC_BITS76 0xc0
#define TGA_DESC_ALPHABITS 0x0f
#define TGA_HEADERS_SIZE 18 #define TGA_HEADERS_SIZE 18
class TGATranslator : public BTranslator { class TGATranslator : public BTranslator {