Beispiel #1
0
void ObjMeshRender::Texture::loadTextureImage(string fullPath, int * width, int * height, int * bpp, unsigned char ** texData)
{
  ImageIO imageIO;
  ImageIO::fileFormatType fileFormat;
  // automatically determines the file format type from the filename extension; see imageIO class
  ImageIO::errorType errorCode = imageIO.load(fullPath.c_str(), &fileFormat);
  if (errorCode != ImageIO::OK)
  {
    printf("Warning: unable to load texture %s.\n", fullPath.c_str());
    return;
  }

  *width = imageIO.getWidth();
  *height = imageIO.getHeight();
  *bpp = imageIO.getBytesPerPixel();
  *texData = (unsigned char*) malloc (sizeof(unsigned char) * *width * *height * *bpp);
  memcpy(*texData, imageIO.getPixels(), sizeof(unsigned char) * *width * *height * *bpp);
}
Beispiel #2
0
void Image::load(const std::string& filename)
{
    ImageIO iio;
    iio.load(*this, filename);
}