Lines Matching refs:tga
65 oTga *tga = NULL; in gdImageCreateFromTgaCtx() local
72 tga = (oTga *) gdMalloc(sizeof(oTga)); in gdImageCreateFromTgaCtx()
73 if (!tga) { in gdImageCreateFromTgaCtx()
77 tga->bitmap = NULL; in gdImageCreateFromTgaCtx()
78 tga->ident = NULL; in gdImageCreateFromTgaCtx()
80 if (read_header_tga(ctx, tga) < 0) { in gdImageCreateFromTgaCtx()
81 free_tga(tga); in gdImageCreateFromTgaCtx()
90 if (read_image_tga(ctx, tga) < 0) { in gdImageCreateFromTgaCtx()
91 free_tga(tga); in gdImageCreateFromTgaCtx()
95 image = gdImageCreateTrueColor((int)tga->width, (int)tga->height ); in gdImageCreateFromTgaCtx()
98 free_tga( tga ); in gdImageCreateFromTgaCtx()
106 if (tga->alphabits) { in gdImageCreateFromTgaCtx()
112 for (y = 0; y < tga->height; y++) { in gdImageCreateFromTgaCtx()
114 for ( x = 0; x < tga->width; x++, tpix++) { in gdImageCreateFromTgaCtx()
115 if (tga->bits == TGA_BPP_24) { in gdImageCreateFromTgaCtx()
116 …*tpix = gdTrueColor(tga->bitmap[bitmap_caret + 2], tga->bitmap[bitmap_caret + 1], tga->bitmap[bitm… in gdImageCreateFromTgaCtx()
118 } else if (tga->bits == TGA_BPP_32 && tga->alphabits) { in gdImageCreateFromTgaCtx()
119 register int a = tga->bitmap[bitmap_caret + 3]; in gdImageCreateFromTgaCtx()
121 …*tpix = gdTrueColorAlpha(tga->bitmap[bitmap_caret + 2], tga->bitmap[bitmap_caret + 1], tga->bitmap… in gdImageCreateFromTgaCtx()
127 if (tga->flipv && tga->fliph) { in gdImageCreateFromTgaCtx()
129 } else if (tga->flipv) { in gdImageCreateFromTgaCtx()
131 } else if (tga->fliph) { in gdImageCreateFromTgaCtx()
135 free_tga(tga); in gdImageCreateFromTgaCtx()
146 int read_header_tga(gdIOCtx *ctx, oTga *tga) in read_header_tga() argument
156 tga->identsize = header[0]; in read_header_tga()
157 tga->colormaptype = header[1]; in read_header_tga()
158 tga->imagetype = header[2]; in read_header_tga()
159 tga->colormapstart = header[3] + (header[4] << 8); in read_header_tga()
160 tga->colormaplength = header[5] + (header[6] << 8); in read_header_tga()
161 tga->colormapbits = header[7]; in read_header_tga()
162 tga->xstart = header[8] + (header[9] << 8); in read_header_tga()
163 tga->ystart = header[10] + (header[11] << 8); in read_header_tga()
164 tga->width = header[12] + (header[13] << 8); in read_header_tga()
165 tga->height = header[14] + (header[15] << 8); in read_header_tga()
166 tga->bits = header[16]; in read_header_tga()
167 tga->alphabits = header[17] & 0x0f; in read_header_tga()
168 tga->fliph = (header[17] & 0x10) ? 1 : 0; in read_header_tga()
169 tga->flipv = (header[17] & 0x20) ? 0 : 1; in read_header_tga()
172 printf("format bps: %i\n", tga->bits); in read_header_tga()
173 printf("flip h/v: %i / %i\n", tga->fliph, tga->flipv); in read_header_tga()
174 printf("alpha: %i\n", tga->alphabits); in read_header_tga()
175 printf("wxh: %i %i\n", tga->width, tga->height); in read_header_tga()
178 if (!((tga->bits == TGA_BPP_24 && tga->alphabits == 0) in read_header_tga()
179 || (tga->bits == TGA_BPP_32 && tga->alphabits == 8))) in read_header_tga()
182 tga->bits, tga->alphabits); in read_header_tga()
186 tga->ident = NULL; in read_header_tga()
188 if (tga->identsize > 0) { in read_header_tga()
189 tga->ident = (char *) gdMalloc(tga->identsize * sizeof(char)); in read_header_tga()
190 if(tga->ident == NULL) { in read_header_tga()
194 gdGetBuf(tga->ident, tga->identsize, ctx); in read_header_tga()
206 int read_image_tga( gdIOCtx *ctx, oTga *tga ) in read_image_tga() argument
208 int pixel_block_size = (tga->bits / 8); in read_image_tga()
218 if(overflow2(tga->width, tga->height)) { in read_image_tga()
222 if(overflow2(tga->width * tga->height, pixel_block_size)) { in read_image_tga()
226 image_block_size = (tga->width * tga->height) * pixel_block_size; in read_image_tga()
233 if (tga->imagetype != TGA_TYPE_RGB && tga->imagetype != TGA_TYPE_RGB_RLE) in read_image_tga()
239 tga->bitmap = (int *) gdMalloc(image_block_size * sizeof(int)); in read_image_tga()
240 if (tga->bitmap == NULL) in read_image_tga()
243 switch (tga->imagetype) { in read_image_tga()
260 tga->bitmap[buffer_caret] = (int) conversion_buffer[buffer_caret]; in read_image_tga()
318 …memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, pixel_block_size * sizeof(… in read_image_tga()
334 …memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, encoded_pixels * pixel_blo… in read_image_tga()
351 void free_tga(oTga * tga) in free_tga() argument
353 if (tga) { in free_tga()
354 if (tga->ident) in free_tga()
355 gdFree(tga->ident); in free_tga()
356 if (tga->bitmap) in free_tga()
357 gdFree(tga->bitmap); in free_tga()
358 gdFree(tga); in free_tga()