- Notifications
You must be signed in to change notification settings - Fork11
C++ library to read/write Truevision TGA/TARGA files
License
NotificationsYou must be signed in to change notification settings
aseprite/tga
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Library to read/writeTruevision TGA/TARGA files.Tested withlibfuzzer.
Example:
#include"tga/tga.h"#include<cstdio>#include<vector>intmain(int argc,char* argv[]){if (argc <2)return1; FILE* f =std::fopen(argv[1],"rb"); tga::StdioFileInterfacefile(f); tga::Decoderdecoder(&file); tga::Header header;if (!decoder.readHeader(header))return2; tga::Image image; image.bytesPerPixel = header.bytesPerPixel(); image.rowstride = header.width * header.bytesPerPixel(); std::vector<uint8_t>buffer(image.rowstride * header.height); image.pixels = &buffer[0];if (!decoder.readImage(header, image,nullptr))return3;// Optional post-process to fix the alpha channel in// some TGA files where alpha=0 for all pixels when// it shouldn't. decoder.postProcessImage(header, image);return0;}