Blender  V3.3
targa.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #ifdef WIN32
9 # include <io.h>
10 #endif
11 
12 #include "BLI_fileops.h"
13 #include "BLI_utildefines.h"
14 
15 #include "MEM_guardedalloc.h"
16 
17 #include "imbuf.h"
18 
19 #include "IMB_imbuf.h"
20 #include "IMB_imbuf_types.h"
21 
22 #include "IMB_filetype.h"
23 
24 #include "IMB_colormanagement.h"
26 
27 /* this one is only def-ed once, strangely... related to GS? */
28 #define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
29 
30 /***/
31 
32 typedef struct TARGA {
33  unsigned char numid;
34  unsigned char maptyp;
35  unsigned char imgtyp;
36  short maporig;
37  short mapsize;
38  unsigned char mapbits;
39  short xorig;
40  short yorig;
41  short xsize;
42  short ysize;
43  unsigned char pixsize;
44  unsigned char imgdes;
46 
53 #define TARGA_HEADER_SIZE 18
54 
55 /***/
56 
57 static int tga_out1(unsigned int data, FILE *file)
58 {
59  uchar *p;
60 
61  p = (uchar *)&data;
62  if (putc(p[0], file) == EOF) {
63  return EOF;
64  }
65  return ~EOF;
66 }
67 
68 static int tga_out2(unsigned int data, FILE *file)
69 {
70  uchar *p;
71 
72  p = (uchar *)&data;
73  if (putc(p[0], file) == EOF) {
74  return EOF;
75  }
76  if (putc(p[1], file) == EOF) {
77  return EOF;
78  }
79  return ~EOF;
80 }
81 
82 static int tga_out3(unsigned int data, FILE *file)
83 {
84  uchar *p;
85 
86  p = (uchar *)&data;
87  if (putc(p[2], file) == EOF) {
88  return EOF;
89  }
90  if (putc(p[1], file) == EOF) {
91  return EOF;
92  }
93  if (putc(p[0], file) == EOF) {
94  return EOF;
95  }
96  return ~EOF;
97 }
98 
99 static int tga_out4(unsigned int data, FILE *file)
100 {
101  uchar *p;
102 
103  p = (uchar *)&data;
104  /* Order = BGRA. */
105  if (putc(p[2], file) == EOF) {
106  return EOF;
107  }
108  if (putc(p[1], file) == EOF) {
109  return EOF;
110  }
111  if (putc(p[0], file) == EOF) {
112  return EOF;
113  }
114  if (putc(p[3], file) == EOF) {
115  return EOF;
116  }
117  return ~EOF;
118 }
119 
120 static bool makebody_tga(ImBuf *ibuf, FILE *file, int (*out)(unsigned int, FILE *))
121 {
122  int last, this;
123  int copy, bytes;
124  unsigned int *rect, *rectstart, *temp;
125  int y;
126 
127  for (y = 0; y < ibuf->y; y++) {
128  bytes = ibuf->x - 1;
129  rectstart = rect = ibuf->rect + (y * ibuf->x);
130  last = *rect++;
131  this = *rect++;
132  copy = last ^ this;
133  while (bytes > 0) {
134  if (copy) {
135  do {
136  last = this;
137  this = *rect++;
138  if (last == this) {
139  if (this == rect[-3]) { /* three the same? */
140  bytes--; /* set bytes */
141  break;
142  }
143  }
144  } while (--bytes != 0);
145 
146  copy = rect - rectstart;
147  copy--;
148  if (bytes) {
149  copy -= 2;
150  }
151 
152  temp = rect;
153  rect = rectstart;
154 
155  while (copy) {
156  last = copy;
157  if (copy >= 128) {
158  last = 128;
159  }
160  copy -= last;
161  if (fputc(last - 1, file) == EOF) {
162  return 0;
163  }
164  do {
165  if (out(*rect++, file) == EOF) {
166  return 0;
167  }
168  } while (--last != 0);
169  }
170  rectstart = rect;
171  rect = temp;
172  last = this;
173 
174  copy = 0;
175  }
176  else {
177  while (*rect++ == this) { /* seek for first different byte */
178  if (--bytes == 0) {
179  break; /* Or end of line. */
180  }
181  }
182  rect--;
183  copy = rect - rectstart;
184  rectstart = rect;
185  bytes--;
186  this = *rect++;
187 
188  while (copy) {
189  if (copy > 128) {
190  if (fputc(255, file) == EOF) {
191  return 0;
192  }
193  copy -= 128;
194  }
195  else {
196  if (copy == 1) {
197  if (fputc(0, file) == EOF) {
198  return 0;
199  }
200  }
201  else if (fputc(127 + copy, file) == EOF) {
202  return 0;
203  }
204  copy = 0;
205  }
206  if (out(last, file) == EOF) {
207  return 0;
208  }
209  }
210  copy = 1;
211  }
212  }
213  }
214  return 1;
215 }
216 
217 static bool dumptarga(struct ImBuf *ibuf, FILE *file)
218 {
219  int size;
220  uchar *rect;
221 
222  if (ibuf == NULL) {
223  return 0;
224  }
225  if (ibuf->rect == NULL) {
226  return 0;
227  }
228 
229  size = ibuf->x * ibuf->y;
230  rect = (uchar *)ibuf->rect;
231 
232  if (ibuf->planes <= 8) {
233  while (size > 0) {
234  if (putc(*rect, file) == EOF) {
235  return 0;
236  }
237  size--;
238  rect += 4;
239  }
240  }
241  else if (ibuf->planes <= 16) {
242  while (size > 0) {
243  putc(rect[0], file);
244  if (putc(rect[1], file) == EOF) {
245  return 0;
246  }
247  size--;
248  rect += 4;
249  }
250  }
251  else if (ibuf->planes <= 24) {
252  while (size > 0) {
253  putc(rect[2], file);
254  putc(rect[1], file);
255  if (putc(rect[0], file) == EOF) {
256  return 0;
257  }
258  size--;
259  rect += 4;
260  }
261  }
262  else if (ibuf->planes <= 32) {
263  while (size > 0) {
264  putc(rect[2], file);
265  putc(rect[1], file);
266  putc(rect[0], file);
267  if (putc(rect[3], file) == EOF) {
268  return 0;
269  }
270  size--;
271  rect += 4;
272  }
273  }
274  else {
275  return 0;
276  }
277 
278  return 1;
279 }
280 
281 bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int UNUSED(flags))
282 {
283  char buf[TARGA_HEADER_SIZE] = {0};
284  FILE *fildes;
285  bool ok = false;
286 
287  buf[16] = (ibuf->planes + 0x7) & ~0x7;
288  if (ibuf->planes > 8) {
289  buf[2] = 10;
290  }
291  else {
292  buf[2] = 11;
293  }
294 
295  if (ibuf->foptions.flag & RAWTGA) {
296  buf[2] &= ~8;
297  }
298 
299  buf[8] = 0;
300  buf[9] = 0;
301  buf[10] = 0;
302  buf[11] = 0;
303 
304  buf[12] = ibuf->x & 0xff;
305  buf[13] = ibuf->x >> 8;
306  buf[14] = ibuf->y & 0xff;
307  buf[15] = ibuf->y >> 8;
308 
309  /* Don't forget to indicate that your 32 bit
310  * targa uses 8 bits for the alpha channel! */
311  if (ibuf->planes == 32) {
312  buf[17] |= 0x08;
313  }
314  fildes = BLI_fopen(filepath, "wb");
315  if (!fildes) {
316  return 0;
317  }
318 
319  if (fwrite(buf, 1, TARGA_HEADER_SIZE, fildes) != TARGA_HEADER_SIZE) {
320  fclose(fildes);
321  return 0;
322  }
323 
324  if (ibuf->foptions.flag & RAWTGA) {
325  ok = dumptarga(ibuf, fildes);
326  }
327  else {
328  switch ((ibuf->planes + 7) >> 3) {
329  case 1:
330  ok = makebody_tga(ibuf, fildes, tga_out1);
331  break;
332  case 2:
333  ok = makebody_tga(ibuf, fildes, tga_out2);
334  break;
335  case 3:
336  ok = makebody_tga(ibuf, fildes, tga_out3);
337  break;
338  case 4:
339  ok = makebody_tga(ibuf, fildes, tga_out4);
340  break;
341  }
342  }
343 
344  fclose(fildes);
345  return ok;
346 }
347 
348 static bool checktarga(TARGA *tga, const unsigned char *mem, const size_t size)
349 {
350  if (size < TARGA_HEADER_SIZE) {
351  return false;
352  }
353 
354  tga->numid = mem[0];
355  tga->maptyp = mem[1];
356  tga->imgtyp = mem[2];
357 
358  tga->maporig = GSS(mem + 3);
359  tga->mapsize = GSS(mem + 5);
360  tga->mapbits = mem[7];
361  tga->xorig = GSS(mem + 8);
362  tga->yorig = GSS(mem + 10);
363  tga->xsize = GSS(mem + 12);
364  tga->ysize = GSS(mem + 14);
365  tga->pixsize = mem[16];
366  tga->imgdes = mem[17];
367 
368  if (tga->maptyp > 1) {
369  return false;
370  }
371  switch (tga->imgtyp) {
372  case 1: /* raw cmap */
373  case 2: /* raw rgb */
374  case 3: /* raw b&w */
375  case 9: /* cmap */
376  case 10: /* rgb */
377  case 11: /* b&w */
378  break;
379  default:
380  return false;
381  }
382  if (tga->mapsize && tga->mapbits > 32) {
383  return false;
384  }
385  if (tga->xsize <= 0) {
386  return false;
387  }
388  if (tga->ysize <= 0) {
389  return false;
390  }
391  if (tga->pixsize > 32) {
392  return false;
393  }
394  if (tga->pixsize == 0) {
395  return false;
396  }
397  return true;
398 }
399 
400 bool imb_is_a_targa(const unsigned char *buf, size_t size)
401 {
402  TARGA tga;
403 
404  return checktarga(&tga, buf, size);
405 }
406 
407 static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect)
408 {
409  int size = (ibuf->x * ibuf->y) - (rect - ibuf->rect);
410  if (size) {
411  printf("decodetarga: incomplete file, %.1f%% missing\n",
412  100 * ((float)size / (ibuf->x * ibuf->y)));
413 
414  /* Not essential but makes displaying partially rendered TGA's less ugly. */
415  memset(rect, 0, size);
416  }
417  else {
418  /* shouldn't happen */
419  printf("decodetarga: incomplete file, all pixels written\n");
420  }
421 }
422 
423 static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize)
424 {
425  const unsigned char *mem_end = mem + mem_size;
426  int count, col, size;
427  unsigned int *rect;
428  uchar *cp = (uchar *)&col;
429 
430  if (ibuf == NULL) {
431  return;
432  }
433  if (ibuf->rect == NULL) {
434  return;
435  }
436 
437  size = ibuf->x * ibuf->y;
438  rect = ibuf->rect;
439 
440  /* set alpha */
441  cp[0] = 0xff;
442  cp[1] = cp[2] = 0;
443 
444  while (size > 0) {
445  count = *mem++;
446 
447  if (mem > mem_end) {
448  goto partial_load;
449  }
450 
451  if (count >= 128) {
452  // if (count == 128) printf("TARGA: 128 in file !\n");
453  count -= 127;
454 
455  if (psize & 2) {
456  if (psize & 1) {
457  /* Order = BGRA. */
458  cp[0] = mem[3];
459  cp[1] = mem[0];
460  cp[2] = mem[1];
461  cp[3] = mem[2];
462  // col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];
463  mem += 4;
464  }
465  else {
466  cp[1] = mem[0];
467  cp[2] = mem[1];
468  cp[3] = mem[2];
469  // col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];
470  mem += 3;
471  }
472  }
473  else {
474  if (psize & 1) {
475  cp[0] = mem[0];
476  cp[1] = mem[1];
477  mem += 2;
478  }
479  else {
480  col = *mem++;
481  }
482  }
483 
484  size -= count;
485  if (size >= 0) {
486  while (count > 0) {
487  *rect++ = col;
488  count--;
489  }
490  }
491  }
492  else {
493  count++;
494  size -= count;
495  if (size >= 0) {
496  while (count > 0) {
497  if (psize & 2) {
498  if (psize & 1) {
499  /* Order = BGRA. */
500  cp[0] = mem[3];
501  cp[1] = mem[0];
502  cp[2] = mem[1];
503  cp[3] = mem[2];
504  // col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];
505  mem += 4;
506  }
507  else {
508  cp[1] = mem[0];
509  cp[2] = mem[1];
510  cp[3] = mem[2];
511  // col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];
512  mem += 3;
513  }
514  }
515  else {
516  if (psize & 1) {
517  cp[0] = mem[0];
518  cp[1] = mem[1];
519  mem += 2;
520  }
521  else {
522  col = *mem++;
523  }
524  }
525  *rect++ = col;
526  count--;
527 
528  if (mem > mem_end) {
529  goto partial_load;
530  }
531  }
532 
533  if (mem > mem_end) {
534  goto partial_load;
535  }
536  }
537  }
538  }
539  if (size) {
540  printf("decodetarga: count would overwrite %d pixels\n", -size);
541  }
542  return;
543 
544 partial_load:
545  complete_partial_load(ibuf, rect);
546 }
547 
548 static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize)
549 {
550  const unsigned char *mem_end = mem + mem_size;
551  int col, size;
552  unsigned int *rect;
553  uchar *cp = (uchar *)&col;
554 
555  if (ibuf == NULL) {
556  return;
557  }
558  if (ibuf->rect == NULL) {
559  return;
560  }
561 
562  size = ibuf->x * ibuf->y;
563  rect = ibuf->rect;
564 
565  /* set alpha */
566  cp[0] = 0xff;
567  cp[1] = cp[2] = 0;
568 
569  while (size > 0) {
570  if (mem > mem_end) {
571  goto partial_load;
572  }
573 
574  if (psize & 2) {
575  if (psize & 1) {
576  /* Order = BGRA. */
577  cp[0] = mem[3];
578  cp[1] = mem[0];
579  cp[2] = mem[1];
580  cp[3] = mem[2];
581  // col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];
582  mem += 4;
583  }
584  else {
585  /* set alpha for 24 bits colors */
586  cp[1] = mem[0];
587  cp[2] = mem[1];
588  cp[3] = mem[2];
589  // col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];
590  mem += 3;
591  }
592  }
593  else {
594  if (psize & 1) {
595  cp[0] = mem[0];
596  cp[1] = mem[1];
597  mem += 2;
598  }
599  else {
600  col = *mem++;
601  }
602  }
603  *rect++ = col;
604  size--;
605  }
606  return;
607 
608 partial_load:
609  complete_partial_load(ibuf, rect);
610 }
611 
612 ImBuf *imb_loadtarga(const unsigned char *mem,
613  size_t mem_size,
614  int flags,
615  char colorspace[IM_MAX_SPACE])
616 {
617  TARGA tga;
618  struct ImBuf *ibuf;
619  int count, size;
620  unsigned int *rect, *cmap = NULL /*, mincol = 0*/, cmap_max = 0;
621  int32_t cp_data;
622  uchar *cp = (uchar *)&cp_data;
623 
624  if (checktarga(&tga, mem, mem_size) == 0) {
625  return NULL;
626  }
627 
629 
630  if (flags & IB_test) {
631  ibuf = IMB_allocImBuf(tga.xsize, tga.ysize, tga.pixsize, 0);
632  }
633  else {
634  ibuf = IMB_allocImBuf(tga.xsize, tga.ysize, (tga.pixsize + 0x7) & ~0x7, IB_rect);
635  }
636 
637  if (ibuf == NULL) {
638  return NULL;
639  }
640  ibuf->ftype = IMB_FTYPE_TGA;
641  if (tga.imgtyp < 4) {
642  ibuf->foptions.flag |= RAWTGA;
643  }
644  mem = mem + TARGA_HEADER_SIZE + tga.numid;
645 
646  cp[0] = 0xff;
647  cp[1] = cp[2] = 0;
648 
649  if (tga.mapsize) {
650  /* Load color map. */
651  // mincol = tga.maporig; /* UNUSED */
652  cmap_max = tga.mapsize;
653  cmap = MEM_callocN(sizeof(unsigned int) * cmap_max, "targa cmap");
654 
655  for (count = 0; count < cmap_max; count++) {
656  switch (tga.mapbits >> 3) {
657  case 4:
658  cp[0] = mem[3];
659  cp[1] = mem[0];
660  cp[2] = mem[1];
661  cp[3] = mem[2];
662  mem += 4;
663  break;
664  case 3:
665  cp[1] = mem[0];
666  cp[2] = mem[1];
667  cp[3] = mem[2];
668  mem += 3;
669  break;
670  case 2:
671  cp[1] = mem[1];
672  cp[0] = mem[0];
673  mem += 2;
674  break;
675  case 1:
676  cp_data = *mem++;
677  break;
678  }
679  cmap[count] = cp_data;
680  }
681 
682  size = 0;
683  for (int cmap_index = cmap_max - 1; cmap_index > 0; cmap_index >>= 1) {
684  size++;
685  }
686  ibuf->planes = size;
687 
688  if (tga.mapbits != 32) { /* Set alpha bits. */
689  cmap[0] &= BIG_LONG(0x00ffffffl);
690  }
691  }
692 
693  if (flags & IB_test) {
694  if (cmap) {
695  MEM_freeN(cmap);
696  }
697  return ibuf;
698  }
699 
700  if (!ELEM(tga.imgtyp, 1, 9)) { /* happens sometimes (ugh) */
701  if (cmap) {
702  MEM_freeN(cmap);
703  cmap = NULL;
704  }
705  }
706 
707  switch (tga.imgtyp) {
708  case 1:
709  case 2:
710  case 3:
711  if (tga.pixsize <= 8) {
712  ldtarga(ibuf, mem, mem_size, 0);
713  }
714  else if (tga.pixsize <= 16) {
715  ldtarga(ibuf, mem, mem_size, 1);
716  }
717  else if (tga.pixsize <= 24) {
718  ldtarga(ibuf, mem, mem_size, 2);
719  }
720  else if (tga.pixsize <= 32) {
721  ldtarga(ibuf, mem, mem_size, 3);
722  }
723  break;
724  case 9:
725  case 10:
726  case 11:
727  if (tga.pixsize <= 8) {
728  decodetarga(ibuf, mem, mem_size, 0);
729  }
730  else if (tga.pixsize <= 16) {
731  decodetarga(ibuf, mem, mem_size, 1);
732  }
733  else if (tga.pixsize <= 24) {
734  decodetarga(ibuf, mem, mem_size, 2);
735  }
736  else if (tga.pixsize <= 32) {
737  decodetarga(ibuf, mem, mem_size, 3);
738  }
739  break;
740  }
741 
742  if (cmap) {
743  /* apply color map */
744  rect = ibuf->rect;
745  for (size = ibuf->x * ibuf->y; size > 0; size--, rect++) {
746  int cmap_index = *rect;
747  if (cmap_index >= 0 && cmap_index < cmap_max) {
748  *rect = cmap[cmap_index];
749  }
750  }
751 
752  MEM_freeN(cmap);
753  }
754 
755  if (tga.pixsize == 16) {
756  unsigned int col;
757  rect = ibuf->rect;
758  for (size = ibuf->x * ibuf->y; size > 0; size--, rect++) {
759  col = *rect;
760  cp = (uchar *)rect;
761  mem = (uchar *)&col;
762 
763  cp[3] = ((mem[1] << 1) & 0xf8);
764  cp[2] = ((mem[0] & 0xe0) >> 2) + ((mem[1] & 0x03) << 6);
765  cp[1] = ((mem[0] << 3) & 0xf8);
766  cp[1] += cp[1] >> 5;
767  cp[2] += cp[2] >> 5;
768  cp[3] += cp[3] >> 5;
769  cp[0] = 0xff;
770  }
771  ibuf->planes = 24;
772  }
773 
774  if (ELEM(tga.imgtyp, 3, 11)) {
775  uchar *crect;
776  unsigned int *lrect, col;
777 
778  crect = (uchar *)ibuf->rect;
779  lrect = (unsigned int *)ibuf->rect;
780 
781  for (size = ibuf->x * ibuf->y; size > 0; size--) {
782  col = *lrect++;
783 
784  crect[0] = 255;
785  crect[1] = crect[2] = crect[3] = col;
786  crect += 4;
787  }
788  }
789 
790  if (tga.imgdes & 0x20) {
791  IMB_flipy(ibuf);
792  }
793 
794  if (ibuf->rect) {
796  }
797 
798  return ibuf;
799 }
File and directory operations.
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:906
unsigned char uchar
Definition: BLI_sys_types.h:70
#define UNUSED(x)
#define ELEM(...)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
@ COLOR_ROLE_DEFAULT_BYTE
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:500
#define IM_MAX_SPACE
Definition: IMB_imbuf.h:49
void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
Definition: imageprocess.c:26
void IMB_flipy(struct ImBuf *ibuf)
Definition: rotate.c:16
Contains defines and structs used throughout the imbuf module.
#define RAWTGA
@ IB_test
@ IB_rect
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
void colorspace_set_default_role(char *colorspace, int size, int role)
FILE * file
uint col
@ IMB_FTYPE_TGA
#define BIG_LONG
Definition: imbuf.h:43
int count
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
signed int int32_t
Definition: stdint.h:77
ImbFormatOptions foptions
unsigned char planes
enum eImbFileType ftype
unsigned int * rect
Definition: targa.c:32
short mapsize
Definition: targa.c:37
unsigned char numid
Definition: targa.c:33
short xorig
Definition: targa.c:39
short yorig
Definition: targa.c:40
unsigned char maptyp
Definition: targa.c:34
unsigned char imgdes
Definition: targa.c:44
short xsize
Definition: targa.c:41
short maporig
Definition: targa.c:36
short ysize
Definition: targa.c:42
unsigned char pixsize
Definition: targa.c:43
unsigned char imgtyp
Definition: targa.c:35
unsigned char mapbits
Definition: targa.c:38
static int tga_out2(unsigned int data, FILE *file)
Definition: targa.c:68
static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize)
Definition: targa.c:423
static int tga_out3(unsigned int data, FILE *file)
Definition: targa.c:82
static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize)
Definition: targa.c:548
struct TARGA TARGA
static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect)
Definition: targa.c:407
static bool makebody_tga(ImBuf *ibuf, FILE *file, int(*out)(unsigned int, FILE *))
Definition: targa.c:120
static bool dumptarga(struct ImBuf *ibuf, FILE *file)
Definition: targa.c:217
static int tga_out1(unsigned int data, FILE *file)
Definition: targa.c:57
#define GSS(x)
Definition: targa.c:28
bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int UNUSED(flags))
Definition: targa.c:281
static int tga_out4(unsigned int data, FILE *file)
Definition: targa.c:99
#define TARGA_HEADER_SIZE
Definition: targa.c:53
bool imb_is_a_targa(const unsigned char *buf, size_t size)
Definition: targa.c:400
ImBuf * imb_loadtarga(const unsigned char *mem, size_t mem_size, int flags, char colorspace[IM_MAX_SPACE])
Definition: targa.c:612
static bool checktarga(TARGA *tga, const unsigned char *mem, const size_t size)
Definition: targa.c:348