Пример #1
0
void init()
{
	/* Load in a PNG image */
	int loadCorrectly = 0;
	loadJPG(jpeg_Path,  imageWidth, imageHeight, comp);
	//printf("Load Successful\n");
}
Пример #2
0
RawImage::RawImage(const char *path) throw(ImageException) :
  _type(GL_RGB),
  _texId(0),
  _bytesPerPixel(0),
  _width(0),
  _height(0),
  _pixels(NULL)
{
  const char *filename = basename(const_cast<char *>(path));
  if (filename == NULL)
    throw ImageException("Invalid image filename: %s does not name a file.", filename);

  const char *ext = strrchr(filename, '.');
  if (ext == NULL)
    throw ImageException("Unknown image format.");

  FILE *file = fopen(path, "rb");
  if (file == NULL)
    throw ImageException("File not found: %s.", filename);

  try {
    if (strcasecmp(ext, ".bmp") == 0) {
      loadBMP(file);
    } else if (strcasecmp(ext, ".tga") == 0) {
      loadTGA(file);
    } else if (strcasecmp(ext, ".ppm") == 0) {
      loadPPM(file);
    } else if (strcasecmp(ext, ".jpg") == 0 || strcasecmp(ext, ".jpeg") == 0) {
      loadJPG(file);
    } else if (strcasecmp(ext, ".png") == 0) {
      loadPNG(file);
    } else if (strcasecmp(ext, ".tif") == 0 || strcasecmp(ext, ".tiff") == 0) {
      loadTIFF(path);
    } else {
      throw ImageException("Unknown image format: %s", ext);
    }
    fclose(file);
  } catch (ImageException& ex) {
    fclose(file);
    if (_pixels != NULL)
      delete _pixels;
    throw ex;
  }
}
Пример #3
0
bool Image::loadSupportedFormat(const char* path_)
{
  const char *verifiedPath = MediaPathManager::lookUpMediaPath(path_);
  
  if (!verifiedPath)
    return false;
    
  path = verifiedPath;
  
  if (isPNG(verifiedPath))
    return loadPNG(verifiedPath, this);
    
  if (isJPEG(verifiedPath))
    return loadJPG(verifiedPath);
    
  if (isTGA(verifiedPath))
    return loadTGA(verifiedPath);
    
  if (isDDS(verifiedPath))
    return loadDDS(verifiedPath);
    
  return false;
}