MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / Targa_decodeImageData

Function Targa_decodeImageData

radiantcore/imagefile/TGALoader.cpp:325–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323
324template<typename Flip>
325RGBAImagePtr Targa_decodeImageData(const TargaHeader& targa_header, stream::PointerInputStream& istream, const Flip& flip)
326{
327 auto image = std::make_shared<RGBAImage>(targa_header.width, targa_header.height);
328
329 if (targa_header.image_type == 2 || targa_header.image_type == 3)
330 {
331 switch (targa_header.pixel_size)
332 {
333 case 8:
334 targa_decode_grayscale(istream, *image, flip);
335 break;
336 case 24:
337 targa_decode_rgb(istream, *image, flip);
338 break;
339 case 32:
340 targa_decode_rgba(istream, *image, flip);
341 break;
342 default:
343 rError() << "LoadTGA: illegal pixel_size '" << targa_header.pixel_size << "'\n";
344 return RGBAImagePtr();
345 }
346 }
347 else if (targa_header.image_type == 10)
348 {
349 switch (targa_header.pixel_size)
350 {
351 case 24:
352 targa_decode_rle_rgb(istream, *image, flip);
353 break;
354 case 32:
355 targa_decode_rle_rgba(istream, *image, flip);
356 break;
357 default:
358 rError() << "LoadTGA: illegal pixel_size '" << targa_header.pixel_size << "'\n";
359 return RGBAImagePtr();
360 }
361 }
362
363 return image;
364}
365
366const unsigned int TGA_FLIP_HORIZONTAL = 0x10;
367const unsigned int TGA_FLIP_VERTICAL = 0x20;

Callers 1

LoadTGABuffFunction · 0.85

Calls 6

targa_decode_grayscaleFunction · 0.85
targa_decode_rgbFunction · 0.85
targa_decode_rgbaFunction · 0.85
rErrorFunction · 0.85
targa_decode_rle_rgbFunction · 0.85
targa_decode_rle_rgbaFunction · 0.85

Tested by

no test coverage detected