Targa.c
main() {
// Default Targa image header typedef struct { char idlength = 0; char colourmaptype = 0; char datatypecode = 0; short int colourmaporigin = 0; short int colourmaplength = 0; char colourmapdepth = 0; short int x_origin = 0; short int y_origin = 0; short width = 400; short height = 300; char bitsperpixel = 8; char imagedescriptor = ' '; } targaHeader; szHeader = sizeOf(targaHeader);
char* image = targa( 100, 200 ); fillRect( image, 10, 20, 30, 40, 0xff0000ff );
// Create a new targa image in memory char* targa(short int width, height) { targaHeader* image = malloc(szHeader+width*height*4); image->width = width; image->height = height; return (char*)ℑ }
void getPixel(char* image, short int x, y, int colour) { targaHeader* header = (targaHeader*)image; char* addr = image+szHeader+4*(x+header->width*y); return *addr; }
void setPixel(char* image, short int x, y, int colour) { }
void fillRect( char* image, short int x1,y1,x2,y2, int colour) { int x,y; for (y=y1; y<y2; y++) for (x=x1; x<x2; x++) setPixel(image,x,y,colour); } }



