//See http://www.paulbourke.net/dataformats/tga/ for TGA specification #include #include #include #include const int IMAGE_TYPE_RGB= 2; typedef unsigned char uchar; //Unmapped RGB(A) typedef struct { uchar idLength; // Number of Characters in Identification Field = the size of TGA header, 0 by default uchar colorMapType; // Color Map Type. 0 means no color map is included uchar imageType; // IMAGE_TYPE_RGB uchar colorMapSpec[5]; // ignored in case of Unmapped RGB image uint16_t xOrigin; // Image X origin - Integer ( lo-hi ) Y coordinate of the lower left corner of the image uint16_t yOrigin; // Image Y origin - Integer ( lo-hi ) Y coordinate of the lower left corner of the image uint16_t width; // Image width uint16_t height; // Image height uchar BPP; // Bits Per Pixel uchar imageDescriptor; // Image descriptor } TGAHeader; typedef struct { TGAHeader header; uchar* data; } TGAImage; // size_t getNumberOfBytes(const TGAHeader& header) // { // } // void tgaSetHeader(TGAHeader& header, const uint16_t width, const uint16_t height) // { // } // void tgaAllocateData(uchar*& data, const TGAHeader& header) // { // } // TGAImage* tgaCreate(const uint16_t width, const uint16_t height ) // { // } // void tgaFree(TGAImage* img) // { // } // void tgaZeros(TGAImage* img) // { // } // void tgaDrawWhiteRect(TGAImage* img, const int start_x, const int start_y, const int end_x, const int end_y ) // { // } // void tgaSave(const TGAImage* img, const char * filename ) // { // } int main() { const uint16_t width = 640; const uint16_t height = 480; // TGAImage* img = tgaCreate(width, height); // tgaZeros(img); // tgaDrawWhiteRect(img, 0, 0, 320, 240); // tgaSave(img, "img.tga"); // tgaFree(img); return 0; }