| line |
true |
false |
branch |
|
126
|
2 |
0 |
if (attr_bit_count == 1) |
|
131
|
0 |
0 |
if (attr_bit_count == 8) |
|
174
|
400 |
400 |
val->rgba.a = (buf[1] & 0x80) ? 0 : 255; |
|
223
|
200 |
200 |
buf[1] |= val->rgba.a > 0x7f ? 0 : 0x80; |
|
264
|
86904 |
106495 |
while(i
|
|
265
|
29883 |
57021 |
if(memcmp(buf+i*bytepp, buf+(i+1)*bytepp, bytepp) == 0) { |
|
266
|
0 |
29883 |
if (i == length-2) return -1; |
|
267
|
25987 |
3896 |
if (memcmp(buf+(i+1)*bytepp, buf+(i+2)*bytepp,bytepp) == 0) |
|
294
|
438247 |
2422 |
while(i
|
|
295
|
23565 |
414682 |
if(memcmp(buf, buf+(i*bytepp), bytepp) != 0) return i; |
|
345
|
17 |
0 |
if (header.bitsperpixel != 8) |
|
351
|
24 |
0 |
if (header.bitsperpixel != 15 && header.bitsperpixel != 16 |
|
|
22 |
2 |
if (header.bitsperpixel != 15 && header.bitsperpixel != 16 |
|
352
|
7 |
15 |
&& header.bitsperpixel != 24 && header.bitsperpixel != 32) |
|
|
6 |
1 |
&& header.bitsperpixel != 24 && header.bitsperpixel != 32) |
|
362
|
0 |
0 |
if (header.datatypecode != 1 && header.datatypecode != 9) |
|
|
0 |
0 |
if (header.datatypecode != 1 && header.datatypecode != 9) |
|
368
|
0 |
18 |
switch (header.colourmapdepth) { |
|
435
|
900 |
107889 |
if (!s->compressed) { |
|
436
|
0 |
900 |
if (i_io_read(s->ig, buf, pixels*s->bytepp) != pixels*s->bytepp) return 0; |
|
440
|
263150 |
107889 |
while(cp < pixels) { |
|
442
|
131575 |
131575 |
if (s->len == 0) s->state = NoInit; |
|
445
|
0 |
131575 |
if (i_io_read(s->ig, &s->hdr, 1) != 1) return 0; |
|
448
|
21876 |
109699 |
s->state = (s->hdr & (1<<7)) ? Rle : Raw; |
|
455
|
21876 |
109699 |
if (s->state == Rle && i_io_read(s->ig, s->cval, s->bytepp) != s->bytepp) return 0; |
|
|
0 |
21876 |
if (s->state == Rle && i_io_read(s->ig, s->cval, s->bytepp) != s->bytepp) return 0; |
|
460
|
796713 |
295139 |
for(k=0; kbytepp; j++) |
|
|
295139 |
21876 |
for(k=0; kbytepp; j++) |
|
467
|
0 |
109699 |
if (i_io_read(s->ig, buf+cp*s->bytepp, ml*s->bytepp) != ml*s->bytepp) return 0; |
|
497
|
150 |
108917 |
if (!s->compressed) { |
|
498
|
0 |
150 |
if (i_io_write(s->ig, buf, pixels*s->bytepp) != pixels*s->bytepp) return 0; |
|
502
|
132482 |
2422 |
while(cp < pixels) { |
|
505
|
106495 |
25987 |
tlen = (nxtrip == -1) ? pixels-cp : nxtrip; |
|
506
|
113319 |
132482 |
while(tlen) { |
|
509
|
0 |
113319 |
if (i_io_write(s->ig, &clen, 1) != 1) return 0; |
|
511
|
0 |
113319 |
if (i_io_write(s->ig, buf+cp*s->bytepp, clen*s->bytepp) != clen*s->bytepp) return 0; |
|
515
|
106495 |
25987 |
if (cp >= pixels) break; |
|
517
|
0 |
25987 |
if (tlen <3) continue; |
|
518
|
26894 |
25987 |
while (tlen) { |
|
521
|
0 |
26894 |
if (i_io_write(s->ig, &clen, 1) != 1) return 0; |
|
523
|
0 |
26894 |
if (i_io_write(s->ig, buf+cp*s->bytepp, s->bytepp) != s->bytepp) return 0; |
|
561
|
1 |
3 |
if (i_io_read(ig, palbuf, palbsize) != palbsize) { |
|
568
|
230 |
3 |
for(i=0; i
|
|
570
|
230 |
0 |
i_addcolors(img, &val, 1); |
|
595
|
7 |
0 |
size_t palbsize = i_colorcount(img)*bytepp; |
|
598
|
1094 |
7 |
for(i=0; i
|
|
600
|
1094 |
0 |
i_getcolors(img, i, &val, 1); |
|
604
|
0 |
7 |
if (i_io_write(ig, palbuf, palbsize) != palbsize) { |
|
645
|
0 |
26 |
if (i_io_read(ig, &headbuf, 18) != 18) { |
|
665
|
3 |
23 |
if (header.idlength) { |
|
668
|
0 |
3 |
if (i_io_read(ig, idstring, header.idlength) != header.idlength) { |
|
683
|
0 |
0 |
if (idstring) myfree(idstring); |
|
690
|
0 |
4 |
if (header.bitsperpixel != 8) { |
|
692
|
0 |
0 |
if (idstring) myfree(idstring); |
|
699
|
22 |
0 |
if ((src.bytepp = bpp_to_bytes(header.bitsperpixel))) |
|
702
|
0 |
0 |
if (idstring) myfree(idstring); |
|
708
|
0 |
0 |
if (idstring) myfree(idstring); |
|
713
|
0 |
0 |
if (idstring) myfree(idstring); |
|
732
|
4 |
22 |
if ((channels = bpp_to_channels(mapped ? |
|
|
26 |
0 |
if ((channels = bpp_to_channels(mapped ? |
|
737
|
0 |
0 |
if (idstring) myfree(idstring); |
|
750
|
3 |
23 |
if (!i_int_check_image_file_limits(width, height, channels, |
|
757
|
4 |
19 |
i_img_pal_new(width, height, channels, 256) : |
|
760
|
0 |
23 |
if (!img) { |
|
761
|
0 |
0 |
if (idstring) |
|
766
|
3 |
20 |
if (idstring) { |
|
778
|
1 |
0 |
if (img) i_img_destroy(img); |
|
786
|
19 |
3 |
if (!mapped) linebuf = mymalloc(width*sizeof(i_color)); |
|
788
|
108789 |
22 |
for(y=0; y
|
|
789
|
0 |
108789 |
if (!tga_source_read(&src, databuf, width)) { |
|
791
|
0 |
0 |
if (linebuf) myfree(linebuf); |
|
793
|
0 |
0 |
if (img) i_img_destroy(img); |
|
796
|
450 |
108339 |
if (mapped && header.colourmaporigin) for(x=0; x
|
|
|
0 |
450 |
if (mapped && header.colourmaporigin) for(x=0; x
|
|
|
0 |
0 |
if (mapped && header.colourmaporigin) for(x=0; x
|
|
797
|
450 |
108339 |
if (mapped) i_ppal(img, 0, width, header.imagedescriptor & (1<<5) ? y : height-1-y, databuf); |
|
|
450 |
0 |
if (mapped) i_ppal(img, 0, width, header.imagedescriptor & (1<<5) ? y : height-1-y, databuf); |
|
|
0 |
450 |
if (mapped) i_ppal(img, 0, width, header.imagedescriptor & (1<<5) ? y : height-1-y, databuf); |
|
799
|
483794 |
108339 |
for(x=0; x
|
|
800
|
0 |
108339 |
i_plin(img, 0, width, header.imagedescriptor & (1<<5) ? y : height-1-y, linebuf); |
|
804
|
19 |
3 |
if (linebuf) myfree(linebuf); |
|
807
|
3 |
19 |
i_tags_addn(&img->tags, "tga_bitspp", 0, mapped?header.colourmapdepth:header.bitsperpixel); |
|
808
|
16 |
6 |
if (src.compressed) i_tags_addn(&img->tags, "compressed", 0, 1); |
|
853
|
25 |
1 |
if (img->xsize > TGA_MAX_DIM || img->ysize > TGA_MAX_DIM) { |
|
|
1 |
24 |
if (img->xsize > TGA_MAX_DIM || img->ysize > TGA_MAX_DIM) { |
|
861
|
0 |
0 |
if (wierdpack) { |
|
871
|
4 |
18 |
bitspp = wierdpack ? 15 : 24; |
|
874
|
1 |
0 |
bitspp = wierdpack ? 16 : 32; |
|
875
|
1 |
0 |
attr_bits = wierdpack ? 1 : 8; |
|
884
|
16 |
7 |
header.datatypecode = mapped ? 1 : img->channels == 1 ? 3 : 2; |
|
|
0 |
16 |
header.datatypecode = mapped ? 1 : img->channels == 1 ? 3 : 2; |
|
885
|
20 |
3 |
header.datatypecode += compress ? 8 : 0; |
|
888
|
7 |
16 |
header.colourmaplength = mapped ? i_colorcount(img) : 0; |
|
|
7 |
0 |
header.colourmaplength = mapped ? i_colorcount(img) : 0; |
|
889
|
7 |
16 |
header.colourmapdepth = mapped ? bitspp : 0; |
|
894
|
16 |
7 |
header.bitsperpixel = mapped ? 8 : bitspp; |
|
899
|
0 |
23 |
if (i_io_write(ig, &headbuf, sizeof(headbuf)) != sizeof(headbuf)) { |
|
904
|
2 |
21 |
if (idlen) { |
|
905
|
0 |
2 |
if (i_io_write(ig, idstring, idlen) != idlen) { |
|
913
|
16 |
7 |
dest.bytepp = mapped ? 1 : bpp_to_bytes(bitspp); |
|
919
|
7 |
16 |
if (img->type == i_palette_type) { |
|
920
|
7 |
0 |
if (!tga_palette_write(ig, img, bitspp, i_colorcount(img))) return 0; |
|
|
0 |
7 |
if (!tga_palette_write(ig, img, bitspp, i_colorcount(img))) return 0; |
|
922
|
7 |
0 |
if (!i_img_virtual(img) && !dest.compressed) { |
|
|
2 |
5 |
if (!i_img_virtual(img) && !dest.compressed) { |
|
923
|
0 |
2 |
if (i_io_write(ig, img->idata, img->bytes) != img->bytes) { |
|
930
|
750 |
5 |
for(y=0; yysize; y++) { |
|
931
|
750 |
0 |
i_gpal(img, 0, img->xsize, y, vals); |
|
938
|
13 |
3 |
size_t bytepp = wierdpack ? 2 : bpp_to_bytes(bitspp); |
|
943
|
108317 |
16 |
for(y=0; yysize; y++) { |
|
945
|
495990 |
108317 |
for(x=0; xxsize; x++) color_pack(buf+x*bytepp, bitspp, vals+x); |
|
952
|
1 |
22 |
if (i_io_close(ig)) |