您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FreeImage_GetFIFFromFilename函数代码示例

51自学网 2021-06-01 20:48:24
  C++
这篇教程C++ FreeImage_GetFIFFromFilename函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中FreeImage_GetFIFFromFilename函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeImage_GetFIFFromFilename函数的具体用法?C++ FreeImage_GetFIFFromFilename怎么用?C++ FreeImage_GetFIFFromFilename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了FreeImage_GetFIFFromFilename函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: storeFreeImage

  void storeFreeImage(const Ref<Image>& img, const FileName& fileName)  {      FIBITMAP* dib = FreeImage_Allocate((int)img->width, (int)img->height, 24);      for(size_t y = 0; y < img->height; y++)      {          for(size_t x = 0; x < img->width; x++)          {			  Color4 c = img->get(x, y);                            RGBQUAD Value = {0};              Value.rgbRed   = (BYTE)(clamp(c.r) * 255.0f);              Value.rgbGreen = (BYTE)(clamp(c.g) * 255.0f);              Value.rgbBlue  = (BYTE)(clamp(c.b) * 255.0f);              FreeImage_SetPixelColor(dib, (unsigned int)x, (unsigned int)y, &Value);          }      }      FIBITMAP* fiLogo = loadWatermark();      unsigned int LogoWidth  = FreeImage_GetWidth (fiLogo);      unsigned int LogoHeight = FreeImage_GetHeight(fiLogo);      if(LogoWidth > img->width || LogoHeight > img->height)      {          FreeImage_Unload(fiLogo);          FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(fileName.c_str());          if(FreeImage_FIFSupportsWriting(fif))              FreeImage_Save(fif, dib, fileName.c_str());          FreeImage_Unload(dib);      }      else      {          int x_pos = (int)img->width  - LogoWidth;          int y_pos = (int)img->height - LogoHeight;          FIBITMAP* fiFG = FreeImage_Allocate((int)img->width, (int)img->height, 32);          BOOL b = FreeImage_Paste(fiFG, fiLogo, x_pos, y_pos, 255);          FreeImage_Unload(fiLogo);          FIBITMAP* fiNew = FreeImage_Composite(fiFG, FALSE, NULL, dib);          FreeImage_Unload(dib);          FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(fileName.c_str());          int save_flags = 0;          if(fif == FIF_JPEG)              save_flags = JPEG_QUALITYSUPERB | JPEG_BASELINE | JPEG_OPTIMIZE;          if(FreeImage_FIFSupportsWriting(fif))              FreeImage_Save(fif, fiNew, fileName.c_str(), save_flags);          FreeImage_Unload(fiNew);      }  }
开发者ID:remledevries,项目名称:Theseus-2.4,代码行数:58,


示例2: FreeImage_GetFileType

		GLubyte* Texture::loadToBitmap(std::string path, bool flip)		{			const char* pathCStr = path.c_str();			FREE_IMAGE_FORMAT format = FIF_UNKNOWN;			format = FreeImage_GetFileType(pathCStr);			if (format == FIF_UNKNOWN)				format = FreeImage_GetFIFFromFilename(pathCStr);			if (format == FIF_UNKNOWN) {				std::cout << "Failed to load image at " << pathCStr << std::endl;				return nullptr;			}			if (!FreeImage_FIFSupportsReading(format))			{				std::cout << "Detected image format cannot be read! " << pathCStr << std::endl;				return nullptr;			}			m_bitmap = FreeImage_Load(format, pathCStr);			if (flip)				FreeImage_FlipVertical(m_bitmap);			GLint bitsPerPixel = FreeImage_GetBPP(m_bitmap);			if (bitsPerPixel == 32)				m_bitmap32 = m_bitmap;			else				m_bitmap32 = FreeImage_ConvertTo32Bits(m_bitmap);			m_width = FreeImage_GetWidth(m_bitmap32);			m_height = FreeImage_GetHeight(m_bitmap32);			return FreeImage_GetBits(m_bitmap32);		}
开发者ID:Christopherbikie,项目名称:Bipolar,代码行数:33,


示例3: LoadTexture

bool LoadTexture(const char* filename,	//where to load the file from	GLuint &texID,	//does not have to be generated with glGenTextures	GLenum image_format,		//format the image is in	GLint internal_format,		//format to store the image in	GLint level ,					//mipmapping level	GLint border ) {	//image format	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;	//pointer to the image, once loaded	FIBITMAP *dib(0);	//pointer to the image data	BYTE* bits(0);	//image width and height	unsigned int width(0), height(0);	//check the file signature and deduce its format	fif = FreeImage_GetFileType(filename, 0);	//if still unknown, try to guess the file format from the file extension	if (fif == FIF_UNKNOWN)		fif = FreeImage_GetFIFFromFilename(filename);	//if still unkown, return failure	if (fif == FIF_UNKNOWN)		return false;	//check that the plugin has reading capabilities and load the file	if (FreeImage_FIFSupportsReading(fif))		dib = FreeImage_Load(fif, filename);	//if the image failed to load, return failure	if (!dib)		return false;	//retrieve the image data	bits = FreeImage_GetBits(dib);	//get the image width and height	width = FreeImage_GetWidth(dib);	height = FreeImage_GetHeight(dib);	//if this somehow one of these failed (they shouldn't), return failure	if ((bits == 0) || (width == 0) || (height == 0))		return false;	//generate an OpenGL texture ID for this texture	glGenTextures(1, &texID);	//store the texture ID mapping	//bind to the new texture ID		glBindTexture(GL_TEXTURE_2D, texID);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);	// 线形滤波	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);   // 线形滤波	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);																		//store the texture data for OpenGL use	glTexImage2D(GL_TEXTURE_2D, level, internal_format, width, height,		border, image_format, GL_UNSIGNED_BYTE, bits);	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);	//Free FreeImage's copy of the data	FreeImage_Unload(dib);	//return success	return true;}
开发者ID:abucraft,项目名称:opengl-balls,代码行数:60,


示例4: FreeImage_GetFIFFromFilename

BOOL fipImage::save(const char* lpszPathName, int flag) const {	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;	BOOL bSuccess = FALSE;	// Try to guess the file format from the file extension	fif = FreeImage_GetFIFFromFilename(lpszPathName);	if(fif != FIF_UNKNOWN ) {		// Check that the dib can be saved in this format		BOOL bCanSave;		FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(_dib);		if(image_type == FIT_BITMAP) {			// standard bitmap type			WORD bpp = FreeImage_GetBPP(_dib);			bCanSave = (FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp));		} else {			// special bitmap type			bCanSave = FreeImage_FIFSupportsExportType(fif, image_type);		}		if(bCanSave) {			bSuccess = FreeImage_Save(fif, _dib, lpszPathName, flag);			return bSuccess;		}	}	return bSuccess;}
开发者ID:MrMasterplan,项目名称:PIC-stuff,代码行数:27,


示例5: _tmain

int _tmain(int argc, _TCHAR* argv[]){	const char* filename = "1.jpg";	FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(filename, 0);	FIBITMAP *dib(0);	//pointer to the image data	BYTE* bits(0);	//image width and height	unsigned int width(0), height(0);	if(fif == FIF_UNKNOWN) 		fif = FreeImage_GetFIFFromFilename(filename);	if(fif == FIF_UNKNOWN)		return 1;	if(FreeImage_FIFSupportsReading(fif))		dib = FreeImage_Load(fif, filename);	//retrieve the image data	bits = FreeImage_GetBits(dib);	//get the image width and height	width = FreeImage_GetWidth(dib);	height = FreeImage_GetHeight(dib);	//if this somehow one of these failed (they shouldn't), return failure	if((bits == 0) || (width == 0) || (height == 0))		return 1;	return 0;}
开发者ID:skatebill,项目名称:MyEngineVersion3,代码行数:29,


示例6: FreeImage_GetFIFFromFilename

bool RGBAImage::WriteToFile(const char* filename){	const FREE_IMAGE_FORMAT fileType = FreeImage_GetFIFFromFilename(filename);	if(FIF_UNKNOWN == fileType)	{		printf("Can't save to unknown filetype %s/n", filename);		return false;	}	FIBITMAP* bitmap = FreeImage_Allocate(Width, Height, 32, 0x000000ff, 0x0000ff00, 0x00ff0000);	if(!bitmap)	{		printf("Failed to create freeimage for %s/n", filename);		return false;	}	const unsigned int* source = Data;	for( int y=0; y < Height; y++, source += Width )	{		unsigned int* scanline = (unsigned int*)FreeImage_GetScanLine(bitmap, Height - y - 1 );		memcpy(scanline, source, sizeof(source[0]) * Width);	}	FreeImage_SetTransparent(bitmap, true);	FIBITMAP* converted = FreeImage_ConvertTo24Bits(bitmap);	const bool result = !!FreeImage_Save(fileType, converted, filename);	if(!result)		printf("Failed to save to %s/n", filename);	FreeImage_Unload(converted);	FreeImage_Unload(bitmap);	return result;}
开发者ID:shakyShane,项目名称:p-diff,代码行数:35,


示例7: ofLog

//----------------------------------------------------------------void  ofImage::saveImageFromPixels(string fileName, ofPixels &pix){	if (pix.bAllocated == false){		ofLog(OF_LOG_ERROR,"error saving image - pixels aren't allocated");		return;	}	#ifdef TARGET_LITTLE_ENDIAN		if (pix.bytesPerPixel != 1) swapRgb(pix);	#endif	FIBITMAP * bmp	= getBmpFromPixels(pix);	#ifdef TARGET_LITTLE_ENDIAN		if (pix.bytesPerPixel != 1) swapRgb(pix);	#endif	fileName = ofToDataPath(fileName);	if (pix.bAllocated == true){		FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;		fif = FreeImage_GetFileType(fileName.c_str(), 0);		if(fif == FIF_UNKNOWN) {			// or guess via filename			fif = FreeImage_GetFIFFromFilename(fileName.c_str());		}		if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {			FreeImage_Save(fif, bmp, fileName.c_str(), 0);		}	}	if (bmp != NULL){		FreeImage_Unload(bmp);	}}
开发者ID:andyli,项目名称:openFrameworks,代码行数:35,


示例8: dib

bool CTexture::loadTexture2D(std::string sTexturePath, bool bGenerateMipMaps){	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;	FIBITMAP* dib(0);	fif = FreeImage_GetFileType(sTexturePath.c_str(), 0); // 检查文件签名,推导其格式	if(fif == FIF_UNKNOWN) fif = FreeImage_GetFIFFromFilename(sTexturePath.c_str()); 	// 从扩展名猜测格式	if(fif == FIF_UNKNOWN) return false;	//clock_t begin = clock();	if(FreeImage_FIFSupportsReading(fif)) dib = FreeImage_Load(fif, sTexturePath.c_str());	if(!dib) return false;	//clock_t end = clock();	//cout << end - begin << endl;			GLubyte* bDataPointer = FreeImage_GetBits(dib);	if(bDataPointer == NULL || FreeImage_GetWidth(dib) == 0 || FreeImage_GetHeight(dib) == 0)		return false;	GLenum format = FreeImage_GetBPP(dib) == 24 ? GL_BGR : FreeImage_GetBPP(dib) == 8 ? GL_LUMINANCE : 0;	createFromData(bDataPointer, 		FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), FreeImage_GetBPP(dib), format, bGenerateMipMaps);	FreeImage_Unload(dib);	m_sTexturePath = sTexturePath;	return true;}
开发者ID:suliutree,项目名称:PanoramaBroadcast,代码行数:28,


示例9: rb_graffik_open

VALUE rb_graffik_open(VALUE self, VALUE rb_filename) {  char *filename = STR2CSTR(rb_filename);  FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;    // Try various methods to thet the image format  fif = FreeImage_GetFileType(filename, 0);  if (fif == FIF_UNKNOWN) {    fif = FreeImage_GetFIFFromFilename(filename);  }    if ((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {    int flags = ((fif == FIF_JPEG) ? JPEG_ACCURATE : 0);    // Load the image from disk    FIBITMAP *image = FreeImage_Load(fif, filename, flags);    // Develop an instance for Ruby    VALUE instance = Data_Wrap_Struct(self, NULL, NULL, image);    // Store the image type as a FixNum    rb_iv_set(instance, "@file_type", INT2FIX(fif));        // If a block is given, yield to it, if not, return the instance    if (rb_block_given_p()) {      return rb_ensure(rb_yield, instance, rb_graffik_close, instance);    } else {      return instance;    }  }    // If we couldn't load it, throw and error  rb_raise(rb_eTypeError, "Unknown file format");}
开发者ID:jeremyboles,项目名称:graffik,代码行数:30,


示例10: dib

bool CTexture::loadTexture2D(string a_sPath, bool bGenerateMipMaps){	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;	FIBITMAP* dib(0);	fif = FreeImage_GetFileType(a_sPath.c_str(), 0); // Check the file signature and deduce its format	if(fif == FIF_UNKNOWN) // If still unknown, try to guess the file format from the file extension		fif = FreeImage_GetFIFFromFilename(a_sPath.c_str());		if(fif == FIF_UNKNOWN) // If still unknown, return failure		return false;	if(FreeImage_FIFSupportsReading(fif)) // Check if the plugin has reading capabilities and load the file		dib = FreeImage_Load(fif, a_sPath.c_str());	if(!dib)		return false;	BYTE* bDataPointer = FreeImage_GetBits(dib); // Retrieve the image data	// If somehow one of these failed (they shouldn't), return failure	if(bDataPointer == NULL || FreeImage_GetWidth(dib) == 0 || FreeImage_GetHeight(dib) == 0)		return false;	GLenum format = FreeImage_GetBPP(dib) == 24 ? GL_BGR : FreeImage_GetBPP(dib) == 8 ? GL_LUMINANCE : 0;	createFromData(bDataPointer, FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), FreeImage_GetBPP(dib), format, bGenerateMipMaps);		FreeImage_Unload(dib);	sPath = a_sPath;	return true; // Success}
开发者ID:yumikokh,项目名称:bado,代码行数:33,


示例11: width

bool TextureManager::LoadTexture(const char *filename, const unsigned int texID, bool generate, GLenum target,                                 GLenum image_format, GLint internal_format, GLint level, GLint border) {  // image format  FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;  // pointer to the image, once loaded  FIBITMAP *dib(0);  // pointer to the image data  BYTE *bits(0);  // image width and height  unsigned int width(0), height(0);  // OpenGL's image ID to map to  GLuint gl_texID;  // check the file signature and deduce its format  fif = FreeImage_GetFileType(filename, 0);  // if still unknown, try to guess the file format from the file extension  if (fif == FIF_UNKNOWN)    fif = FreeImage_GetFIFFromFilename(filename);  // if still unkown, return failure  if (fif == FIF_UNKNOWN)    return false;  // check that the plugin has reading capabilities and load the file  if (FreeImage_FIFSupportsReading(fif))    dib = FreeImage_Load(fif, filename);  // if the image failed to load, return failure  if (!dib)    return false;  // retrieve the image data  bits = FreeImage_GetBits(dib);  // get the image width and height  width = FreeImage_GetWidth(dib);  height = FreeImage_GetHeight(dib);  // if this somehow one of these failed (they shouldn't), return failure  if ((bits == 0) || (width == 0) || (height == 0))    return false;  // if this texture ID is in use, unload the current texture  if (m_texID.find(texID) != m_texID.end())    glDeleteTextures(1, &(m_texID[texID]));  if (generate) {    // generate an OpenGL texture ID for this texture    glGenTextures(1, &gl_texID);    // store the texture ID mapping    m_texID[texID] = gl_texID;    // bind to the new texture ID    glBindTexture(target, gl_texID);  }  // store the texture data for OpenGL use  glTexImage2D(target, level, internal_format, width, height, border, image_format, GL_UNSIGNED_BYTE, bits);  // Free FreeImage's copy of the data  FreeImage_Unload(dib);  // return success  return true;}
开发者ID:dooglz,项目名称:Celestial-Drift,代码行数:60,


示例12: FreeImage_GetFileType

	Texture::Texture(const char* file) {		FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;		FIBITMAP* dib = nullptr;		fif = FreeImage_GetFileType(file, 0);		if (fif == FIF_UNKNOWN)			fif = FreeImage_GetFIFFromFilename(file);		if (fif != FIF_UNKNOWN) {			if (FreeImage_FIFSupportsReading(fif))				dib = FreeImage_Load(fif, file);			BYTE* pixels = FreeImage_GetBits(dib);			int width = FreeImage_GetWidth(dib);			int height = FreeImage_GetHeight(dib);			int bits = FreeImage_GetBPP(dib);			int size = width * height * (bits / 8);			BYTE* result = new BYTE[size];			memcpy(result, pixels, size);			FreeImage_Unload(dib);			glGenTextures(1, &m_ID);			glBindTexture(GL_TEXTURE_2D, m_ID);			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, result ? result : NULL);			glBindTexture(GL_TEXTURE_2D, 0);		}		else {			m_ID = -1;		}	}
开发者ID:Jacob-Mango,项目名称:ME-Engine,代码行数:27,


示例13: GenericWriter

/** Generic image writer@param dib Pointer to the dib to be saved@param lpszPathName Pointer to the full file name@param flag Optional save flag constant@return Returns true if successful, returns false otherwise*/bool GenericWriter(const bitmap_ptr& dib, const std::string& lpszPathName, int flag) {	auto fif = FIF_UNKNOWN;	auto bSuccess = FALSE;	// check if file path is not empty	if (lpszPathName.empty())		return false;	if (dib) {		// try to guess the file format from the file extension		fif = FreeImage_GetFIFFromFilename(lpszPathName.c_str());		if (fif != FIF_UNKNOWN) {			// check that the plugin has sufficient writing and export capabilities ...			if (FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportType(fif, FreeImage_GetImageType(dib.get()))) {				// ok, we can save the file				bSuccess = FreeImage_Save(fif, dib.get(), lpszPathName.c_str(), flag);				// unless an abnormal bug, we are done !			}			else {				std::cout << "Can't save file" << lpszPathName << std::endl;			}		}    else {      std::cerr << "Can't determine output file type" << std::endl;    }	}	return (bSuccess == TRUE);}
开发者ID:imapp-pl,项目名称:gnr-taskcollector,代码行数:32,


示例14: FreeImage_GetFileType

BOOL fipImage::load(const char* lpszPathName, int flag) {	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;	// check the file signature and get its format	// (the second argument is currently not used by FreeImage)	fif = FreeImage_GetFileType(lpszPathName, 0);	if(fif == FIF_UNKNOWN) {		// no signature ?		// try to guess the file format from the file extension		fif = FreeImage_GetFIFFromFilename(lpszPathName);	}	// check that the plugin has reading capabilities ...	if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {		// Free the previous dib		if(_dib) {			FreeImage_Unload(_dib);					}		// Load the file		_dib = FreeImage_Load(fif, lpszPathName, flag);		_bHasChanged = TRUE;		if(_dib == NULL)			return FALSE;		return TRUE;	}	return FALSE;}
开发者ID:MrMasterplan,项目名称:PIC-stuff,代码行数:26,


示例15: FREEIMAGE_LoadImage

	FREEIMAGE_BMP*	FREEIMAGE_LoadImage(const UString& filePath)	{		FREEIMAGE_BMP* vix_bmp = new FREEIMAGE_BMP;		vix_bmp->path = filePath;		vix_bmp->name = getFileName(filePath);		vix_bmp->format = FREEIMAGE_FormatFromExtension(getFileExtension(filePath, false));		vix_bmp->data = NULL;		vix_bmp->bitmap = NULL;		/*Here we must */				//Check file signature and deduce format#ifdef UNICODE		vix_bmp->format = FreeImage_GetFileTypeU(filePath.c_str());#else		vix_bmp->format = FreeImage_GetFileType(filePath.c_str());#endif		if (vix_bmp->format == FIF_UNKNOWN) {#ifdef UNICODE			vix_bmp->format = FreeImage_GetFIFFromFilenameU(filePath.c_str());#else			vix_bmp->format = FreeImage_GetFIFFromFilename(filePath.c_str());#endif		}					//if still unknown, return NULL;		if (vix_bmp->format == FIF_UNKNOWN)			return NULL;		//Check if FreeImage has reading capabilities		if (FreeImage_FIFSupportsReading(vix_bmp->format)) {#ifdef UNICODE			//read image into struct pointer			vix_bmp->bitmap = FreeImage_LoadU(vix_bmp->format, filePath.c_str());#else			vix_bmp->bitmap = FreeImage_Load(vix_bmp->format, filePath.c_str());#endif					}		//If image failed to load, return NULL		if (!vix_bmp->bitmap)			return NULL;		FreeImage_FlipVertical(vix_bmp->bitmap);		//Retrieve image data		vix_bmp->data = FreeImage_GetBits(vix_bmp->bitmap);		//Retrieve image width		vix_bmp->header.width = FreeImage_GetWidth(vix_bmp->bitmap);		//Retrieve image height		vix_bmp->header.height = FreeImage_GetHeight(vix_bmp->bitmap);		if (vix_bmp->data == 0 || vix_bmp->header.width == 0 || vix_bmp->header.height == 0)			return NULL;		//return bitmap		return vix_bmp;	}
开发者ID:eric-fonseca,项目名称:Throw-Things-at-Monsters,代码行数:59,


示例16: glLoadTexture

	///////////////////////////////////////////////////////////////////////////	///	/// @fn bool glLoadTexture(const std::string& nomFichier, unsigned int& idTexture,	///                        bool genererTexture)	///	/// Cette fonction crée une texture OpenGL à partir d'une image contenu	/// dans un fichier.  FreeImage est utilisée pour lire l'image, donc tous	/// les formats reconnues par cette librairie devraient être supportés.	///	/// @param[in]  nomFichier     : Le nom du fichier image à charger.	/// @param[out] idTexture      : L'identificateur de la texture créée.	/// @param[in]  genererTexture : Doit-on demander à OpenGL de générer un numéro	///										de texture au préalable?	///	/// @return Vrai si le chargement a réussi, faux autrement.	///	///////////////////////////////////////////////////////////////////////////	bool glLoadTexture(const std::string& nomFichier, unsigned int& idTexture, bool genererTexture)	{		// Ce code de lecture générique d'un fichier provient de la		// documentation de FreeImage		FREE_IMAGE_FORMAT format = FIF_UNKNOWN;		// check the file signature and deduce its format		// (the second argument is currently not used by FreeImage)		format = FreeImage_GetFileType(nomFichier.c_str(), 0);		if(format == FIF_UNKNOWN) {			// no signature ?			// try to guess the file format from the file extension			format = FreeImage_GetFIFFromFilename(nomFichier.c_str());		}		// check that the plugin has reading capabilities ...		if((format == FIF_UNKNOWN) || !FreeImage_FIFSupportsReading(format)) {			utilitaire::afficherErreur(				std::string("Format du fichier image /"") +				std::string(nomFichier.c_str()) + std::string("/" non supporté")				);			return false;		}		// ok, let's load the file		FIBITMAP* dib = FreeImage_Load(format, nomFichier.c_str(), 0);		if (dib == 0) {			utilitaire::afficherErreur(				std::string("Erreur à la lecture du fichier /"") +				std::string(nomFichier.c_str()) + std::string("/"")				);			return false;		}		FIBITMAP* dib32 = FreeImage_ConvertTo32Bits(dib);		if (dib32 == 0) {			utilitaire::afficherErreur(				std::string("Incapable de convertir le fichier /"") +				std::string(nomFichier.c_str()) + std::string("/" en 32 bpp.")				);			FreeImage_Unload(dib);			return false;		}		int pitch = FreeImage_GetPitch(dib32);		glCreateTexture(			FreeImage_GetBits(dib32),			FreeImage_GetWidth(dib32),			FreeImage_GetHeight(dib32),			FreeImage_GetBPP(dib32),			FreeImage_GetPitch(dib32),			idTexture,			genererTexture			);		FreeImage_Unload(dib32);		FreeImage_Unload(dib);		return true;	}
开发者ID:gravufo,项目名称:MLGHockey,代码行数:76,


示例17: FreeImage_GetFIFFromFilename

unsigned char * HVSTGFX::loadImageFile(char *fileName, HVSTGFX::IMAGEFILE * imgFile,  GLuint &texture){	//FREE_IMAGE_FORMAT fif = FIF_PNG;	FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(fileName);	//pointer to the image data	unsigned char* bits;	unsigned char tempRGB;	GLuint tempTex = 0;	GLenum errCode;	const unsigned char *errString;	bool error = false;	std::string file(fileName);		if(FreeImage_FIFSupportsReading(fif))		imgFile->dib = FreeImage_Load(fif, fileName);		if(!imgFile->dib)	{		glbl->debugger->writeString("failed to open sprite " + *fileName);		return NULL;	}	bits = FreeImage_GetBits(imgFile->dib);	imgFile->width = FreeImage_GetWidth(imgFile->dib); imgFile->height = FreeImage_GetHeight(imgFile->dib);	imgFile->size = sizeof(bits);	int size = imgFile->width*imgFile->height;//(FreeImage_GetWidth(dib) * FreeImage_GetHeight(dib));	for (int imageIDx = 0; imageIDx < size * 4; imageIDx += 4)	{		tempRGB = bits[imageIDx];		bits[imageIDx] = bits[imageIDx + 2];		bits[imageIDx + 2] = tempRGB;	}		glGenTextures(1, &tempTex);	texture = tempTex;		errCode = glGetError();	if (errCode != GL_NO_ERROR)	{		MessageBox(NULL, _T("Unable to detect OpenGL support. Check if you have your graphics driver installed, or if your graphics card supports OpenGL."), NULL, NULL);	}	glBindTexture(GL_TEXTURE_2D, texture);		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imgFile->width, imgFile->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bits);		//FreeImage_Unload(dib);	#ifdef _DEBUG	if (!error)		glbl->debugger->writeString("successfully loaded sprite " + file + "/n");#endif	return bits;}
开发者ID:MGZero,项目名称:Harvest,代码行数:59,


示例18: FreeImage_GetFIFFromFilename

void rtgu::image_io::write_image(char const* filename, any_image const& image){  FREE_IMAGE_FORMAT fi_image_format = FreeImage_GetFIFFromFilename(filename);  FIBITMAP* fi_image = detail::get_FIBITMAP(image);  BOOL result = FreeImage_Save(fi_image_format, fi_image, filename);}
开发者ID:rotoglup,项目名称:rotoglup-scratchpad,代码行数:8,


示例19: SaveImage

/////  Save an image using the FreeImage library//bool SaveImage(char *fileName, char *buffer, int width, int height){    FREE_IMAGE_FORMAT format = FreeImage_GetFIFFromFilename(fileName);    FIBITMAP *image = FreeImage_ConvertFromRawBits((BYTE*)buffer, width,                        height, width * 4, 32,                        0xFF000000, 0x00FF0000, 0x0000FF00);    return (FreeImage_Save(format, image, fileName) == TRUE) ? true : false;}
开发者ID:Haiyang21,项目名称:toolsCL,代码行数:11,


示例20: lfi_getFIFFromFilename

/* * Arguments: path (string) * Returns: image_format (string) */static intlfi_getFIFFromFilename (lua_State *L){  const char *path = luaL_checkstring(L, 1);  FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(path);  return lfi_pushoption(L, fif, lfi_format_values, lfi_format_names);}
开发者ID:jlsandell,项目名称:luafreeimage,代码行数:12,


示例21: bits

	unsigned char* GLES2Texture::loadImage(const char *filename, int& colorDepth)	{		//image format		FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;		//pointer to the image, once loaded		FIBITMAP *dib(0);		//pointer to the image data		BYTE* bits(0);		//image width and height		unsigned int width(0), height(0);		//check the file signature and deduce its format		fif = FreeImage_GetFileType(filename, 0);		//if still unknown, try to guess the file format from the file extension		if(fif == FIF_UNKNOWN) 			fif = FreeImage_GetFIFFromFilename(filename);		//if still unkown, return failure		if(fif == FIF_UNKNOWN)			return NULL;		//check that the plugin has reading capabilities and load the file		if(FreeImage_FIFSupportsReading(fif))			dib = FreeImage_Load(fif, filename);		//if the image failed to load, return failure		if(!dib)			return NULL;		int datasize = FreeImage_GetDIBSize(dib);		//retrieve the image data		bits = FreeImage_GetBits(dib);		//get the image width and height		width = FreeImage_GetWidth(dib);		height = FreeImage_GetHeight(dib);		//get the image bpp		colorDepth = FreeImage_GetBPP(dib);		//if this somehow one of these failed (they shouldn't), return failure		if((bits == 0) || (width == 0) || (height == 0))			return NULL;		mWidth = width;		mHeight = height;		// BGRA 转成 RGBA		unsigned char* buffer = new unsigned char[datasize];		int i=0;		for (i=0; i<datasize; i+=4) {			(buffer+i)[0] = (bits+i)[2];			(buffer+i)[1] = (bits+i)[1];			(buffer+i)[2] = (bits+i)[0];			(buffer+i)[3] = (bits+i)[3];		}		//Free FreeImage's copy of the data		FreeImage_Unload(dib);		return buffer;	}
开发者ID:crackgame,项目名称:easy2d,代码行数:57,


示例22: resizeImage

//you can pass 0 for width or height to keep aspect ratiobool resizeImage(const std::string& path, int maxWidth, int maxHeight){	// nothing to do	if(maxWidth == 0 && maxHeight == 0)		return true;	FREE_IMAGE_FORMAT format = FIF_UNKNOWN;	FIBITMAP* image = NULL;		//detect the filetype	format = FreeImage_GetFileType(path.c_str(), 0);	if(format == FIF_UNKNOWN)		format = FreeImage_GetFIFFromFilename(path.c_str());	if(format == FIF_UNKNOWN)	{		LOG(LogError) << "Error - could not detect filetype for image /"" << path << "/"!";		return false;	}	//make sure we can read this filetype first, then load it	if(FreeImage_FIFSupportsReading(format))	{		image = FreeImage_Load(format, path.c_str());	}else{		LOG(LogError) << "Error - file format reading not supported for image /"" << path << "/"!";		return false;	}	float width = (float)FreeImage_GetWidth(image);	float height = (float)FreeImage_GetHeight(image);	if(maxWidth == 0)	{		maxWidth = (int)((maxHeight / height) * width);	}else if(maxHeight == 0)	{		maxHeight = (int)((maxWidth / width) * height);	}	FIBITMAP* imageRescaled = FreeImage_Rescale(image, maxWidth, maxHeight, FILTER_BILINEAR);	FreeImage_Unload(image);	if(imageRescaled == NULL)	{		LOG(LogError) << "Could not resize image! (not enough memory? invalid bitdepth?)";		return false;	}	bool saved = FreeImage_Save(format, imageRescaled, path.c_str());	FreeImage_Unload(imageRescaled);    if(!saved) {		LOG(LogError) << "Failed to save resized image!";    }	return saved;}
开发者ID:XD9527,项目名称:recalbox-emulationstation,代码行数:58,


示例23: FreeImage_GetFIFFromFilename

GLuint Texture::loadTexture(){	FIBITMAP *dib1 = NULL;	FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(_filename);	dib1 = FreeImage_Load(fif, _filename, JPEG_DEFAULT);	if (!dib1)	{		std::cerr << "Erreur ouverture d/'image" << std::endl;		exit(0);	}	GLuint tex_id = 0;	int x, y;	int height, width;	RGBQUAD rgbquad;	FREE_IMAGE_TYPE type;	BITMAPINFOHEADER *header;	type = FreeImage_GetImageType(dib1);	height = FreeImage_GetHeight(dib1);	width = FreeImage_GetWidth(dib1);	header = FreeImage_GetInfoHeader(dib1);	int scanLineWidh = ((3 * width) % 4 == 0) ? 3 * width : ((3 * width) / 4) * 4 + 4;	unsigned char * texels = (GLubyte*)calloc(height*scanLineWidh, sizeof(GLubyte));	for (x = 0; x<width; x++)		for (y = 0; y<height; y++)		{			FreeImage_GetPixelColor(dib1, x, y, &rgbquad);			texels[(y*scanLineWidh + 3 * x)] = ((GLubyte*)&rgbquad)[2];			texels[(y*scanLineWidh + 3 * x) + 1] = ((GLubyte*)&rgbquad)[1];			texels[(y*scanLineWidh + 3 * x) + 2] = ((GLubyte*)&rgbquad)[0];		}	glGenTextures(1, &tex_id);	glBindTexture(GL_TEXTURE_2D, tex_id);	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_RGB,		width, height, 0, GL_RGB,		GL_UNSIGNED_BYTE, texels);	free(texels);	return tex_id;}
开发者ID:mxklsn,项目名称:BachelorWork,代码行数:57,


示例24: FreeImage_GetFIFFromFilename

/** * This method saves the image to an given file. * The image type will determined by the file ending. * * @param szFile the path of the image file to save * @return true if the image data was saved, else false */bool fipImage::save( const char * szFile ) const{	FREE_IMAGE_FORMAT freeImageFormat = FreeImage_GetFIFFromFilename( szFile );	if ( freeImageFormat == FIF_UNKNOWN ){		return false;	}		return FreeImage_Save( freeImageFormat, pImageData, szFile);}
开发者ID:BioKom,项目名称:Fib,代码行数:16,


示例25: texture

/*	Loads a texture froma file to be applied to the terrain	@param the path to the texture file	@return whether or not the file was loaded correctly*/bool Ground::loadGroundTexture(string path) {	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;	FIBITMAP* texture(0);	fif = FreeImage_GetFileType(path.c_str(), 0);	if (fif == FIF_UNKNOWN) { // Unknown file type		//std::cout << "Unknown Filetype/n";		fif = FreeImage_GetFIFFromFilename(path.c_str());	}	if (fif == FIF_UNKNOWN) { // Still unkown file type		std::cout << "Unknown Filetype/n";		return false;	}	if (FreeImage_FIFSupportsReading(fif)) { // is the file supported by free image?		texture = FreeImage_Load(fif, path.c_str());	}	if (!texture) {		std::cout << "This file type is not supported by FreeImage/n";		return false;	}	BYTE* dataPointer = FreeImage_GetBits(texture);	textureWidth = FreeImage_GetWidth(texture);	textureHeight = FreeImage_GetHeight(texture);	textureBPP = FreeImage_GetBPP(texture);	glGenTextures(1, &textureID);	glBindTexture(GL_TEXTURE_2D, textureID);		int format = textureBPP == 24 ? GL_BGR : textureBPP == 8 ? GL_LUMINANCE : 0;	int internalFormat = textureBPP == 24 ? GL_BGR : GL_DEPTH_COMPONENT;			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureWidth, textureHeight, 0, format, GL_UNSIGNED_BYTE, dataPointer);	glGenerateMipmap(GL_TEXTURE_2D);		FreeImage_Unload(texture);	glGenSamplers(1, &samplerID);	texturePath = path;	// Tri linear filtering	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_LINEAR);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 	glGenerateMipmap(GL_TEXTURE_2D);	return true;}
开发者ID:hipblip,项目名称:OutdoorScene,代码行数:60,


示例26: FI

void FI(saveImageFile)(const Bitmap& bitmap, Gosu::Writer writer,                       const std::wstring& formatHint){    std::string utf8FormatHint = wstringToUTF8(formatHint);    FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(utf8FormatHint.c_str());    FIBITMAP* fib = bitmapToFIB(bitmap, fif);    FreeImageIO fio = { NULL, WriteProc, SeekProc, TellProc };    FreeImage_SaveToHandle(fif, fib, &fio, &writer);    FreeImage_Unload(fib);    checkForFreeImageErrors();}
开发者ID:JTunnessen,项目名称:gosu,代码行数:12,


示例27: strcpy

void sprite::load(config* simConfig, string fpath){    //generate texture data    //get texture file name    char newname[512];    string textPath = "../bin/sprites/" + fpath;    isFont = false;    strcpy(newname, textPath.c_str());    //give it its texture    texID = simConfig->texCount;    simConfig->texCount++;    FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;    BYTE * bits(0);    FIBITMAP * dib(0);    fif = FreeImage_GetFileType(newname, 0);    //if still unknown, try to guess the file format from the file extension    if(fif == FIF_UNKNOWN)        fif = FreeImage_GetFIFFromFilename(newname);    if(fif == FIF_UNKNOWN)        cout<<"WE DON'T KNOW WHAT FIF THIS IS!"<<endl;    if(FreeImage_FIFSupportsReading(fif))        dib = FreeImage_Load(fif, newname, 0);    else        cout<<"Bad texture file format!"<<endl;    if(!dib)        cout<<"Dib failed to load! Are your file paths set up properly?? "<<newname<<endl;    bits = FreeImage_GetBits(dib);    //get the image width and height    texWidth = FreeImage_GetWidth(dib);    texHeight = FreeImage_GetHeight(dib);    //generate an OpenGL texture ID for this texture    glGenTextures(1, &texID);    glBindTexture( GL_TEXTURE_2D, texID);    //store the texture data for OpenGL use    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, bits);    FreeImage_Unload(dib);    //reset texture frame sizes to max    frameSize[0] = texWidth;    frameSize[1] = texHeight;}
开发者ID:afalconi,项目名称:Graphics,代码行数:53,


示例28: unload

const Texture* Texture::load(const std::string& fileName){	if (sTextureMap.find(fileName) != sTextureMap.end()) {		unload(sTextureMap[fileName]);	}	const std::string path = sBasePath + fileName;	FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(path.c_str(), 0);	if (fif == FIF_UNKNOWN) {		fif = FreeImage_GetFIFFromFilename(path.c_str());	}	if (fif == FIF_UNKNOWN) {		return nullptr;	}	FIBITMAP* dib = nullptr;	if (FreeImage_FIFSupportsReading(fif)) {		dib = FreeImage_Load(fif, path.c_str());	}	if (!dib) {		return nullptr;	}	BYTE* bits = FreeImage_GetBits(dib);	unsigned int width = FreeImage_GetWidth(dib);	unsigned int height = FreeImage_GetHeight(dib);	if (bits == 0 || width == 0 || height == 0) {		return nullptr;	}	FREE_IMAGE_COLOR_TYPE colorType = FreeImage_GetColorType(dib);	FREE_IMAGE_TYPE imageType = FreeImage_GetImageType(dib);	GLenum glFormat = getGLFormat(colorType);	Texture tex;	tex.mName = fileName;	glGenTextures(1, &tex.mId);	assert(tex.mId);	glBindTexture(GL_TEXTURE_2D, tex.mId);	glTexImage2D(GL_TEXTURE_2D, 0, glFormat, width, height, 0, glFormat, GL_UNSIGNED_BYTE, bits);	glGenerateMipmap(GL_TEXTURE_2D);	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);	sTextureMap[fileName] = tex;	FreeImage_Unload(dib);	return &sTextureMap[fileName];}
开发者ID:santisan,项目名称:santisan.github.com,代码行数:52,



注:本文中的FreeImage_GetFIFFromFilename函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ FreeImage_GetFileType函数代码示例
C++ FreeImage_GetColorType函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。