| 1 | /* |
| 2 | Copyright (C) 2000 Marco Ziech ([email protected]) |
| 3 | Copyright (C) 2000 Ross Combs ([email protected]) |
| 4 | |
| 5 | This program is xfree software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; either version 2 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the Free Software |
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/ |
| 20 | #include "tga.h"cxx . . $ `<file>/src/bniutils/tga.h`/ |
| 21 | |
| 22 | #include <cerrno> |
| 23 | #include <cstdint> |
| 24 | #include <cstring> |
| 25 | |
| 26 | #include "common/xalloc.h"cxx . . $ `<file>/src/common/xalloc.h`/ |
| 27 | #include "fileio.h"cxx . . $ `<file>/src/bniutils/fileio.h`/ |
| 28 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 29 | |
| 30 | namespace pvpgncxx . . $ pvpgn/ |
| 31 | { |
| 32 | |
| 33 | namespace bnicxx . . $ pvpgn/bni/ |
| 34 | { |
| 35 | |
| 36 | namespacecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/ |
| 37 | { |
| 38 | |
| 39 | int rotate_updowncxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/rotate_updown(97c5078d2292c5f6).(t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# *img) { |
| 40 | unsigned char *ndata; |
| 41 | int pixelsize; |
| 42 | int y; |
| 43 | if (img == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return -1; |
| 44 | if (img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return -1; |
| 45 | pixelsize = getpixelsizecxx . . $ pvpgn/bni/getpixelsize(5314f7cd3df64b7e).(img); |
| 46 | if (pixelsize == 0) return -1; |
| 47 | ndata = (unsigned char *)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(img->width*img->height*pixelsize); |
| 48 | for (y = 0; y < img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.; y++) { |
| 49 | std::memcpy(ndata + (y*img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*pixelsize), |
| 50 | img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. + ((img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.*pixelsize) - ((y + 1)*img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*pixelsize)), |
| 51 | img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*pixelsize); |
| 52 | } |
| 53 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img->data); |
| 54 | img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. = ndata; |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | int rotate_leftrightcxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/rotate_leftright(97c5078d2292c5f6).(t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# *img) { |
| 59 | unsigned char *ndata, *datap; |
| 60 | int pixelsize; |
| 61 | int y, x; |
| 62 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "WARNING: rotate_leftright: this function is untested!\n"); |
| 63 | if (img == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return -1; |
| 64 | if (img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return -1; |
| 65 | pixelsize = getpixelsizecxx . . $ pvpgn/bni/getpixelsize(5314f7cd3df64b7e).(img); |
| 66 | if (pixelsize == 0) return -1; |
| 67 | ndata = (unsigned char *)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(img->width*img->height*pixelsize); |
| 68 | datap = img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data.; |
| 69 | for (y = 0; y < img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.; y++) { |
| 70 | unsigned char *linep = (ndata + (((y + 1)*img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*pixelsize) - pixelsize)); |
| 71 | for (x = 0; x < img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.; x++) { |
| 72 | std::memcpy(linep, datap, pixelsize); |
| 73 | linep -= pixelsize; |
| 74 | datap += pixelsize; |
| 75 | } |
| 76 | } |
| 77 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img->data); |
| 78 | img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. = ndata; |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | int RLE_decompresscxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/RLE_decompress(5122c2bbcc2ce4c8).(std::FILEcxx . . $ std/FILE# *f, void *buf, int bufsize, int pixelsize) { |
| 84 | unsigned char pt; |
| 85 | unsigned char *bufp; |
| 86 | unsigned char temp[8]; /* MAXPIXELSIZE */ |
| 87 | int bufi; |
| 88 | int count; |
| 89 | |
| 90 | file_rpushcxx . . $ pvpgn/bni/file_rpush(8d4262d45fc644ab).(f); |
| 91 | bufp = (unsigned char*)buf; |
| 92 | for (bufi = 0; bufi<bufsize;) { |
| 93 | pt = file_readbcxx . . $ pvpgn/bni/file_readb(7c4be072098b358f).(); |
| 94 | if (std::feofcxx . . $ std/feof(7a688d7338757b98).(f)) { |
| 95 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_decompress: after final packet only got %d of %d bytes\n", bufi, bufsize); |
| 96 | file_rpopcxx . . $ pvpgn/bni/file_rpop(49f6e7a06ebc5aa8).(); |
| 97 | return -1; |
| 98 | } |
| 99 | count = (pt & 0x7f) + 1; |
| 100 | if (bufi + count*pixelsize>bufsize) { |
| 101 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_decompress: buffer too short for next packet (need %d bytes, have %d)\n", bufi + count*pixelsize, bufsize); |
| 102 | file_rpopcxx . . $ pvpgn/bni/file_rpop(49f6e7a06ebc5aa8).(); |
| 103 | return -1; |
| 104 | } |
| 105 | if ((pt & 0x80) == 0) { /* RAW PACKET */ |
| 106 | if (std::freadcxx . . $ std/fread(738fc8ac1d711e58).(bufp, pixelsize, count, f) < (unsigned)count) { |
| 107 | if (std::feofcxx . . $ std/feof(7a688d7338757b98).(f)) |
| 108 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_decompress: short RAW packet (expected %d bytes) (EOF)\n", pixelsize*count); |
| 109 | else |
| 110 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_decompress: short RAW packet (expected %d bytes) (std::fread: %s)\n", pixelsize*count, std::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 111 | #if 0 |
| 112 | file_rpop(); |
| 113 | return -1; |
| 114 | #endif |
| 115 | } |
| 116 | bufp += count*pixelsize; |
| 117 | bufi += count*pixelsize; |
| 118 | } |
| 119 | else { /* RLE PACKET */ |
| 120 | if (std::freadcxx . . $ std/fread(738fc8ac1d711e58).(temp, pixelsize, 1, f) < 1) { |
| 121 | if (std::feofcxx . . $ std/feof(7a688d7338757b98).(f)) |
| 122 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_decompress: short RLE packet (expected %d bytes) (EOF)\n", pixelsize); |
| 123 | else |
| 124 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_decompress: short RLE packet (expected %d bytes) (std::fread: %s)\n", pixelsize, std::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 125 | #if 0 |
| 126 | file_rpop(); |
| 127 | return -1; |
| 128 | #endif |
| 129 | } |
| 130 | if (count<2) { |
| 131 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_decompress: suspicious RLE repetition count %d\n", count); |
| 132 | } |
| 133 | for (; count > 0; count--) { |
| 134 | std::memcpy(bufp, temp, pixelsize); |
| 135 | bufp += pixelsize; |
| 136 | bufi += pixelsize; |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | file_rpopcxx . . $ pvpgn/bni/file_rpop(49f6e7a06ebc5aa8).(); |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | void RLE_write_pktcxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/RLE_write_pkt(a1888478a31afdfc).(std::FILEcxx . . $ std/FILE# *f, t_tgapkttypecxx . . $ pvpgn/bni/t_tgapkttype# pkttype, int len, void *data, int pixelsize) { |
| 145 | unsigned char count; |
| 146 | |
| 147 | if (len<1 || len>128) { |
| 148 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_write_pkt: packet has bad length (%d bytes)\n", len); |
| 149 | return; |
| 150 | } |
| 151 | if (pkttype == RLEcxx . . $ pvpgn/bni/RLE.) { |
| 152 | if (len < 2) { |
| 153 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_write_pkt: RLE packet has bad length (%d bytes)\n", len); |
| 154 | return; |
| 155 | } |
| 156 | count = (unsigned char)(0x80 | (len - 1)); |
| 157 | if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(&count, 1, 1, f) < 1) |
| 158 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_write_pkt: could not write RLE pixel count (std::fwrite: %s)\n", std::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 159 | if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(data, pixelsize, 1, f) < 1) |
| 160 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_write_pkt: could not write RLE pixel value (std::fwrite: %s)\n", std::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 161 | } |
| 162 | else { |
| 163 | count = (unsigned char)(len - 1); |
| 164 | if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(&count, 1, 1, f) < 1) |
| 165 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_write_pkt: could not write RAW pixel count (std::fwrite: %s)\n", std::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 166 | if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(data, pixelsize, len, f) < (unsigned)len) |
| 167 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_write_pkt: could not write %d RAW pixels (std::fwrite: %s)\n", len, std::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | |
| 172 | int RLE_compresscxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/RLE_compress(d90b36b885574611).(std::FILEcxx . . $ std/FILE# *f, t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# const *img) { |
| 173 | int pixelsize; |
| 174 | unsigned char const *datap; |
| 175 | unsigned char *pktdata; |
| 176 | unsigned int pktlen; |
| 177 | t_tgapkttypecxx . . $ pvpgn/bni/t_tgapkttype# pkttype; |
| 178 | unsigned char *pktdatap; |
| 179 | unsigned int actual = 0, perceived = 0; |
| 180 | int i; |
| 181 | |
| 182 | pkttype = RAWcxx . . $ pvpgn/bni/RAW.; |
| 183 | pktdatap = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 184 | |
| 185 | if (img == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return -1; |
| 186 | if (img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return -1; |
| 187 | pixelsize = getpixelsizecxx . . $ pvpgn/bni/getpixelsize(5314f7cd3df64b7e).(img); |
| 188 | if (pixelsize == 0) return -1; |
| 189 | |
| 190 | datap = img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data.; |
| 191 | pktdata = (unsigned char*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(img->width*img->height*pixelsize); |
| 192 | pktlen = 0; |
| 193 | |
| 194 | for (i = 0; i < img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.;) { |
| 195 | if (pktlen == 0) { |
| 196 | pktdatap = pktdata; |
| 197 | std::memcpy(pktdatap, datap, pixelsize); |
| 198 | pktlen++; |
| 199 | i++; |
| 200 | pktdatap += pixelsize; |
| 201 | datap += pixelsize; |
| 202 | pkttype = RAWcxx . . $ pvpgn/bni/RAW.; |
| 203 | continue; |
| 204 | } |
| 205 | if (pktlen == 1) { |
| 206 | if (std::memcmp(datap - pixelsize, datap, pixelsize) == 0) { |
| 207 | pkttype = RLEcxx . . $ pvpgn/bni/RLE.; |
| 208 | } |
| 209 | } |
| 210 | if (pkttype == RLEcxx . . $ pvpgn/bni/RLE.) { |
| 211 | if (std::memcmp(datap - pixelsize, datap, pixelsize) != 0 || pktlen >= 128) { |
| 212 | RLE_write_pktcxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/RLE_write_pkt(a1888478a31afdfc).(f, pkttype, pktlen, pktdata, pixelsize); |
| 213 | actual += 1 + pixelsize; |
| 214 | perceived += pixelsize*pktlen; |
| 215 | pktlen = 0; |
| 216 | } |
| 217 | else { |
| 218 | pktlen++; |
| 219 | i++; |
| 220 | datap += pixelsize; |
| 221 | } |
| 222 | } |
| 223 | else { |
| 224 | if (std::memcmp(datap - pixelsize, datap, pixelsize) == 0 || pktlen >= 129) { |
| 225 | datap -= pixelsize; /* push back last pixel */ |
| 226 | i--; |
| 227 | if (i < 0) std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "BUG!\n"); |
| 228 | pktlen--; |
| 229 | RLE_write_pktcxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/RLE_write_pkt(a1888478a31afdfc).(f, pkttype, pktlen, pktdata, pixelsize); |
| 230 | actual += 1 + pixelsize*pktlen; |
| 231 | perceived += pixelsize*pktlen; |
| 232 | pktlen = 0; |
| 233 | } |
| 234 | else { |
| 235 | std::memcpy(pktdatap, datap, pixelsize); |
| 236 | pktlen++; |
| 237 | i++; |
| 238 | pktdatap += pixelsize; |
| 239 | datap += pixelsize; |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | if (pktlen) { |
| 244 | RLE_write_pktcxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/RLE_write_pkt(a1888478a31afdfc).(f, pkttype, pktlen, pktdata, pixelsize); |
| 245 | if (pkttype == RLEcxx . . $ pvpgn/bni/RLE.) { |
| 246 | actual += 1 + pixelsize; |
| 247 | perceived += pixelsize*pktlen; |
| 248 | } |
| 249 | else { |
| 250 | actual += 1 + pixelsize*pktlen; |
| 251 | perceived += pixelsize*pktlen; |
| 252 | } |
| 253 | pktlen = 0; |
| 254 | } |
| 255 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "RLE_compress: wrote %u bytes (%u uncompressed)\n", actual, perceived); |
| 256 | xfreecxx . . $ `src/common/xalloc.h:51:9`!((void*)pktdata); |
| 257 | return 0; |
| 258 | } |
| 259 | |
| 260 | } |
| 261 | |
| 262 | extern int getpixelsizecxx . . $ pvpgn/bni/getpixelsize(5314f7cd3df64b7e).(t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# const *img) { |
| 263 | switch (img->bppcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#bpp.) { |
| 264 | case 8: |
| 265 | return 1; |
| 266 | case 15: |
| 267 | case 16: |
| 268 | return 2; |
| 269 | case 24: |
| 270 | return 3; |
| 271 | case 32: |
| 272 | return 4; |
| 273 | default: |
| 274 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "load_tga: color depth %u is not supported!\n", img->bppcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#bpp.); |
| 275 | return 0; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | |
| 280 | extern t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# * new_tgaimgcxx . . $ pvpgn/bni/new_tgaimg(c336b9b97445332).(unsigned int width, unsigned int height, unsigned int bpp, t_tgaimgtypecxx . . $ pvpgn/bni/t_tgaimgtype# imgtype) { |
| 281 | t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# *img; |
| 282 | |
| 283 | img = (t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_tgaimg)); |
| 284 | img->idlencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#idlen. = 0; |
| 285 | img->cmaptypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaptype. = tgacmap_nonecxx . . $ pvpgn/bni/tgacmap_none.; |
| 286 | img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. = imgtype; |
| 287 | img->cmapfirstcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmapfirst. = 0; |
| 288 | img->cmaplencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaplen. = 0; |
| 289 | img->cmapescxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmapes. = 0; |
| 290 | img->xorigincxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#xorigin. = 0; |
| 291 | img->yorigincxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#yorigin. = 0; |
| 292 | img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width. = width; |
| 293 | img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height. = height; |
| 294 | img->bppcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#bpp. = bpp; |
| 295 | img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc. = 0; /* no attribute bits, top, left, and zero reserved */ |
| 296 | img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 297 | img->extareaoffcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#extareaoff. = 0; |
| 298 | img->devareaoffcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#devareaoff. = 0; |
| 299 | |
| 300 | return img; |
| 301 | } |
| 302 | |
| 303 | extern t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# * load_tgaheadercxx . . $ pvpgn/bni/load_tgaheader(bf631a1f9eee4486).(void) { |
| 304 | t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# *img; |
| 305 | |
| 306 | img = (t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_tgaimg)); |
| 307 | img->idlencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#idlen. = file_readbcxx . . $ pvpgn/bni/file_readb(7c4be072098b358f).(); |
| 308 | img->cmaptypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaptype. = file_readbcxx . . $ pvpgn/bni/file_readb(7c4be072098b358f).(); |
| 309 | img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. = file_readbcxx . . $ pvpgn/bni/file_readb(7c4be072098b358f).(); |
| 310 | img->cmapfirstcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmapfirst. = file_readw_lecxx . . $ pvpgn/bni/file_readw_le(32a7769d58713265).(); |
| 311 | img->cmaplencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaplen. = file_readw_lecxx . . $ pvpgn/bni/file_readw_le(32a7769d58713265).(); |
| 312 | img->cmapescxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmapes. = file_readbcxx . . $ pvpgn/bni/file_readb(7c4be072098b358f).(); |
| 313 | img->xorigincxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#xorigin. = file_readw_lecxx . . $ pvpgn/bni/file_readw_le(32a7769d58713265).(); |
| 314 | img->yorigincxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#yorigin. = file_readw_lecxx . . $ pvpgn/bni/file_readw_le(32a7769d58713265).(); |
| 315 | img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width. = file_readw_lecxx . . $ pvpgn/bni/file_readw_le(32a7769d58713265).(); |
| 316 | img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height. = file_readw_lecxx . . $ pvpgn/bni/file_readw_le(32a7769d58713265).(); |
| 317 | img->bppcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#bpp. = file_readbcxx . . $ pvpgn/bni/file_readb(7c4be072098b358f).(); |
| 318 | img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc. = file_readbcxx . . $ pvpgn/bni/file_readb(7c4be072098b358f).(); |
| 319 | img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 320 | img->extareaoffcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#extareaoff. = 0; /* ignored when reading */ |
| 321 | img->devareaoffcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#devareaoff. = 0; /* ignored when reading */ |
| 322 | |
| 323 | return img; |
| 324 | } |
| 325 | |
| 326 | extern t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# * load_tgacxx . . $ pvpgn/bni/load_tga(d209b58585032934).(std::FILEcxx . . $ std/FILE# *f) { |
| 327 | t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# *img; |
| 328 | int pixelsize; |
| 329 | |
| 330 | file_rpushcxx . . $ pvpgn/bni/file_rpush(8d4262d45fc644ab).(f); |
| 331 | img = load_tgaheadercxx . . $ pvpgn/bni/load_tgaheader(bf631a1f9eee4486).(); |
| 332 | |
| 333 | /* make sure we understand the header fields */ |
| 334 | if (img->cmaptypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaptype. != tgacmap_nonecxx . . $ pvpgn/bni/tgacmap_none.) { |
| 335 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "load_tga: Color-mapped images are not (yet?) supported!\n"); |
| 336 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img); |
| 337 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 338 | } |
| 339 | if (img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. != tgaimgtype_uncompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_uncompressed_truecolor. && img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. != tgaimgtype_rlecompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_rlecompressed_truecolor.) { |
| 340 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "load_tga: imagetype %u is not supported. (only 2 and 10 are supported)\n", img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype.); |
| 341 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img); |
| 342 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 343 | } |
| 344 | |
| 345 | pixelsize = getpixelsizecxx . . $ pvpgn/bni/getpixelsize(5314f7cd3df64b7e).(img); |
| 346 | if (pixelsize == 0) { |
| 347 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img); |
| 348 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 349 | } |
| 350 | /* Skip the ID if there is one */ |
| 351 | if (img->idlencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#idlen. > 0) { |
| 352 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "load_tga: ID present, skipping %d bytes\n", img->idlencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#idlen.); |
| 353 | if (std::fseekcxx . . $ std/fseek(543fae30d249f6b1).(f, img->idlencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#idlen., SEEK_CURcxx . . $ `<external>/232824719582829767/stdio.h:111:9`!) < 0) |
| 354 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "load_tga: could not seek %u bytes forward (std::fseek: %s)\n", img->idlencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#idlen., std::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 355 | } |
| 356 | |
| 357 | /* Now, we can alloc img->data */ |
| 358 | img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. = (std::uint8_tcxx . . $ std/uint8_t#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(img->width*img->height*pixelsize); |
| 359 | if (img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. == tgaimgtype_uncompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_uncompressed_truecolor.) { |
| 360 | if (std::freadcxx . . $ std/fread(738fc8ac1d711e58).(img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data., pixelsize, img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height., f) < (unsigned)(img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.)) { |
| 361 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "load_tga: error while reading data!\n"); |
| 362 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img->data); |
| 363 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img); |
| 364 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 365 | } |
| 366 | } |
| 367 | else { /* == tgaimgtype_rlecompressed_truecolor */ |
| 368 | if (RLE_decompresscxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/RLE_decompress(5122c2bbcc2ce4c8).(f, img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data., img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.*pixelsize, pixelsize) < 0) { |
| 369 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "load_tga: error while decompressing data!\n"); |
| 370 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img->data); |
| 371 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img); |
| 372 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 373 | } |
| 374 | } |
| 375 | file_rpopcxx . . $ pvpgn/bni/file_rpop(49f6e7a06ebc5aa8).(); |
| 376 | if ((img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc. & tgadesc_horzcxx . . $ pvpgn/bni/tgadesc_horz.) == 1) { /* right, want left */ |
| 377 | if (rotate_leftrightcxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/rotate_leftright(97c5078d2292c5f6).(img) < 0) { |
| 378 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: rotate_leftright failed!\n"); |
| 379 | } |
| 380 | } |
| 381 | if ((img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc. & tgadesc_vertcxx . . $ pvpgn/bni/tgadesc_vert.) == 0) { /* bottom, want top */ |
| 382 | if (rotate_updowncxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/rotate_updown(97c5078d2292c5f6).(img) < 0) { |
| 383 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: rotate_updown failed!\n"); |
| 384 | } |
| 385 | } |
| 386 | return img; |
| 387 | } |
| 388 | |
| 389 | extern int write_tgacxx . . $ pvpgn/bni/write_tga(790b6d97a440dd74).(std::FILEcxx . . $ std/FILE# *f, t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# *img) { |
| 390 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return -1; |
| 391 | if (img == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return -1; |
| 392 | if (img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return -1; |
| 393 | if (img->idlencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#idlen. != 0) return -1; |
| 394 | if (img->cmaptypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaptype. != tgacmap_nonecxx . . $ pvpgn/bni/tgacmap_none.) return -1; |
| 395 | if (img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. != tgaimgtype_uncompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_uncompressed_truecolor. && img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. != tgaimgtype_rlecompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_rlecompressed_truecolor.) return -1; |
| 396 | file_wpushcxx . . $ pvpgn/bni/file_wpush(8d4262d45fc644ab).(f); |
| 397 | |
| 398 | file_writebcxx . . $ pvpgn/bni/file_writeb(b27dbea426b7b93).(img->idlencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#idlen.); |
| 399 | file_writebcxx . . $ pvpgn/bni/file_writeb(b27dbea426b7b93).(img->cmaptypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaptype.); |
| 400 | file_writebcxx . . $ pvpgn/bni/file_writeb(b27dbea426b7b93).(img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype.); |
| 401 | file_writew_lecxx . . $ pvpgn/bni/file_writew_le(377f6a3136964dac).(img->cmapfirstcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmapfirst.); |
| 402 | file_writew_lecxx . . $ pvpgn/bni/file_writew_le(377f6a3136964dac).(img->cmaplencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaplen.); |
| 403 | file_writebcxx . . $ pvpgn/bni/file_writeb(b27dbea426b7b93).(img->cmapescxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmapes.); |
| 404 | file_writew_lecxx . . $ pvpgn/bni/file_writew_le(377f6a3136964dac).(img->xorigincxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#xorigin.); |
| 405 | file_writew_lecxx . . $ pvpgn/bni/file_writew_le(377f6a3136964dac).(img->yorigincxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#yorigin.); |
| 406 | file_writew_lecxx . . $ pvpgn/bni/file_writew_le(377f6a3136964dac).(img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.); |
| 407 | file_writew_lecxx . . $ pvpgn/bni/file_writew_le(377f6a3136964dac).(img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.); |
| 408 | file_writebcxx . . $ pvpgn/bni/file_writeb(b27dbea426b7b93).(img->bppcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#bpp.); |
| 409 | file_writebcxx . . $ pvpgn/bni/file_writeb(b27dbea426b7b93).(img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc.); |
| 410 | |
| 411 | if ((img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc.&tgadesc_horzcxx . . $ pvpgn/bni/tgadesc_horz.) == 1) { /* right, want left */ |
| 412 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "write_tga: flipping horizontally\n"); |
| 413 | if (rotate_leftrightcxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/rotate_leftright(97c5078d2292c5f6).(img) < 0) { |
| 414 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: rotate_updown failed!\n"); |
| 415 | } |
| 416 | } |
| 417 | if ((img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc.&tgadesc_vertcxx . . $ pvpgn/bni/tgadesc_vert.) == 0) { /* bottom, want top */ |
| 418 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "write_tga: flipping vertically\n"); |
| 419 | if (rotate_updowncxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/rotate_updown(97c5078d2292c5f6).(img) < 0) { |
| 420 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: rotate_updown failed!\n"); |
| 421 | } |
| 422 | } |
| 423 | if (img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. == tgaimgtype_uncompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_uncompressed_truecolor.) { |
| 424 | int pixelsize; |
| 425 | |
| 426 | pixelsize = getpixelsizecxx . . $ pvpgn/bni/getpixelsize(5314f7cd3df64b7e).(img); |
| 427 | if (pixelsize == 0) return -1; |
| 428 | if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data., pixelsize, img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height., f) < (unsigned)(img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.)) { |
| 429 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "write_tga: could not write %d pixels (std::fwrite: %s)\n", img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width.*img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height., std::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 430 | file_wpopcxx . . $ pvpgn/bni/file_wpop(49f6e7a06ebc5aa8).(); |
| 431 | return -1; |
| 432 | } |
| 433 | } |
| 434 | else if (img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype. == tgaimgtype_rlecompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_rlecompressed_truecolor.) { |
| 435 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "write_tga: using RLE compression\n"); |
| 436 | if (RLE_compresscxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/tga.cpp`/RLE_compress(d90b36b885574611).(f, img) < 0) { |
| 437 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "write_tga: RLE compression failed.\n"); |
| 438 | } |
| 439 | } |
| 440 | /* Write the file-footer */ |
| 441 | file_writed_lecxx . . $ pvpgn/bni/file_writed_le(4c679297bf94b9eb).(img->extareaoffcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#extareaoff.); |
| 442 | file_writed_lecxx . . $ pvpgn/bni/file_writed_le(4c679297bf94b9eb).(img->devareaoffcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#devareaoff.); |
| 443 | if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(TGAMAGICcxx . . $ `src/bniutils/tga.h:92:9`!, std::strlen(TGAMAGICcxx . . $ `src/bniutils/tga.h:92:9`!) + 1, 1, f) < 1) |
| 444 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "write_tga: could not write TGA footer magic (std::fwrite: %s)\n", std::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 445 | /* Ready */ |
| 446 | file_wpopcxx . . $ pvpgn/bni/file_wpop(49f6e7a06ebc5aa8).(); |
| 447 | return 0; |
| 448 | } |
| 449 | |
| 450 | extern void destroy_imgcxx . . $ pvpgn/bni/destroy_img(537e23c0c2dd1c71).(t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# * img) { |
| 451 | if (img == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return; |
| 452 | |
| 453 | if (img->datacxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#data.) |
| 454 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img->data); |
| 455 | xfreecxx . . $ `src/common/xalloc.h:51:9`!(img); |
| 456 | } |
| 457 | |
| 458 | extern void print_tga_infocxx . . $ pvpgn/bni/print_tga_info(bced1c5b17084774).(t_tgaimgcxx . . $ pvpgn/bni/t_tgaimg# const * img, std::FILEcxx . . $ std/FILE# * fp) { |
| 459 | unsigned int interleave; |
| 460 | unsigned int attrbits; |
| 461 | char const * typestr; |
| 462 | char const * cmapstr; |
| 463 | char const * horzstr; |
| 464 | char const * vertstr; |
| 465 | char const * intlstr; |
| 466 | |
| 467 | if (!img || !fp) |
| 468 | return; |
| 469 | |
| 470 | interleave = ((img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc.&tgadesc_interleave1cxx . . $ pvpgn/bni/tgadesc_interleave1.) != 0) * 2 + ((img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc.&tgadesc_interleave2cxx . . $ pvpgn/bni/tgadesc_interleave2.) != 0); |
| 471 | attrbits = img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc.&(tgadesc_attrbits0cxx . . $ pvpgn/bni/tgadesc_attrbits0. | tgadesc_attrbits1cxx . . $ pvpgn/bni/tgadesc_attrbits1. | tgadesc_attrbits2cxx . . $ pvpgn/bni/tgadesc_attrbits2. | tgadesc_attrbits3cxx . . $ pvpgn/bni/tgadesc_attrbits3.); |
| 472 | switch (img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype.) { |
| 473 | case tgaimgtype_emptycxx . . $ pvpgn/bni/tgaimgtype_empty.: |
| 474 | typestr = "No Image Data Included"; |
| 475 | break; |
| 476 | case tgaimgtype_uncompressed_mappedcxx . . $ pvpgn/bni/tgaimgtype_uncompressed_mapped.: |
| 477 | typestr = "Uncompressed, Color-mapped Image"; |
| 478 | break; |
| 479 | case tgaimgtype_uncompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_uncompressed_truecolor.: |
| 480 | typestr = "Uncompressed, True-color Image"; |
| 481 | break; |
| 482 | case tgaimgtype_uncompressed_monochromecxx . . $ pvpgn/bni/tgaimgtype_uncompressed_monochrome.: |
| 483 | typestr = "Uncompressed, Black-and-white image"; |
| 484 | break; |
| 485 | case tgaimgtype_rlecompressed_mappedcxx . . $ pvpgn/bni/tgaimgtype_rlecompressed_mapped.: |
| 486 | typestr = "Run-length encoded, Color-mapped Image"; |
| 487 | break; |
| 488 | case tgaimgtype_rlecompressed_truecolorcxx . . $ pvpgn/bni/tgaimgtype_rlecompressed_truecolor.: |
| 489 | typestr = "Run-length encoded, True-color Image"; |
| 490 | break; |
| 491 | case tgaimgtype_rlecompressed_monochromecxx . . $ pvpgn/bni/tgaimgtype_rlecompressed_monochrome.: |
| 492 | typestr = "Run-length encoded, Black-and-white image"; |
| 493 | break; |
| 494 | case tgaimgtype_huffman_mappedcxx . . $ pvpgn/bni/tgaimgtype_huffman_mapped.: |
| 495 | typestr = "Huffman encoded, Color-mapped image"; |
| 496 | break; |
| 497 | case tgaimgtype_huffman_4pass_mappedcxx . . $ pvpgn/bni/tgaimgtype_huffman_4pass_mapped.: |
| 498 | typestr = "Four-pass Huffman encoded, Color-mapped image"; |
| 499 | break; |
| 500 | default: |
| 501 | typestr = "unknown"; |
| 502 | } |
| 503 | switch (img->cmaptypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaptype.) { |
| 504 | case tgacmap_nonecxx . . $ pvpgn/bni/tgacmap_none.: |
| 505 | cmapstr = "None"; |
| 506 | break; |
| 507 | case tgacmap_includedcxx . . $ pvpgn/bni/tgacmap_included.: |
| 508 | cmapstr = "Included"; |
| 509 | break; |
| 510 | default: |
| 511 | cmapstr = "Unknown"; |
| 512 | } |
| 513 | if ((img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc.&tgadesc_horzcxx . . $ pvpgn/bni/tgadesc_horz.) == 0) { |
| 514 | horzstr = "left"; |
| 515 | } |
| 516 | else { |
| 517 | horzstr = "right"; |
| 518 | } |
| 519 | if ((img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc.&tgadesc_vertcxx . . $ pvpgn/bni/tgadesc_vert.) == 0) { |
| 520 | vertstr = "bottom"; |
| 521 | } |
| 522 | else { |
| 523 | vertstr = "top"; |
| 524 | } |
| 525 | switch (interleave) { |
| 526 | case 0: |
| 527 | intlstr = "none"; |
| 528 | break; |
| 529 | case 2: |
| 530 | intlstr = "two way"; |
| 531 | break; |
| 532 | case 3: |
| 533 | intlstr = "four way"; |
| 534 | break; |
| 535 | case 4: |
| 536 | default: |
| 537 | intlstr = "unknown"; |
| 538 | break; |
| 539 | } |
| 540 | |
| 541 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "TGAHeader: IDLength=%u ColorMapType=%u(%s)\n", img->idlencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#idlen., img->cmaptypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaptype., cmapstr); |
| 542 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "TGAHeader: ImageType=%u(%s)\n", img->imgtypecxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#imgtype., typestr); |
| 543 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "TGAHeader: ColorMap: FirstEntryIndex=%u ColorMapLength=%u\n", img->cmapfirstcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmapfirst., img->cmaplencxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmaplen.); |
| 544 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "TGAHeader: ColorMap: ColorMapEntrySize=%ubits\n", img->cmapescxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#cmapes.); |
| 545 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "TGAHeader: X-origin=%u Y-origin=%u Width=%u(0x%x) Height=%u(0x%x)\n", img->xorigincxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#xorigin., img->yorigincxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#yorigin., img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width., img->widthcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#width., img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height., img->heightcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#height.); |
| 546 | std::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "TGAHeader: PixelDepth=%ubits ImageDescriptor=0x%02x(%u attribute bits, origin is %s %s, interleave=%s)\n", img->bppcxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#bpp., img->desccxx . . $ pvpgn/bni/$anonymous_type_5814204c52cb45dd_0#desc., attrbits, vertstr, horzstr, intlstr); |
| 547 | } |
| 548 | |
| 549 | } |
| 550 | |
| 551 | } |