Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. ImageData::Ptr ImageLoader::loadTga(const std::string &filename) {
  2.     ImageData::Ptr data_ = std::make_shared<ImageData>();
  3.  
  4.     {
  5.  
  6.         TGA        *info;
  7.         TGAData    *data;
  8.  
  9.         char * tmp = const_cast<char *>(filename.c_str());
  10.  
  11.  
  12.         data = reinterpret_cast<TGAData*>(malloc(sizeof(TGAData)));
  13.         if(!data) {
  14.                 TGA_ERROR((TGA*)NULL, TGA_OOM);
  15.                 return 0;
  16.             }
  17.  
  18.         info = TGAOpen(tmp,"r");
  19.  
  20.  
  21.        
  22.         data->flags = TGA_IMAGE_ID | TGA_IMAGE_DATA | TGA_RGB;
  23.  
  24.         TGAReadImage(info,data);
  25.  
  26.  
  27.         data_->size.width   =  info->hdr.width;
  28.         data_->size.height  =  info->hdr.height;
  29.         //data_->channel      =  3;
  30.  
  31.  
  32.  
  33.         TGAClose(info);
  34.  
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement