Exemple #1
0
int main(int argc,char* argv[]) {
    if(argc != 2 && argc != 3) {
        std::cerr << "Usage: path to the OFF file" << std::endl;
        throw 2;
    }
    
    if (argc == 3) {
        pre_simplified = true;
        collapse_file = argv[2];
    }
    printHelp();
	
	//Initialize GLUT
	FreeImage_Initialise();
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutCreateWindow("HW1: Meshes");
	init(argv[1]);

	glutDisplayFunc(shared::display);
	glutSpecialFunc(specialKey);
	glutKeyboardFunc(keyboard);
	glutReshapeFunc(reshape);
	glutReshapeWindow(w,h);
	
	glutMainLoop();	
	FreeImage_DeInitialise();

	return 0;
}
Exemple #2
0
int main(int argc,char* argv[]) {
	
	//Initialize GLUT
	FreeImage_Initialise();
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutCreateWindow("HW1: Transformations");
	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;
}
Exemple #3
0
void pre_lzw::do_lzw(const QDir & d){
    FreeImage_Initialise(true);
    QString label_out = "";
    QString dst = ui.lineEdit_2->text();
    QString d_src = d.path();
    QString serial_str = d_src.right(5);
    QDir dst_dir(dst);
    dst_dir.mkdir(serial_str);
    QString image_name = "", image_name_path(""), saved_name("");
    int dot_pos = 0;
    QFileInfoList handled_images = d.entryInfoList();
    QList<QFileInfo>::iterator images_iter = handled_images.begin();
    
    FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
    for(; images_iter < handled_images.end(); ++images_iter){
        image_name_path = (*images_iter).absoluteFilePath();
        if((*images_iter).isDir()){
            continue;
        }
        FIBITMAP *handled_image = 0;
        image_name = (*images_iter).fileName();
        dot_pos = image_name.indexOf(".");
        saved_name = dst + "\\" + serial_str + "\\" + image_name.left(dot_pos) + "_c.tif";
        label_out += saved_name + "\n";
        fif = FreeImage_GetFileType(image_name_path.toStdString().c_str());
        handled_image = FreeImage_Load(fif, image_name_path.toStdString().c_str());
        FreeImage_Save(FIF_TIFF, handled_image, saved_name.toStdString().c_str(), TIFF_LZW);
        FreeImage_Unload(handled_image);
    }
//    ui.label->setText(label_out);
    FreeImage_DeInitialise();

}
Exemple #4
0
void Film::output(string path){
  int maxIntensity = 255;
  int bpp = 24;
  RGBQUAD color;
  FreeImage_Initialise();
  FIBITMAP* bitmap = FreeImage_Allocate(sceneWidth,
					sceneHeight,
					bpp);
  for(int h = 0; h < sceneHeight; h++){
    vector<Color> row = pixelData[h];
    for(int w = 0; w < sceneWidth; w++){
      Color pixelColor = row[w];
      color.rgbRed = pixelColor.getR() * maxIntensity;
      color.rgbGreen = pixelColor.getG() * maxIntensity;
      color.rgbBlue = pixelColor.getB() * maxIntensity;
      FreeImage_SetPixelColor(bitmap, w, h, &color);
    }
  }
  if (FreeImage_Save(FIF_PNG, bitmap, path.c_str(), 0)) {
    cout << "Image saved to " << path << endl;
    cout << sceneWidth << endl;
  }
  else {
    cerr << "Couldn't save image to " << path << endl;
    exit(1);
  }

  FreeImage_DeInitialise();
}
void CoreImplementationWinSDL::init()
{
	// Load SDL
	assert(SDL_Init(SDL_INIT_VIDEO) == 0);

	FreeImage_Initialise();
}
TextureManager::TextureManager()
{
	// call this ONLY when linking with FreeImage as a static library
	#ifdef FREEIMAGE_LIB
		FreeImage_Initialise();
	#endif
}
Exemple #7
0
int main(int argc, char** argv)
{
    FreeImage_Initialise();

    gLua.init();
    gConfig.init();
    gDatabase.init();
    gLog.init();

    Window win;
    
    win.loadZoneModel(argc > 1 ? argv[1] : "gfaydark");
    
    for (;;)
    {
        gTimerPool.check();
        
        if (!win.mainLoop())
            break;
        
        gTemp.reset();
        Clock::sleepMilliseconds(25);
    }
    
    gLog.signalClose();
    gLog.waitUntilClosed();
    
    FreeImage_DeInitialise();
    return 0;
}
Exemple #8
0
void Client::init()
{
    initSDL();

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

    m_gui = GUI::instance();
    m_mainMenu = new MainMenu(this);
    m_mainMenu->showMainMenu();

    m_debugMenu = new DebugMenu(this);
    m_debugMenu->show();

    if (Settings::instance()->startupFlags() & Settings::PlayNowStartupFlag) {
        startMultiplayerHost("Dingo");
    }

//dws    std::stringstream ss;
//    ss << "Player";
//    std::random_device device;
//    std::mt19937 rand(device());
//    std::uniform_int_distribution<> distribution(0, INT_MAX);
//
//    ss << distribution(rand);
//
//    startMultiplayerHost(ss.str());
}
Exemple #9
0
static void loadFreeImageIfNeeded() {
	static bool free_image_loaded = false;
	if(!free_image_loaded) {
		FreeImage_Initialise();
		free_image_loaded = true;
	}
}
Exemple #10
0
void InitDLL(const char* dllname)
{
	if (!dllname || strlen(dllname) < 3)
			return;
	m_dll = LoadLibraryA(dllname);
	if (!m_dll)
	{
		DWORD err = GetLastError();
		ReportErrWithLastErr(err, "Load Library Failed!:%s", dllname);
		return ;
	}
	gCreateAIPtr = (CreateAIControl_FunPtr)GetProcAddress(m_dll, "CreateAIControl");
	if (!gCreateAIPtr)
	{
		DWORD err = GetLastError();
		ReportErrWithLastErr(err, "GetProcAddress!:CreateAIControl");
		return;
	}

	gDeleteAIPtr = (DeleteAIControl_FunPtr)GetProcAddress(m_dll, "DeleteAIControl");
	if (!gDeleteAIPtr)
	{
		DWORD err = GetLastError();
		ReportErrWithLastErr(err, "GetProcAddress!:DeleteAIControl");
		return;
	}

	gAIControl = gCreateAIPtr();

	FreeImage_Initialise();

}
Exemple #11
0
int 
main(int argc, char *argv[]) {

	char *input_filename = "images\\input.tif";
	char *output_filename = "images\\clone.tif";

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

	// initialize our own FreeImage error handler

	FreeImage_SetOutputMessage(MyMessageFunc);

	// Copy 'input.tif' to 'clone.tif'

	CloneMultiPage(FIF_TIFF, input_filename, output_filename, 0);

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

	return 0;
}
Exemple #12
0
int main(int argc, char* args[]) {
	
	/* Check arguments */
	if (argc <= 1) {
		std::cerr << "Error: No input files.\n";
		std::cin.get();
		return -1;
	}
	
	/* Initialize FreeImage */
	#ifdef FREEIMAGE_LIB
		FreeImage_Initialise();
	#endif
	std::cout << "Using FreeImage version " << FreeImage_GetVersion() << "\n";
	
	/* Convert all files */
	for (int i = 1; i < argc; i++) convert(args[i]);
	
	/* Deinitialize FreeImage */
	#ifdef FREEIMAGE_LIB
		FreeImage_DeInitialise();
	#endif
	std::cout << "\nFinished." << std::endl;
	
	/* Wait for input */
	std::cin.get();
	
	return 0;
}
Exemple #13
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 FreeImage error handler

	FreeImage_SetOutputMessage(MyMessageFunc);

	// print version & copyright infos

	cout << "FreeImage " << FreeImage_GetVersion() << "\n";
	cout << FreeImage_GetCopyrightMessage() << "\n\n";

	// Print input formats (including external plugins) known by the library
	fstream importFile("fif_import.csv", ios::out);
	PrintImportFormats(importFile);
	importFile.close();

	// Print output formats (including plugins) known by the library
	// for each export format, supported bitdepths are given
	fstream exportFile("fif_export.csv", ios::out);
	PrintExportFormats(exportFile);
	exportFile.close();

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

	return 0;

}
Exemple #14
0
TextureLoader::TextureLoader()
{
	if(initialised != true)
	{
		FreeImage_Initialise();
	}
}
Exemple #15
0
int main(int argc, char *argv[])
{
    //  initialize the GLUT library.
    glutInit(&argc, argv);
    // set the display mode
    glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DEPTH | GLUT_DOUBLE);
    // set the window size
    glutInitWindowSize(windowWidth, windowHeight);
    // creates a top-level window.
    glutCreateWindow("LengXuegang's Homework");
    // initialize the extension entry points
    GLenum error = glewInit();
    if (GLEW_OK != error)
    {
        fprintf(stderr, "Error: %s\n", glewGetErrorString(error));
        exit(-1);
    }

    FreeImage_Initialise(false);

    const char *version = FreeImage_GetVersion();
    fprintf(stdout, "version: %s", version);

    const char *copyright = FreeImage_GetCopyrightMessage();
    fprintf(stdout, "copyright: %s", copyright);

    initPrograms();

    GLint n = initVertex();
    if (n < 0)
    {
        fprintf(stderr, "init vertex failed");
        exit(-1);
    }

    GLint uModelMatrix = glGetUniformLocation(program->getProgramID(), "u_ModelMatrix");
    // GLint uMvpMatrix = glGetUniformLocation(program, "u_MvpMatrix");
    GLint uNormalMatrix = glGetUniformLocation(program->getProgramID(), "u_NormalMatrix");
    GLint uLightColor = glGetUniformLocation(program->getProgramID(), "u_LightColor");
    GLint uLightPosition = glGetUniformLocation(program->getProgramID(), "u_LightPosition");
    GLint uAmbientLight = glGetUniformLocation(program->getProgramID(), "u_AmbientLight");

    glUniform3f(uLightColor, 0.5, 0.9, 0.1);
    glUniform3f(uLightPosition, 1.0, 2.0, 3.0);
    glUniform3f(uAmbientLight, 0.6, 0.6, 0.6);

    // glUniformMatrix4fv(uModelMatrix, )
    // glUniformMatrix4fv(uNormalMatrix, )
    // sets the display callback for the current window.
    glutDisplayFunc(display);
    // sets the reshape callback for the current window.
    glutReshapeFunc(reshape);
    // sets the special keyboard callback for the current window.
    // glutSpecialFunc(specialKey);
    // enters the GLUT event processing loop.
    glutMainLoop();

    return 0;
}
painter::painter()
{
	boost::filesystem::create_directory(default_pic_path);
	FreeImage_Initialise();

	border_color = new RGBQUAD;
	border_color->rgbBlue = border_color->rgbGreen = border_color->rgbRed = 100;
}
Ogre::TexturePtr textureFromBytes(const QByteArray &ba,
                                  const std::string &name) {

  static bool fi_init = false;
  if (!fi_init) {
    FreeImage_Initialise();
  }

  void *data = const_cast<char *>(ba.data());
  FIMEMORY *mem =
      FreeImage_OpenMemory(reinterpret_cast<BYTE *>(data), ba.size());
  FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(mem, 0);
  if (fif == FIF_UNKNOWN) {
    FreeImage_CloseMemory(mem);
    throw std::runtime_error("Image format is not supported for loading");
  }
  FIBITMAP *bmp = FreeImage_LoadFromMemory(fif, mem, 0);
  FreeImage_CloseMemory(mem);
  if (!bmp) {
    throw std::runtime_error("Failed to decode image");
  }
  FIBITMAP *converted = FreeImage_ConvertTo24Bits(bmp);
  FreeImage_Unload(bmp);
  if (!converted) {
    throw std::runtime_error("Failed to convert image to 24 bit");
  }

  const unsigned w = FreeImage_GetWidth(converted);
  const unsigned h = FreeImage_GetHeight(converted);
  const unsigned data_size = w * h * 3;
  BYTE *image_data = FreeImage_GetBits(converted);

  ROS_INFO("Loading a %u x %u texture", w, h);

  //  create texture
  Ogre::TexturePtr texture;
  try {
    Ogre::DataStreamPtr data_stream;
    data_stream.bind(new Ogre::MemoryDataStream(image_data, data_size));

    const Ogre::String res_group =
        Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME;
    Ogre::TextureManager &texture_manager =
        Ogre::TextureManager::getSingleton();
    texture =
        texture_manager.loadRawData(name, res_group, data_stream, w, h,
                                    Ogre::PF_R8G8B8, Ogre::TEX_TYPE_2D, 0);
  }
  catch (...) {
    //  clean up FreeImage before re-throwing
    FreeImage_Unload(converted);
    throw;
  }

  return texture;
}
Exemple #18
0
/**
 * standard constructor of an fipImage object
 */
fipImage::fipImage(){
	
	if ( ! bFreeImageInitialised ){
		FreeImage_Initialise();
		bFreeImageInitialised = true;
	}
	ulImageInstances++;
	
	pImageData = NULL;
}
Exemple #19
0
/**
 * copy constructor
 *
 * @param inFipImage the fip image to copy
 */
fipImage::fipImage( const fipImage & inFipImage ){

	
	if ( ! bFreeImageInitialised ){
		FreeImage_Initialise();
		bFreeImageInitialised = true;
	}
	ulImageInstances++;

	pImageData = FreeImage_Clone( inFipImage.pImageData );
}
Exemple #20
0
	static void FreeImageInit()
	{
		static bool Init = false;

		if(!Init)
		{
			Init = true;
			FreeImage_Initialise(false);
			atexit(FreeImageFree);
		}
	}
//----------------------------------------------------------
ofImage::ofImage(const ofImage& mom) {

	if (!bFreeImageInited){
		FreeImage_Initialise();
		bFreeImageInited = true;
	}

	clear();
	clone(mom);
	update();
}
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();
	}
}
Exemple #24
0
//----------------------------------------------------------
ofImage::ofImage(const ofImage& mom) {
	myPixels.bAllocated			= false;

	if (!bFreeImageInited){
		FreeImage_Initialise();
		bFreeImageInited = true;
	}

	clear();
	clone(mom);
	update();
};
Exemple #25
0
int main(int argc, char *argv[])
{	
	//////////////////////////////////////////////////////////////////////////
	allegro_init(); // Initialize Allegro
	install_keyboard();
	set_close_button_callback(quit_function);
	FreeImage_Initialise(TRUE);

	create_cycles_table();

	Configuration cfg;
	cfg.Process(argc, argv);

	if (cfg.continue_processing)
	{
		quiet=true;
		rasta.Resume();
		rasta.cfg.continue_processing=true;
		quiet=false;
	}
	else
		rasta.SetConfig(cfg);

	screen_color_depth = desktop_color_depth();
	get_desktop_resolution(&desktop_width,&desktop_height);
	set_color_depth(screen_color_depth);

	if (!rasta.cfg.preprocess_only)
	{
		if (desktop_width>=320*3)
			set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320*3,480,0,0); 
		else
			set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480,0,0); // Change our graphics mode to 640x480

		set_display_switch_mode(SWITCH_BACKGROUND);
		set_close_button_callback(close_button_procedure);

		set_window_title(rasta.cfg.command_line.c_str());
	}
	else
		quiet=true;

	rasta.LoadAtariPalette();

	rasta.LoadInputBitmap();
	if (rasta.ProcessInit())
	{
		rasta.FindBestSolution();
		rasta.SaveBestSolution();
	}
	return 0; // Exit with no errors
}
/** constructor which can directly open the corresponding file */
Vt2IsoImageFreeImage_c::Vt2IsoImageFreeImage_c( const char* filename )
 : Vt2IsoImageBase_c( ), i_curScanLineY( -1 )
{
 if ( ! b_FreeImageLibInited )
 {
  b_FreeImageLibInited = true;
  FreeImage_Initialise();
 }
 if ( filename != NULL )
 {
  if ( openBitmap( filename ) ) getOptimalBwThreshold();
 }
}
Exemple #27
0
/**
 * parameter constructor of an fipImage object
 *
 * @param type the type of the image of the fipImage to create
 * @param ulWidth the width of the image (in points) of the fipImage
 * 	to create
 * @param ulHeight the height of the image (in points) of the fipImage
 * 	to create
 * @param uiBitsPerPixel the number of bits per pixel for the color of
 * 	the fipImage to create
 */
fipImage::fipImage( FREE_IMAGE_TYPE type, const unsigned long ulWidth,
		const unsigned long ulHeight, const unsigned int uiBitsPerPixel ){

	
	if ( ! bFreeImageInitialised ){
		FreeImage_Initialise();
		bFreeImageInitialised = true;
	}
	ulImageInstances++;
	
	pImageData = FreeImage_AllocateT( type, ulWidth, ulHeight, uiBitsPerPixel );

}
Exemple #28
0
bool graphics() {
	glfwSetErrorCallback(glfw_error);
	
	if(glfwInit() != GL_TRUE) {
		err("graphics", "could not");
		return false;
	}
	
	FreeImage_Initialise();
		
	glfw_state = 1;
	return true;
}
	//---------------------------------------------------------------------
	void FreeImageCodec::startup(void)
	{
		FreeImage_Initialise(false);

		LogManager::getSingleton().logMessage(
			LML_NORMAL,
			"FreeImage version: " + String(FreeImage_GetVersion()));
		LogManager::getSingleton().logMessage(
			LML_NORMAL,
			FreeImage_GetCopyrightMessage());

		// Register codecs
		StringUtil::StrStreamType strExt;
		strExt << "Supported formats: ";
		bool first = true;
		for (int i = 0; i < FreeImage_GetFIFCount(); ++i)
		{

			// Skip DDS codec since FreeImage does not have the option 
			// to keep DXT data compressed, we'll use our own codec
			if ((FREE_IMAGE_FORMAT)i == FIF_DDS)
				continue;
			
			String exts(FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i));
			if (!first)
			{
				strExt << ",";
			}
			first = false;
			strExt << exts;
			
			// Pull off individual formats (separated by comma by FI)
			StringVector extsVector = StringUtil::split(exts, ",");
			for (StringVector::iterator v = extsVector.begin(); v != extsVector.end(); ++v)
			{
				ImageCodec* codec = OGRE_NEW FreeImageCodec(*v, i);
				msCodecList.push_back(codec);
				Codec::registerCodec(codec);
			}
		}
		LogManager::getSingleton().logMessage(
			LML_NORMAL,
			strExt.str());

		// Set error handler
		FreeImage_SetOutputMessage(FreeImageErrorHandler);




	}
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;
}