Go to the documentation of this file.00001
00006 #include <stdlib.h>
00007 #include <stdio.h>
00008
00009 #include "contrib/libtarga.h"
00010
00012 const int size = 256;
00013
00015
00016 int main(int argc, char *argv[])
00017 {
00018 unsigned char* targaimage;
00019 int j, k, wdt = size, hgt = size;
00020
00021 targaimage = (unsigned char*) tga_create(wdt, hgt, TGA_TRUECOLOR_32);
00022
00023 for(j = 0; j < wdt; j ++)
00024 for(k = 0; k < hgt; k ++)
00025 {
00026 targaimage[(j*wdt + k)*4] = j*wdt + k;
00027 targaimage[(j*wdt + k)*4 + 1] = j*wdt + k;
00028 targaimage[(j*wdt + k)*4 + 2] = j*wdt + k;
00029 targaimage[(j*wdt + k)*4 + 3] = 255;
00030 }
00031
00032 printf("Writing Image!\n");
00033 if (!tga_write_raw("output.tga", wdt, hgt, targaimage, TGA_TRUECOLOR_32))
00034 {
00035 printf("Failed to write image!\n");
00036 printf(tga_error_string(tga_get_last_error()));
00037 }
00038
00039 free(targaimage);
00040 return EXIT_SUCCESS;
00041 }