Exemplo n.º 1
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;

}
Exemplo n.º 2
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;
}
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;
}
Exemplo n.º 4
0
	//---------------------------------------------------------------------
	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);




	}
Exemplo n.º 5
0
/**
 * Returns 1 (true) if the administrator is successfully initialized.
 * Must be called before using any method.
 */
bool IND_ImageManager::init() {
	end();
	initVars();

	g_debug->header("Initializing ImageManager", DebugApi::LogHeaderBegin);
	g_debug->header("Preparing ImageManager", DebugApi::LogHeaderOk);
	_ok = true;

	FreeImage_Initialise();
	const char* freeImageVer = FreeImage_GetVersion();
	const char* freeImageCopyright = FreeImage_GetCopyrightMessage();
	g_debug->header("Using FreeImage version: ",DebugApi::LogHeaderInfo);
	g_debug->dataChar(freeImageVer, true);
    g_debug->header("Copyright: ", DebugApi::LogHeaderInfo);
    g_debug->dataChar(freeImageCopyright, true);
	g_debug->header("ImageManager Initialised", DebugApi::LogHeaderEnd);
	
	//TODO: REGISTER ERROR HANDLERS FOR FREEIMAGE

	return _ok;
}
Exemplo n.º 6
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;
}
Exemplo n.º 7
0
MainWindow::MainWindow() : playerCosmetics(18), civilianCosmetics(12)
{
    QSettings::setDefaultFormat(QSettings::IniFormat);
    QCoreApplication::setOrganizationName("TEMP_ORG"); //TODO: Add a proper organization name.
    QCoreApplication::setOrganizationDomain("TEMP_ORG.com");
    QCoreApplication::setApplicationName("Driver Level Editor");

    levelHasChanged = false;
    d3dHasChanged = false;
    civCosHasChanged = false;
    playerCosHasChanged = false;
    civDentHasChanged = false;
    playerDentHasChanged = false;
    wdfHasChanged = false;

    mainLog.createLogfile("debug.txt");
    levelLog.createLogfile("levelDebug.txt");
    levelLog.setLogPriority(DEBUG_LEVEL_RIDICULOUS);
    level.setLogger(&levelLog);
    levelTextures.setTextureProvider(&level.textures);
    levelTextures.setD3D(&d3d);

    if(QDir("./settings").exists())
    {
        mainLog.Log("Settings folder exists in working directory, settings will be saved portably.");
        if(!QDir("./settings/User").exists())
            QDir().mkdir("./settings/User");
        if(!QDir("./settings/System").exists())
            QDir().mkdir("./settings/System");
        QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, "./settings/User");
        QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, "./settings/System");
    }
    else mainLog.Log("No settings folder found. Saving settings locally.");

#ifdef DEBUG_ENABLED
    mainLog.Log("Executable is a debug build.");
    setWindowTitle(QApplication::translate("windowtitle", "Driver Level Editor [DEBUG][*]"));
#else
    mainLog.Log("Executable is a release build.");
    setWindowTitle(QApplication::translate("windowtitle", "Driver Level Editor[*]"));
#endif

#ifdef FREEIMAGE_LIB
    mainLog.Log("FreeImage is static linked.");
	FreeImage_Initialise();
#endif
    FreeImageLogger = &mainLog;
    FreeImage_SetOutputMessage(FreeImageErrorHandler);
    mainLog.Log("FreeImage version: %s",FreeImage_GetVersion());
    mainLog.Log("%s",FreeImage_GetCopyrightMessage());

    mainLog.Log("Initializing widgets...");

    centralWindow = new QStackedWidget(this);
    startPage = new StartScreen(this);
    customLevelDialog = new CustomLevelDialog(this);
    aboutDialog = new AboutDialog(this);
    //TODO: Enter final about information
    aboutDialog->setDescription(tr("Description goes here!"));
    aboutDialog->setInformation(tr("Information goes here!"));
    aboutDialog->setThanks(tr("Thanks goes here!"));
    aboutDialog->setImage("data/about.png");

    modelViewPanel = new ModelViewPanel(this, NULL, 0, &mainLog);
    modelViewPanel->setLevel(&level);
    modelViewPanel->setTextureProvider(&levelTextures);

    definitionEditor = new TextureDefinitionEditor(this, modelViewPanel->glViewer()); //Don't forget, this needs a share widget when model viewing is done
    definitionEditor->setLevel(&level);
    definitionEditor->setTextureProvider(&levelTextures);
    definitionEditor->overlay()->makeCurrent();

    textureBrowser = new TextureBrowser(this, modelViewPanel->glViewer());
    textureBrowser->setLevel(&level);
    textureBrowser->setTextureList(&levelTextures);
    textureBrowser->setD3D(&d3d);

    levelLoader = new LevelLoadingDialog(this);
    levelLoader->setLevel(&level);
    levelLoader->setD3D(&d3d);
    levelLoader->setWheelDefinitions(&wheels);
    levelLoader->setPlayerCosmetics(&playerCosmetics);
    levelLoader->setCivilianCosmetics(&civilianCosmetics);
    levelLoader->setPlayerDenting(&playerDenting);
    levelLoader->setCivilianDenting(&civilianDenting);
    levelLoader->setLog(&mainLog);

    saveDialog = new SaveAsDialog(this);
    connect(saveDialog, SIGNAL(saveLevel(QString,unsigned int)), this, SLOT(saveLevel(QString,unsigned int)));
    connect(saveDialog, SIGNAL(saveD3D(QString)), this, SLOT(saveD3D(QString)));
    connect(saveDialog, SIGNAL(savePlayerDenting(QString)), this, SLOT(savePlayerDenting(QString)));
    connect(saveDialog, SIGNAL(saveCivilianDenting(QString)), this, SLOT(saveCivilianDenting(QString)));
    connect(saveDialog, SIGNAL(savePlayerCosmetics(QString)), this, SLOT(savePlayerCosmetics(QString)));
    connect(saveDialog, SIGNAL(saveCivilianCosmetics(QString)), this, SLOT(saveCivilianCosmetics(QString)));
    connect(saveDialog, SIGNAL(saveWheelDefinitions(QString)), this, SLOT(saveWheelDefinitions(QString)));

    createActions();
    createMenus();
    textureBrowser->setupEditMenu(editMenu);
    setConvenienceActionsEnabled(false);

    centralWindow->addWidget(startPage);
    centralWindow->addWidget(modelViewPanel);
    centralWindow->addWidget(textureBrowser);
    centralWindow->addWidget(definitionEditor);
    statusBar();
    setCentralWidget(centralWindow);

    mainLog.Log("Finished initializing widgets.");

    loadSettings();
    show();
};
Exemplo n.º 8
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_GetVersion());
	printf("\n");
	printf(FreeImage_GetCopyrightMessage());
	printf("\n");


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

	// initialize your own IO functions

	FreeImageIO io;

	io.read_proc  = myReadProc;
	io.write_proc = myWriteProc;
	io.seek_proc  = mySeekProc;
	io.tell_proc  = myTellProc;

	FILE *file = fopen(argv[1], "rb");

	if (file != NULL) {
		// find the buffer format
		FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromHandle(&io, (fi_handle)file, 0);

		if(fif != FIF_UNKNOWN) {
			// load from the file handle
			FIBITMAP *dib = FreeImage_LoadFromHandle(fif, &io, (fi_handle)file, 0);

			// save the bitmap as a PNG ...
			const char *output_filename = "test.png";

			// first, check the output format from the file name or file extension
			FREE_IMAGE_FORMAT out_fif = FreeImage_GetFIFFromFilename(output_filename);

			if(out_fif != FIF_UNKNOWN) {
				// then save the file
				FreeImage_Save(out_fif, dib, output_filename, 0);
			}

			// free the loaded FIBITMAP
			FreeImage_Unload(dib);
		}
		fclose(file);
	}

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

	return 0;
}
Exemplo n.º 9
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
	std::cout << "FreeImage version : " << FreeImage_GetVersion() << "\n"
	          << FreeImage_GetCopyrightMessage() << std::endl;

	if (argc < 4) {
		std::cerr << "Usage: taskcollector.exe <type> <width> <height> <outputfile> <inputfile1> [<input file2> ...]\n";
		return -1;
	}

	std::unique_ptr<TaskCollector> taskCollector;

	std::string command{argv[1]};
	if (command == "add") {
		taskCollector = std::make_unique<AddTaskCollector>();
	}
	else if (command == "paste") {
		taskCollector = std::make_unique<PasteTaskCollector>();
	}
	else {
		std::cerr << "Unknown command '" << command << "'. Allowed: 'add', 'paste'.\n";
		return -1;
	}
	taskCollector->set_width(std::stoi(argv[2]));
	taskCollector->set_height(std::stoi(argv[3]));
	//to be sure the ordering is proper
	std::sort(argv + 5, argv + argc);

	for (int i = 5; i < argc; ++i) {
		if (std::string(argv[i]).find("Alpha") == std::string::npos) {
			if (!taskCollector->addImgFile(argv[i])) {
				std::cerr << "Can't add file: " << argv[i] << "\n";
			}
		}
		else {
			if (!taskCollector->addAlphaFile(argv[i])) {
				std::cerr << "Can't add file: " << argv[i] << "\n";
			}
		}
	}

	std::string name{argv[4]};
	auto it = name.find_last_of('.');
	name = ( (it == std::string::npos) ? (name + ".exr") : (name.substr(0, it) + ".Alpha.exr") );

  bool saved = taskCollector->finalizeAndSave(argv[4]);
	// call this ONLY when linking with FreeImage as a static library
#ifdef FREEIMAGE_LIB
	FreeImage_DeInitialise();
#endif // FREEIMAGE_LIB
  if (saved)
    return 0;
  else
    return 1;
}
Exemplo n.º 10
0
QString ImageLoaderFreeImage::libraryAboutText() const
{
    return QLatin1String(FreeImage_GetCopyrightMessage());
}
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 < 4)  {
		printf("Usage: taskcollector.exe <type> <outputfile> <inputfile1> [<input file2> ...]\n");
		return -1;
	}

	TaskCollector *taskCollector;

	if (strcmp(argv[1], "pbrt") == 0) {
		taskCollector = &(PbrtTaskCollector());
	} else if (strcmp(argv[1], "mr") == 0) {
		taskCollector = &(MentalRayTaskCollector());
	} else {
		printf("Possible types: 'mr', 'pbrt'\n");
		return -1;
	}


	for (int i = 3; i < argc; i++) {
		if (! taskCollector->addImgFile(argv[i])) {
			printf("Can't add file: %s\n", argv[i]);
		}
	}
	/*char text[14];
	sprintf_s(text, (size_t) 14, "temp0000%d.exr", 1);
	printf("%s\n", text);
	for (int i = 0; i < 10; i++) {
		sprintf_s(text, 14, "temp0000%d.exr", i);
		printf("%s\n", text);
		if (! pbrtTC.addImgFile(text)) {
			printf("appendTask error %s\n", text);
		}
	}
	for (int i = 10; i < 60; i++) {
		sprintf_s(text, 14, "temp000%d.exr", i);
		printf("%s\n", text);
		if (! pbrtTC.addImgFile(text)) {
			printf("appendTask error %s\n", text);
		}
	}
	*/

	FIBITMAP *finalImage = taskCollector->finalize();
	taskCollector->finalizeAndSave(argv[2]); 

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

	return 0;
}