Esempio n. 1
0
/*
 * Read an image
 */
int RImage::read(char file[100]) {
	if (strstr(file, ".ppm") != NULL) {
		type = PPM;
		readPPM(file);

	} else if (strstr(file, ".pgm") != NULL){
		type = PGM;
		readPGM(file);

	} else if (strstr(file, ".jpeg") != NULL ||
			strstr(file, ".jpg") != NULL) {
		type = JPEG;
		readJPEG(file);

	} else if (strstr(file, ".png") != NULL) {
		fprintf(stderr, "ERROR: Format not supported as yet.\n");
		type = PNG;
		readPNG(file);

	} else {
		fprintf(stderr, "ERROR: Cannot read image %s.\n", file);
		exit(1);
	}

	return 0;
}
Esempio n. 2
0
GLImageStructure readImage(const std::string& FileName, ImageType type_hint)
{
  if (type_hint==itUnknown)
  {
    type_hint = getImageType(FileName);
  }
  switch (type_hint)
  {
    case itJPEG:
         return readJPEG(FileName);
    case itPNG:
         return readPNG(FileName);
    case itGIF:
         return readGIF(FileName);
    case itBitmap:
         return readBMP(FileName);
    case itPPM:
         return readPPM(FileName);
  }

  //no supported image here
  GLImageStructure temp_glis;
  temp_glis.setWidth(0);
  temp_glis.setHeight(0);
  temp_glis.setFormat(0);
  temp_glis.setBuffer(NULL);
  return temp_glis;
}
Esempio n. 3
0
void textureLoadWithFilename(const char *filename, GLuint *texturename) 
{
	unsigned char *image_data;

	/* FIXME: test mime instead */	
	if(strcasestr(filename, ".png") != NULL) {
		image_data = readPNG(filename);
	} else {
		image_data = readJPEG(filename);
	}

	powerOfTwoScaling(&image_data, &tex_width, &tex_height);
// scale4x(&image_data, tex_width, tex_height);

	if(image_data != NULL) {
		glBindTexture(GL_TEXTURE_2D, (*texturename));
		glTexParameteri(GL_TEXTURE_2D, 
			GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, 
			GL_TEXTURE_MAG_FILTER, GL_LINEAR);

		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex_width, tex_height, 
			0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);

		free(image_data);

		printf("SUCCESS: loadTextureWithFilename():" 
			" %s\n", filename);		
	}
}
Esempio n. 4
0
int panoJPEGRead(Image * im, fullPath * sfile)
{
  if ( readJPEG(im, sfile) == 0) {
      return panoMetadataUpdateFromImage(im);
  } else
      return FALSE;


}
Esempio n. 5
0
void loadAllImages(const std::string &path)
{
    DIR *dirp = opendir(path.c_str());
    struct dirent* dp;
    
    std::vector<std::string> fileNames;
    while ((dp = readdir(dirp)) != NULL){
        if (getExt(dp->d_name) == "jpg") {
            fileNames.push_back(std::string(dp->d_name));
        }
    }
    
    std::sort(fileNames.begin(), fileNames.end());
    
    for(size_t i=0;i<fileNames.size();i++){
        unsigned char* rgbdata;
        int width,height;
        readJPEG(path + fileNames[i], rgbdata, width, height);
        write(1,rgbdata,width*height*3);
        free(rgbdata);
    }
}