Esempio n. 1
0
TextureManager::~TextureManager() {
// call this ONLY when linking with FreeImage as a static library
#ifdef FREEIMAGE_LIB
  FreeImage_DeInitialise();
#endif

  UnloadAllTextures();
  m_inst = 0;
}
Esempio n. 2
0
int main(int argc, char** argv) 
{
	DLL_API void DLL_CALLCONV FreeImage_Initialise(BOOL load_local_plugins_only FI_DEFAULT(FALSE));
	for(int i = 1; i < argc; i++)
	{
		fileRead(argv[i]);
	}
	FreeImage_DeInitialise();
	return 0;
};
int 
main(int argc, char *argv[]) {
	
	// call this ONLY when linking with FreeImage as a static library
#ifdef FREEIMAGE_LIB
	FreeImage_Initialise();
#endif // FREEIMAGE_LIB

	// initialize your own FreeImage error handler

	FreeImage_SetOutputMessage(FreeImageErrorHandler);

	// print version & copyright infos

	printf("FreeImage version : %s", FreeImage_GetVersion());
	printf("\n");
	printf(FreeImage_GetCopyrightMessage());
	printf("\n");


	if(argc != 3) {
		printf("Usage : CreateAlpha <input file name> <output file name>\n");
		return 0;
	}

	// Load the source image
	FIBITMAP *src = GenericLoader(argv[1], 0);
	if(src) {
		// Create a transparent image from the lightness image of src
		FIBITMAP *dst = CreateAlphaFromLightness(src);

		if(dst) {
			// Save the destination image
			bool bSuccess = GenericWriter(dst, argv[2], 0);
			if(!bSuccess) {
				printf("\nUnable to save %s file", argv[2]);
				printf("\nThis format does not support 32-bit images");
			}

			// Free dst
			FreeImage_Unload(dst);
		}

		// Free src
		FreeImage_Unload(src);
	}

	// call this ONLY when linking with FreeImage as a static library
#ifdef FREEIMAGE_LIB
	FreeImage_DeInitialise();
#endif // FREEIMAGE_LIB

	return 0;
}
//----------------------------------------------------------
// static variable for freeImage initialization:
void ofInitFreeImage(bool deinit=false){
	// need a new bool to avoid c++ "deinitialization order fiasco":
	// http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.15
	static bool	* bFreeImageInited = new bool(false);
	if(!bFreeImageInited && !deinit){
		FreeImage_Initialise();
		*bFreeImageInited = true;
	}
	if(bFreeImageInited && deinit){
		FreeImage_DeInitialise();
	}
}
Esempio n. 5
0
/**
 * Frees the manager and all the objects that it contains.
 */
void IND_ImageManager::end() {
	if (_ok) {
		g_debug->header("Finalizing ImageManager", DebugApi::LogHeaderBegin);
		g_debug->header("Freeing images" , DebugApi::LogHeaderBegin);
		freeVars();
		FreeImage_DeInitialise();
		g_debug->header("Images freed", DebugApi::LogHeaderEnd);
		g_debug->header("ImageManager finalized", DebugApi::LogHeaderEnd);

		_ok = false;
	}
}
Esempio n. 6
0
	//---------------------------------------------------------------------
	void FreeImageCodec::shutdown(void)
	{
		FreeImage_DeInitialise();

		for (RegisteredCodecList::iterator i = msCodecList.begin();
			i != msCodecList.end(); ++i)
		{
			Codec::unRegisterCodec(*i);
			OGRE_DELETE *i;
		}
		msCodecList.clear();

	}
Esempio n. 7
0
/**
 * destructor
 */
fipImage::~fipImage(){
	
	if ( pImageData ){
		FreeImage_Unload( pImageData );
	}
	
	ulImageInstances--;
	if ( ( ulImageInstances == 0 ) && bFreeImageInitialised ){
		FreeImage_DeInitialise();
		bFreeImageInitialised = false;
	}
	
}
int main(int argc, char *argv[]) {
	unsigned width  = 512;
	unsigned height = 512;

#if defined(_DEBUG) && defined(WIN32)
	// check for memory leaks at program exit (after the 'return 0')
	// through a call to _CrtDumpMemoryLeaks 
	// note that in debug mode, objects allocated with the new operator 
	// may be destroyed *after* the end of the main function. 
	_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF);
#endif

#if defined(FREEIMAGE_LIB) || !defined(WIN32)
	FreeImage_Initialise();
#endif

	// initialize our own FreeImage error handler
	FreeImage_SetOutputMessage(FreeImageErrorHandler);

	// test plugins capabilities
	showPlugins();

	// test the clone function
	testAllocateCloneUnload("exif.jpg");

	// test internal image types
	testImageType(width, height);

	// test loading / saving / converting image types using the TIFF plugin
	testImageTypeTIFF(width, height);

	// test multipage creation
	testBuildMPage("sample.png", "sample.ico", FIF_ICO, 24);
	testBuildMPage("sample.png", "sample.tif", FIF_TIFF, 24);
	//testBuildMPage("sample.png", "sample.gif", FIF_GIF, 8);

	// test multipage cache
	testMPageCache("sample.png");

	// test memory IO
	testMemIO("sample.png");

	// test JPEG lossless transform & cropping
	testJPEG();
	
#if defined(FREEIMAGE_LIB) || !defined(WIN32)
	FreeImage_DeInitialise();
#endif

	return 0;
}
Esempio n. 9
0
App::~App()
{
	m_pluginManager.UnloadAll();

	m_commandLineParser.DisposeCommands();

	for (IdeType* type : m_ides)
	{
		delete type;
	}
	m_ides.clear();
	
	FreeImage_DeInitialise();
}
Esempio n. 10
0
Client::~Client()
{
    enet_host_destroy(m_client);

    delete m_mainPlayer;

    // call this ONLY when linking with FreeImage as a static library
#ifdef FREEIMAGE_LIB
    FreeImage_DeInitialise();
#endif

    SDL_DestroyWindow(m_window);
    SDL_Quit();
}
Esempio n. 11
0
BOOL CBigle3DApp::InitInstance()
{
    AfxEnableControlContainer();

    // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.

    // call this ONLY when linking with FreeImage as a static library
    //FreeImage_Initialise();

    // initialize your own FreeImage error handler
    FreeImage_SetOutputMessage(MyMessageFunc);

    CStartPP pp1;
    CFondPP pp2;
    CReliefPP pp3;
    CCreateImgPP pp4;
    CAboutPP pp5;
    pp1.m_psp.dwFlags -= PSP_HASHELP;
    pp2.m_psp.dwFlags -= PSP_HASHELP;
    pp3.m_psp.dwFlags -= PSP_HASHELP;
    pp4.m_psp.dwFlags -= PSP_HASHELP;
    pp5.m_psp.dwFlags -= PSP_HASHELP;
    m_ps.AddPage( &pp1 );
    m_ps.AddPage( &pp2 );
    m_ps.AddPage( &pp3 );
    m_ps.AddPage( &pp4 );
    m_ps.AddPage( &pp5 );
    m_ps.SetWizardMode();
    m_pMainWnd = &m_ps;
    int nResponse = (int)m_ps.DoModal();
    if (nResponse == IDOK)
    {
        // TODO: Place code here to handle when the dialog is
        //  dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
        // TODO: Place code here to handle when the dialog is
        //  dismissed with Cancel
    }

    FreeImage_DeInitialise();

    // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
}
Esempio n. 12
0
File: fip.cpp Progetto: AleemDev/waf
int main() {

#if defined(FREEIMAGE_LIB) || !defined(WIN32)
	FreeImage_Initialise();
#endif

	fipImage img;
	img.load("img.png");
	std::cout << img.getWidth() << "x" << img.getHeight() << std::endl;

#if defined(FREEIMAGE_LIB) || !defined(WIN32)
	FreeImage_DeInitialise();
#endif

	return 0;
}
Esempio n. 13
0
void ThinLens::render_scene(World& w) {
	RGBColor L;
	Ray ray;
	ViewPlane vp(w.vp);
	FreeImage_Initialise();
	FIBITMAP* bitmap = FreeImage_Allocate(vp.hres, vp.vres, 24);
	RGBQUAD color;
	int depth = 0;

	Point2D sp;
	Point2D pp;
	Point2D dp;
	Point2D lp;

	vp.s /= zoom;

	for(int r = 0; r < vp.vres; r++)
		for(int c = 0 ; c < vp.hres; c++) {
			L = black;

			for(int n = 0; n < vp.num_samples; n++) {
				sp = vp.sampler_ptr -> sample_unit_square();
				pp.x = vp.s * (c - vp.hres / 2.0 + sp.x);
				pp.y = vp.s * (r - vp.vres / 2.0 + sp.y);

				dp = sampler_ptr -> sample_unit_disk();
				lp = dp * lens_radius;

				ray.o = eye + lp.x * u + lp.y * v;
				ray.d = ray_direction(pp, lp);
				L += w.tracer_ptr -> trace_ray(ray);
			}

			L /= vp.num_samples;
			L *= exposure_time;
			w.display_pixel(r, c, L);
			color.rgbRed = (int)(L.r*255);
			color.rgbGreen = (int)(L.g*255);
			color.rgbBlue = (int)(L.b*255);
			FreeImage_SetPixelColor(bitmap, c, r, &color);
		}
	if (FreeImage_Save(FIF_PNG, bitmap, "test.png", 0))
		std::cout << "Image Successfully Saved!" << std::endl;

	FreeImage_DeInitialise();

}
Esempio n. 14
0
void Scene::saveImage(int t){
    FreeImage_Initialise();
    BYTE* pixels = new BYTE[ 3 * WIDTH * HEIGHT];

    glReadPixels(0, 0, WIDTH, HEIGHT, GL_BGR, GL_UNSIGNED_BYTE, pixels);
    FIBITMAP* image = FreeImage_ConvertFromRawBits(pixels, WIDTH, HEIGHT, 3 * WIDTH, 24, 0x0000FF, 0xFF0000, 0x00FF00, false);
    // get a string to concat with an int
    stringstream nameStream;
    nameStream << "test" << t << ".png";
    string name = nameStream.str();
    char *a = new char[name.size() + 1];
    a[name.size()] = 0;
    memcpy(a, name.c_str(), name.size());
    if(FreeImage_Save(FIF_BMP, image, a, 0))
        cout << "Image " << t << " successfully saved! " << endl ;
    FreeImage_DeInitialise(); //Cleanup !
}
Esempio n. 15
0
BOOL APIENTRY
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
	switch (ul_reason_for_call) {
		case DLL_PROCESS_ATTACH :
			FreeImage_Initialise(FALSE);
			break;

		case DLL_PROCESS_DETACH :
			FreeImage_DeInitialise();
			break;

		case DLL_THREAD_ATTACH :
		case DLL_THREAD_DETACH :
			break;
    }

    return TRUE;
}
Esempio n. 16
0
void Film::WriteImage(std::string fname){
	/*Before you use FreeImage, call FreeImage_Initialise(). 
	To record the colors for each pixel, use an array of one byte elements. 
	Then convert this array to a FIBITMAP object as follows, assuming the bytes are in RGB order:*/
	FreeImage_Initialise();
	int pix = width * height;
	BYTE *pixels = new BYTE[3 * pix];
	memcpy((void *)pixels, (void *)colorbuffer, width * height * 3);

	FIBITMAP *img = FreeImage_ConvertFromRawBits(pixels, width, height, width * 3, 24, 0xFF0000, 0x00FF00, 0x0000FF, false);

	std::cout << "Saving screenshot: " << fname << "\n";

	FreeImage_Save(FIF_PNG, img, fname.c_str(), 0);
	
	delete pixels;
	FreeImage_DeInitialise();
}
Esempio n. 17
0
void Fisheye::render_scene(World& w) {
	RGBColor L;
	ViewPlane vp(w.vp);
	FreeImage_Initialise();
	FIBITMAP* bitmap = FreeImage_Allocate(vp.hres, vp.vres, 24);
	RGBQUAD color;
	int hres = vp.hres;
	int vres = vp.vres;
	float s = vp.s;
	Ray ray;
	int depth = 0;
	Point2D sp;
	Point2D pp;
	float r_squared;

	ray.o  = eye;

	for(int r = 0; r < vres; r++)
		for(int c = 0; c < hres; c++) {
			L = black;

			for(int j = 0; j < vp.num_samples; j++) {
				sp = vp.sampler_ptr -> sample_unit_square();
				pp.x = s * (c - hres / 2.0 + sp.x);
				pp.y = s * (r - vres / 2.0 + sp.y);
				ray.d = ray_direction(pp, hres, vres, s, r_squared);

				if(r_squared <= 1.0)
					L += w.tracer_ptr -> trace_ray(ray);
			}

			L /= vp.num_samples;
			L *= exposure_time;
			w.display_pixel(r, c, L);
			color.rgbRed = (int)(L.r*255);
			color.rgbGreen = (int)(L.g*255);
			color.rgbBlue = (int)(L.b*255);
			FreeImage_SetPixelColor(bitmap, c, r, &color);
		}
	if (FreeImage_Save(FIF_PNG, bitmap, "test.png", 0))
		std::cout << "Image Successfully Saved!" << std::endl;
	FreeImage_DeInitialise();
}
Esempio n. 18
0
int main(int argc, const char **argv) {
	if (argc == 5) {
		doingTransfer = true;
	}
	else {
		doingTransfer = false;
	}
	if (argc != 3 && argc != 5) {
		std::cerr << "usage: " << argv[0] << " <src> <dst> <src-crsp> <dst-crsp> " << std::endl;
		return 2;
	}

	blockHeight = 64;
	blockWidth = 64;
	numIterations = 1;
	vertOverlapAmount = 10;
	horizOverlapAmount = 10;
	FreeImage_Initialise(true);

	const int rows = 8;
	const int cols = 8;

	Image * const src = new Image();
	src->load(argv[1]);
	Image * const dst = allocate(rows, cols);
	srand(time(NULL));
	Image * const src_crsp = doingTransfer ? new Image() : NULL;
	Image * const dst_crsp = doingTransfer ? new Image() : NULL;
	if (doingTransfer) {
		src_crsp->load(argv[3]);
		dst_crsp->load(argv[4]);
	}
	quilt(dst, dst_crsp, rows, cols, src, src_crsp);
	dst->save(argv[2]);

	delete dst;
	delete src;
	delete dst_crsp;
	delete src_crsp;

	FreeImage_DeInitialise();
}
Esempio n. 19
0
void Globals::CleanUp()
{
	SAFE_RELEASE(gEntityFactory);
	SAFE_RELEASE(timer);
	SAFE_RELEASE(gWorld);
	SAFE_RELEASE(gKeyControl);
	SAFE_DELETE(gFpsCamera);
	SAFE_DELETE(gFollowCamera);
	SAFE_DELETE(gRTSCamera);
	gCurrentCamera = 0;
	gAIControl = 0;
	if (gDeleteAIPtr)
		gDeleteAIPtr();
	if (m_dll)
		FreeModule(m_dll);
	SAFE_DELETE(gFxEffectManager);
	SAFE_DELETE(gRender);
	SAFE_DELETE(gUI);
	FreeImage_DeInitialise();
}
Esempio n. 20
0
int main(int argc, char *argv[])
{
	if (argc != 3)
	{
		printf("Usage : cworld2img input_filename.bin output_filename.png\n\n");
		return 0;
	}
	FreeImage_Initialise();
	FIBITMAP *bitmap = FreeImage_Allocate(WORLD_WIDTH, WORLD_HEIGHT, 32);
	if(!bitmap)
	{
		printf("Error while allocating image. Aborting");
		return -1;
	}
	FILE *fd = fopen(argv[1], "rb");
	fread(c_world.solids, sizeof(block), WORLD_HEIGHT * WORLD_WIDTH, fd);
	fclose(fd);
	for(int i = 0; i < WORLD_HEIGHT; i++)
	{
		for(int j = 0; j < WORLD_WIDTH; j++)
		{
			switch(c_world.solids[WORLD_WIDTH * i + j])
			{
			case BLCK_AIR:
				FreeImage_SetPixelColor(bitmap, j, WORLD_HEIGHT - i, &qpixel_air);break;
			case BLCK_DIRT:
				FreeImage_SetPixelColor(bitmap, j, WORLD_HEIGHT - i, &qpixel_dirt);break;
			default:
				FreeImage_SetPixelColor(bitmap, j, WORLD_HEIGHT - i, &qpixel_unknown);break;
			}
		}
	}
	if(!FreeImage_Save(FIF_PNG, bitmap, argv[2], 0))
	{
		printf("Error while saving image. Aborting");
		return -1;
	}
	FreeImage_DeInitialise();
	return 0;
}
Esempio n. 21
0
//----------------------------------------------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------------------------------------------
void azImage::Initialize()
{
	azSz szFilePath = azL("F://Dev//Aztec//Bin//Debug//Test.png");

	FreeImage_Initialise();

	fipImage oFreeImage;
#ifdef UNICODE
	azBool bLoaded = (0 != oFreeImage.loadU(szFilePath));
#else // UNICODE
    azBool bLoaded = (0 != oFreeImage.load(szFilePath));
#endif // UNICODE
	azAssert(bLoaded, "Image extension or format not supported");

	azAssert(oFreeImage.getBitsPerPixel() <= 32, "More than 32 BPP images not yet supported, there will be some data loss");

	// Always convert to RGBA 32 bits
	azBool bConverted = (0 != oFreeImage.convertTo32Bits());
	azAssert(bConverted, "Image recognized but we failed to convert it to 32 BPP");

	m_uWidth = oFreeImage.getWidth();
	m_uHeight = oFreeImage.getHeight();
	m_uBpp = oFreeImage.getBitsPerPixel();
	azAssert(m_uBpp == 32, "Convert didn't work properly");

	azUInt uBufferSize = GetBufferSize();
	m_abData = azNewArray(azByte, uBufferSize);

	// There is no C++ wrapping for this method.
    FreeImage_ConvertToRawBits(m_abData,
		oFreeImage,
		oFreeImage.getScanWidth(),
		m_uBpp,
		FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK,
		true);  
	
	oFreeImage.clear();

	FreeImage_DeInitialise();
}
Esempio n. 22
0
  unsigned char* Texture::loadTexture( const char* fileName_,
                                       unsigned int &width_,
                                       unsigned int &height_ )
  {
    FreeImage_Initialise(TRUE);

    FREE_IMAGE_FORMAT format = FreeImage_GetFileType(fileName_, 0);
    if (format == FIF_UNKNOWN)
      format = FreeImage_GetFIFFromFilename(fileName_);
    if ((format == FIF_UNKNOWN) || !FreeImage_FIFSupportsReading(format))
      return NULL;

    FIBITMAP* img = FreeImage_Load(format, fileName_);
    if (img == NULL)
      return NULL;

    FIBITMAP* tempImg = img;
    img = FreeImage_ConvertTo32Bits(img);
    FreeImage_Unload(tempImg);

    width_ = FreeImage_GetWidth(img);
    height_ = FreeImage_GetHeight(img);

    //BGRA a RGBA
    unsigned char * map = new unsigned char[4 * width_*height_];
    char *buff = (char*)FreeImage_GetBits(img);

    for (unsigned int j = 0; j<width_*height_; j++){
      map[j * 4 + 0] = buff[j * 4 + 2];
      map[j * 4 + 1] = buff[j * 4 + 1];
      map[j * 4 + 2] = buff[j * 4 + 0];
      map[j * 4 + 3] = buff[j * 4 + 3];
    }

    FreeImage_Unload(img);
    FreeImage_DeInitialise();

    return map;
  }
Image::Image(const char *image_path, GLuint textureUnit, bool& success) {
	success = true;
	FreeImage_Initialise();
	texture_unit = textureUnit;
	// Load Texture
	FREE_IMAGE_FORMAT image_format = FreeImage_GetFileType(image_path,0);
	FIBITMAP* image_bgr = FreeImage_Load(image_format, image_path);
	if (!image_bgr) {
		fprintf(stdout, "Failed to load image %s", image_path);
		success = false;
	}
	FIBITMAP* temp = image_bgr;
	image_bgr = FreeImage_ConvertTo32Bits(image_bgr);
	FreeImage_Unload(temp);
	im_width = FreeImage_GetWidth(image_bgr);
	im_height = FreeImage_GetHeight(image_bgr);
	GLubyte* image_texture = new GLubyte[4*im_width*im_height];
	char* image_pixeles = (char*)FreeImage_GetBits(image_bgr);
	//FreeImage loads in BGR format, so you need to swap some bytes(Or use GL_BGR).
	for(int j= 0; j<im_width*im_height; j++){
		image_texture[j*4+0]= image_pixeles[j*4+2];
		image_texture[j*4+1]= image_pixeles[j*4+1];
		image_texture[j*4+2]= image_pixeles[j*4+0];
		image_texture[j*4+3]= image_pixeles[j*4+3];
	}
	FreeImage_DeInitialise();
	// Create one OpenGL texture
	glGenTextures(1, &texture_handle);
	glActiveTexture(GL_TEXTURE0 + textureUnit);
	glBindTexture(GL_TEXTURE_2D, texture_handle);
	glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA, im_width, im_height, 0, GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)image_texture );
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 
	glGenerateMipmap(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,0);
}
Esempio n. 24
0
GLuint scene::Loadtexture(const char* pFilename) {

    FreeImage_Initialise();
    GLuint texObject = 0;
    glGenTextures(1, &texObject);
    int error = glGetError();
    FIBITMAP* pImage = FreeImage_Load(FreeImage_GetFileType(pFilename, 0), pFilename);
    FIBITMAP *p32BitsImage = FreeImage_ConvertTo32Bits(pImage);
    int iWidth = FreeImage_GetWidth(p32BitsImage);
    int iHeight = FreeImage_GetHeight(p32BitsImage);

    glBindTexture(GL_TEXTURE_2D, texObject);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iWidth, iHeight,
                 0, GL_BGRA, GL_UNSIGNED_BYTE, (void*)FreeImage_GetBits(p32BitsImage));
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    FreeImage_Unload(p32BitsImage);
    FreeImage_Unload(pImage);
    glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
    return texObject;
    FreeImage_DeInitialise();
}
Esempio n. 25
0
int main(int argc,char* argv[]) {

	//Initialize GLUT
	FreeImage_Initialise();
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutCreateWindow("HW1: Transformations");

	GLenum err = glewInit() ; 
	if (GLEW_OK != err) { 
		std::cerr << "Error: " << glewGetString(err) << std::endl; 
	} 

	init();
	glutDisplayFunc(display);
	glutSpecialFunc(specialKey);
	glutKeyboardFunc(keyboard);
	glutReshapeFunc(reshape);
	glutReshapeWindow(w,h);

	if(argc > 1) {
		allowGrader = true;
		grader.init(argv[1]);
		grader.loadCommands(argv[1]);
		grader.bindDisplayFunc(display);
		grader.bindSpecialFunc(specialKey);
		grader.bindKeyboardFunc(keyboard);
		grader.bindScreenshotFunc(saveScreenshot);
	}

	printHelp();
	glutMainLoop();	
	FreeImage_DeInitialise();

	return 0;
}
Esempio n. 26
0
void pre_lzw_mp::do_lzw(QString n){
    QString job = n;
    QString images_src = src + "\\" +n;
    QString write_dst = dst + "\\" + n;
    QString image_name, saved_name;
    int dot_pos;
    QString image_path;
    QDir images_dir(images_src);
    QDir write_dir(dst);
    write_dir.mkdir(job);
    qDebug()<<images_src;
    qDebug()<<write_dst;
    QFileInfoList images_info_list = images_dir.entryInfoList();
    QList<QFileInfo>::iterator image_iter = images_info_list.begin();
    FreeImage_Initialise(true);
    for(; image_iter < images_info_list.end(); ++image_iter){
        if((*image_iter).isDir()){
//            qDebug()<<(*image_iter).fileName();
            continue;
        }
        image_name = (*image_iter).fileName();
        dot_pos = image_name.indexOf(".");
        saved_name = write_dst + "\\" + image_name.left(dot_pos) + "_c.tif";
        image_path = (*image_iter).absoluteFilePath();
        FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(image_path.toStdString().c_str(), 0);
        if(fif == FIF_UNKNOWN){
            fif = FreeImage_GetFIFFromFilename(image_path.toStdString().c_str());
        }
        if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)){
            FIBITMAP *image = FreeImage_Load(fif, image_path.toStdString().c_str());
            FreeImage_Save(FIF_TIFF, image, saved_name.toStdString().c_str(), TIFF_LZW);
            FreeImage_Unload(image);
        }        
    }
    FreeImage_DeInitialise();
}
Esempio n. 27
0
 void Texture::shutdownTextureSystem() {
   freeimage_init_lock_.lock();
   FreeImage_DeInitialise();
   freeimage_init_ = false;
   freeimage_init_lock_.unlock();
 }
Esempio n. 28
0
void releaseFreeImage() {
  FreeImage_DeInitialise();
}
Esempio n. 29
0
FreeImage::~FreeImage() {
  FreeImage_DeInitialise();
}
Esempio n. 30
0
int 
main(int argc, char *argv[]) {

	const char *input_dir = "d:\\images\\";
	FIBITMAP *dib = NULL;
	int id = 1;

	// call this ONLY when linking with FreeImage as a static library
#ifdef FREEIMAGE_LIB
	FreeImage_Initialise();
#endif // FREEIMAGE_LIB

	// initialize your own FreeImage error handler

	FreeImage_SetOutputMessage(FreeImageErrorHandler);

	// print version & copyright infos

	printf(FreeImage_GetVersion());
	printf("\n");
	printf(FreeImage_GetCopyrightMessage());
	printf("\n");

	// open the log file

	FILE *log_file = fopen("log_file.txt", "w");

	// batch convert all supported bitmaps

	_finddata_t finddata;
	long handle;
	char image_path[MAX_PATH];

	// scan all files
	strcpy(image_path, input_dir);
	strcat(image_path, "*.*");

	if ((handle = _findfirst(image_path, &finddata)) != -1) {
		do {
			// make a path to a directory

			char *directory = new char[MAX_PATH];
			strcpy(directory, input_dir);
			strcat(directory, finddata.name);

			// make a unique filename

			char *unique = new char[128];
			itoa(id, unique, 10);
			strcat(unique, ".png");

			// open and load the file using the default load option
			dib = GenericLoader(directory, 0);

			if (dib != NULL) {
				// save the file as PNG
				bool bSuccess = GenericWriter(dib, unique, PNG_DEFAULT);

				// free the dib
				FreeImage_Unload(dib);

				if(bSuccess) {
					fwrite(unique, strlen(unique), 1, log_file);
				} else {
					strcpy(unique, "FAILED");
					fwrite(unique, strlen(unique), 1, log_file);
				}
				fwrite(" >> ", 4, 1, log_file);
				fwrite(directory, strlen(directory), 1, log_file);
				fwrite("\n", 1, 1, log_file);

				id++;
			}

			delete [] unique;
			delete [] directory;

		} while (_findnext(handle, &finddata) == 0);

		_findclose(handle);
	}

	fclose(log_file);

	// call this ONLY when linking with FreeImage as a static library
#ifdef FREEIMAGE_LIB
	FreeImage_DeInitialise();
#endif // FREEIMAGE_LIB

	return 0;
}