示例#1
0
my_image *load_image(boost::filesystem::path & aPath, int nbytes, bool for_bmp, bool inverse)
{
	if (aPath.extension().compare(".bmp") == 0) return loadBMP(  aPath, nbytes, inverse);
	if (aPath.extension().compare(".BMP") == 0) return loadBMP(  aPath, nbytes, inverse);
	if (aPath.extension().compare(".jpg") == 0) return loadJPEG( aPath, nbytes, for_bmp, inverse);
	if (aPath.extension().compare(".JPG") == 0) return loadJPEG( aPath, nbytes, for_bmp, inverse);
	if (aPath.extension().compare(".thb") == 0) return loadJPEG( aPath, nbytes, for_bmp, inverse);
	if (aPath.extension().compare(".THB") == 0) return loadJPEG( aPath, nbytes, for_bmp, inverse);
	if (aPath.extension().compare(".png") == 0) return loadPNG(  aPath, nbytes, for_bmp, inverse);
	if (aPath.extension().compare(".PNG") == 0) return loadPNG(  aPath, nbytes, for_bmp, inverse);
	if (aPath.extension().compare(".tif") == 0) return loadTIFF( aPath, nbytes, for_bmp, inverse);
	if (aPath.extension().compare(".TIF") == 0) return loadTIFF( aPath, nbytes, for_bmp, inverse);

	return NULL;
}
示例#2
0
文件: image.cpp 项目: AranHase/embree
  /*! loads an image from a file with auto-detection of format */
  Ref<Image> loadImageFromDisk(const FileName& fileName) try
  {
    std::string ext = std::strlwr(fileName.ext());
#ifdef USE_OPENEXR
    if (ext == "exr" ) return loadExr(fileName);
#endif
#ifdef USE_IMAGEMAGICK
    if (ext == "bmp" ) return loadMagick(fileName);
    if (ext == "gif" ) return loadMagick(fileName);
    if (ext == "png" ) return loadMagick(fileName);
    if (ext == "tga" ) return loadMagick(fileName);
    if (ext == "tif" ) return loadMagick(fileName);
    if (ext == "tiff") return loadMagick(fileName);
#endif
#ifdef USE_LIBJPEG
    if (ext == "jpg" ) return loadJPEG(fileName);
#endif
    if (ext == "pfm" ) return loadPFM(fileName);
    if (ext == "ppm" ) return loadPPM(fileName);
    throw std::runtime_error("image format " + ext + " not supported");
  }
  catch (const std::exception& e) {
    std::cout << "cannot read file " << fileName << ": " << e.what() << std::endl;
    return null;
  }
示例#3
0
int load_pixels(const std::string& filename, unsigned char **pixel_buf, img_info_t *img_info) {

	memset(img_info, 0x0, sizeof(*img_info));

	std::string ext = get_file_extension(filename);
	if (ext == ".jpg" || ext == ".jpeg") {
		if (!loadJPEG(filename, pixel_buf, img_info)) {
			fprintf(stderr, "[load_pixels]: fatal error: loading file %s failed.\n", filename.c_str());
			return 0;
		}
	
	}
	else if (ext == ".png") {
		if(!loadPNG(filename, pixel_buf, img_info)) {
			fprintf(stderr, "[load_pixels]: fatal error: loading file %s failed.\n", filename.c_str());
			return 0;
		}
	} else {
		fprintf(stderr, "[load_pixels]: fatal error: unsupported image file extension \"%s\" (only .png, .jpg, .jpeg are supported)\n", ext.c_str());
		return 0;
	}

	return 1;

}
示例#4
0
void VirtGlWindow::setBackImgFile( const char* fname )
{
	if ( jpgImgData.data )
		delete jpgImgData.data;

	jpgImgData = loadJPEG(fname);
}
示例#5
0
int main(int argc, char *argv[])
{
	int width, height;
	unsigned int orientation;
	
	struct timeval t1, t2;
	struct timezone tz;
	float deltatime;
	
	unsigned char *image;
	GL_STATE_T state, *p_state = &state;
	
	//image = esLoadTGA("jan.tga", &width, &height);
	gettimeofday ( &t1 , &tz );
	
	if (argc < 2) {
		printf("Usage: %s <filename>\n", argv[0]);
		return -1;
	}
	
	image = loadJPEG(argv[1], 1920, 1080, &width, &height, &orientation);
	if (image == NULL) {
		fprintf(stderr, "No such image\n");
		exit(1);
	}
	fprintf(stderr, "Image is %d x %d\n", width, height);
	gettimeofday(&t2, &tz);
	deltatime = (float)(t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) * 1e-6);
	
	printf("Image loaded in %1.4f seconds\n", deltatime);
	
	
	bcm_host_init();
	
	gl_display_init(p_state);

#if 1
	if(!gl_image_init(p_state, image, width, height, orientation))
		return 0;
	
	gl_display_register_draw_func(p_state, gl_image_draw);
#endif

#if 0
	if (!gl_rect_init(p_state, width, height, 1.0f, 0.0f, 0.0f))
		return 0;
	
	gl_display_register_draw_func(p_state, gl_rect_draw);
#endif
	
	eglSwapBuffers(p_state->display, p_state->surface);
	esMainLoop(p_state);
	
	return 0; // not reached
}
示例#6
0
Bitmap::Bitmap(EFileFormat format, Stream *stream) : m_data(NULL) {
	if (format == EPNG)
		loadPNG(stream);
	else if (format == EJPEG)
		loadJPEG(stream);
	else if (format == EEXR)
		loadEXR(stream);
	else if (format == ETGA)
		loadTGA(stream);
	else if (format == EBMP)
		loadBMP(stream);
	else
		Log(EError, "Bitmap: Invalid file format!");
}
示例#7
0
bool Surface::loadImage(Common::SeekableReadStream &stream, ImageType type) {
	if (type == kImageTypeNone)
		return false;

	switch (type) {
	case kImageTypeTGA:
		return loadTGA(stream);
	case kImageTypeIFF:
		return loadIFF(stream);
	case kImageTypeBRC:
		return loadBRC(stream);
	case kImageTypeBMP:
		return loadBMP(stream);
	case kImageTypeJPEG:
		return loadJPEG(stream);

	default:
		warning("Surface::loadImage(): Unknown image type: %d", (int) type);
		return false;
	}

	return false;
}
示例#8
0
void CurveEditScreen::screenCB( Fl_Widget* w )
{
	if ( !editCurvePtr )
		return;

	if ( w == curveEditUI->closeButton )
	{
		editCurvePtr->setCloseFlag( curveEditUI->closeButton->value() );
		editCurvePtr->generate();
		editCurvePtr->triggerGeom();
		glWin->redraw();
	}
	else if ( w == curveEditUI->smoothButton )
	{
		editCurvePtr->setSmoothFlag( curveEditUI->smoothButton->value() );
		editCurvePtr->generate();
		editCurvePtr->triggerGeom();
		glWin->redraw();
	}
	else if ( w == curveEditUI->addButton )
	{
		editCurvePtr->addEditPnt();
		editCurvePtr->generate();
		editCurvePtr->triggerGeom();
		glWin->redraw();
	}
	else if ( w == curveEditUI->delButton )
	{
		editCurvePtr->delEditPnt();
		editCurvePtr->generate();
		editCurvePtr->triggerGeom();
		glWin->redraw();
	}
	else if ( w == curveEditUI->symmetryChoice )
	{
		int val = curveEditUI->symmetryChoice->value();
		editCurvePtr->setSym(val);
		editCurvePtr->generate();
		editCurvePtr->triggerGeom();
		glWin->redraw();
	}
	else if ( w == curveEditUI->lockXButton )
	{
		int val = curveEditUI->lockXButton->value();
		editCurvePtr->setLockX(val);
		glWin->redraw();
	}
	else if ( w == curveEditUI->lockYButton )
	{
		int val = curveEditUI->lockYButton->value();
		editCurvePtr->setLockY(val);
		glWin->redraw();
	}
	else if ( w == curveEditUI->scaleXNo )
	{
		editCurvePtr->resetScaleX();
		editCurvePtr->generate();
		editCurvePtr->triggerGeom();
		glWin->redraw();
	}
	else if ( w == curveEditUI->scaleXOk )
	{
		editCurvePtr->acceptScaleX();
		glWin->redraw();
	}
	else if ( w == curveEditUI->scaleYNo )
	{
		editCurvePtr->resetScaleY();
		editCurvePtr->generate();
		editCurvePtr->triggerGeom();
		glWin->redraw();
	}
	else if ( w == curveEditUI->scaleYOk )
	{
		editCurvePtr->acceptScaleY();
		glWin->redraw();
	}
	else if ( w == curveEditUI->initButton  )
	{
		editCurvePtr->initShape();
		editCurvePtr->generate();
		editCurvePtr->triggerGeom();
		glWin->redraw();
	}
	else if ( w == curveEditUI->shapeChoice  )
	{
		int val = curveEditUI->shapeChoice->value();
		editCurvePtr->setShapeType( val );
	}
	else if ( w == curveEditUI->zoomRoller )
	{
		double val = curveEditUI->zoomRoller->value();
		editCurvePtr->setDrawScaleFactor( val );
		glWin->redraw();
	}
	else if ( w == curveEditUI->backgroundButton  )
	{
		if ( curveEditUI->backgroundButton->value() )
		{

//			char *newfile = fl_file_chooser("Read Deflection File?", "*.jpg", "");
			char *newfile = screenMgrPtr->FileChooser("Read Deflection File?", "*.jpg");
			if ( newfile != NULL )
			{
				deleteJPEG( jpgImgData );
				jpgImgData = loadJPEG(newfile);
				glWin->setBackImg( jpgImgData );
			}
			glWin->setDrawBackImgFlag( 1 );
		}
		else
		{
			glWin->setDrawBackImgFlag( 0 );
		}
		glWin->redraw();
	}

}