• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ FreeImage_ConvertTo32Bits函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FreeImage_GetFileType

int TextureLoader::LoadTexture(const char * imagepath)
{    
    // Load image using the Free Image library
    FREE_IMAGE_FORMAT format = FreeImage_GetFileType(imagepath, 0);
    FIBITMAP* image = FreeImage_Load(format, imagepath);
    FIBITMAP* image32bits = FreeImage_ConvertTo32Bits(image);
    
    // Get an available texture index from OpenGL
    GLuint texture = 0;
    glGenTextures(1, &texture);
    assert(texture != 0);
    
    // Set OpenGL filtering properties (bi-linear interpolation)
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    
    // Retrieve width and hight
    int width = FreeImage_GetWidth(image32bits);
    int height = FreeImage_GetHeight(image32bits);
    
    // This will upload the texture to the GPU memory
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height,
                 0, GL_BGRA, GL_UNSIGNED_BYTE, (void*)FreeImage_GetBits(image32bits));
    
    // Free images
    FreeImage_Unload(image);
    FreeImage_Unload(image32bits);
 
    return texture;
}
开发者ID:GeoffreyBoom,项目名称:Noise,代码行数:31,代码来源:TextureLoader.cpp


示例2: SDL_assert_release

FIBITMAP *GraphicsHelps::loadImageRC(const char *file)
{
    unsigned char *memory = nullptr;
    size_t fileSize = 0;
    SDL_assert_release(RES_getMem(file, memory, fileSize));
    //{
        //pLogCritical("Resource file \"%s\" is not found!", file);
        //return nullptr;
    //}

    FIMEMORY *imgMEM = FreeImage_OpenMemory(memory, static_cast<FI_DWORD>(fileSize));
    FREE_IMAGE_FORMAT formato = FreeImage_GetFileTypeFromMemory(imgMEM);

    if(formato == FIF_UNKNOWN)
        return nullptr;

    FIBITMAP *img = FreeImage_LoadFromMemory(formato, imgMEM, 0);
    FreeImage_CloseMemory(imgMEM);

    if(!img)
        return nullptr;

    FIBITMAP *temp;
    temp = FreeImage_ConvertTo32Bits(img);

    if(!temp)
        return nullptr;

    FreeImage_Unload(img);
    img = temp;
    return img;
}
开发者ID:jpmac26,项目名称:PGE-Project,代码行数:32,代码来源:graphics_funcs.cpp


示例3: FreeImage_ConvertTo32Bits

GLuint Engine::useTexture(char* texDir, bool wrap) {
	FIBITMAP* imagePtr =
		FreeImage_ConvertTo32Bits(
			FreeImage_Load(
				FreeImage_GetFileType(texDir, 0), texDir)
			);
	GLuint texture;
	glGenTextures(1, &texture); // i used to be 1
	glBindTexture(GL_TEXTURE_2D, texture);

	glTexImage2D(GL_TEXTURE_2D, 0,
		GL_SRGB_ALPHA,
		FreeImage_GetWidth(imagePtr),
		FreeImage_GetHeight(imagePtr),
		0, GL_BGRA, GL_UNSIGNED_BYTE,
		(void*)FreeImage_GetBits(imagePtr));

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap ? GL_REPEAT : GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap ? GL_REPEAT : GL_CLAMP);

	// Clear from RAM
	FreeImage_Unload(imagePtr);
	// Unbind when finished uplloading
	glBindTexture(GL_TEXTURE_2D, 0);
	return texture;
}
开发者ID:martinsuas,项目名称:ms7605Engine,代码行数:28,代码来源:Engine.cpp


示例4: load_image

std::shared_ptr<FIBITMAP> load_image(const std::wstring& filename)
{
	if(!boost::filesystem::exists(filename))
		BOOST_THROW_EXCEPTION(file_not_found() << boost::errinfo_file_name(narrow(filename)));

	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	fif = FreeImage_GetFileTypeU(filename.c_str(), 0);
	if(fif == FIF_UNKNOWN) 
		fif = FreeImage_GetFIFFromFilenameU(filename.c_str());
		
	if(fif == FIF_UNKNOWN || !FreeImage_FIFSupportsReading(fif)) 
		BOOST_THROW_EXCEPTION(invalid_argument() << msg_info("Unsupported image format."));
		
	auto bitmap = std::shared_ptr<FIBITMAP>(FreeImage_LoadU(fif, filename.c_str(), 0), FreeImage_Unload);
		  
	if(FreeImage_GetBPP(bitmap.get()) != 32)
	{
		bitmap = std::shared_ptr<FIBITMAP>(FreeImage_ConvertTo32Bits(bitmap.get()), FreeImage_Unload);
		if(!bitmap)
			BOOST_THROW_EXCEPTION(invalid_argument() << msg_info("Unsupported image format."));			
	}

	//PNG-images need to be premultiplied with their alpha
	if(fif == FIF_PNG)
	{
		image_view<bgra_pixel> original_view(FreeImage_GetBits(bitmap.get()), FreeImage_GetWidth(bitmap.get()), FreeImage_GetHeight(bitmap.get()));
		premultiply(original_view);
	}
	
	return bitmap;
}
开发者ID:jaskie,项目名称:Server,代码行数:31,代码来源:image_loader.cpp


示例5: 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,代码来源:Texture.cpp


示例6: compatible

void ImageLoader::
compatible()
{
	// BITMAP数据是从下往上的, 需要翻转
	FreeImage_FlipVertical(mDIB);

	// FreeImage是BGR顺序, 与NVTT要求的一致, 而PVRT需要RGB顺序, 两者都需要32bits数据
	if (config.imageCompressionType != CT_DXTC)
	{
		// 将BGR改为RGB, 交换R channel和B channel
		const unsigned bytesperpixel = FreeImage_GetBPP(mDIB) / 8;
		const unsigned height = FreeImage_GetHeight(mDIB);
		const unsigned pitch = FreeImage_GetPitch(mDIB);
		const unsigned lineSize = FreeImage_GetLine(mDIB);

		BYTE* line = FreeImage_GetBits(mDIB);
		for (unsigned y = 0; y < height; ++y, line += pitch) {
			for (BYTE* pixel = line; pixel < line + lineSize; pixel += bytesperpixel) {
				INPLACESWAP(pixel[0], pixel[2]);
			}
		}
	}

	if (FreeImage_GetBPP(mDIB) != 32)
	{
		FIBITMAP* convertDIB = FreeImage_ConvertTo32Bits(mDIB);
		FreeImage_Unload(mDIB);
		mDIB = convertDIB;
	}
}
开发者ID:Napoleon314,项目名称:oiramExporter,代码行数:30,代码来源:ImageLoader.cpp


示例7: createTexture

image* createTexture(char* filePath){
	//FreeImage_Initialise(FALSE);
	FREE_IMAGE_FORMAT formato = FreeImage_GetFileType(filePath,0);//Automatocally detects the format(from over 20 formats!)
	FIBITMAP* imagen = FreeImage_Load(formato, filePath,JPEG_ACCURATE);
	FIBITMAP* temp = imagen;
	imagen = FreeImage_ConvertTo32Bits(imagen);
	FreeImage_Unload(temp);

	int w = FreeImage_GetWidth(imagen);
	int h = FreeImage_GetHeight(imagen);
	GLubyte* textura = (GLubyte*) malloc(4*w*h);
	char* pixeles = (char*)FreeImage_GetBits(imagen);
	//FreeImage loads in BGR format, so you need to swap some bytes(Or use GL_BGR).
	int j = 0;
	for(; j<w*h; j++){
		textura[j*4+0]= pixeles[j*4+2];
		textura[j*4+1]= pixeles[j*4+1];
		textura[j*4+2]= pixeles[j*4+0];
		textura[j*4+3]= pixeles[j*4+3];
	}
	free(pixeles);
	FreeImage_Unload(imagen);
	image* imageToReturn = malloc(sizeof(image));
	imageToReturn->height = h;
	imageToReturn->width = w;
	imageToReturn->texture = textura;
	return imageToReturn;
}
开发者ID:laurenskz,项目名称:Game,代码行数:28,代码来源:textureLoader.c


示例8: loadTexture

void loadTexture(char *textureFileName, GLuint &textureMapID)	
{
	FREE_IMAGE_FORMAT fifmt = FreeImage_GetFileType(textureFileName, 0);

	FIBITMAP *dib = FreeImage_Load(fifmt, textureFileName,0);

	FIBITMAP *temp = dib;
    dib = FreeImage_ConvertTo32Bits(temp);
    FreeImage_Unload(temp);	 
	
    if( dib != NULL )
	{
        
        glGenTextures( 1, &textureMapID );
		glBindTexture( GL_TEXTURE_2D, textureMapID );
        
         
        BYTE *pixels = (BYTE*)FreeImage_GetBits(dib);
        
        //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);		
      
        ConfigureAndLoadTexture(pixels,  FreeImage_GetWidth(dib),  FreeImage_GetHeight(dib) );           
 
     glActiveTexture (GL_TEXTURE0);                                                                                                                                            
    glBindTexture(GL_TEXTURE_2D, textureMapID); 
//===================================================================================================      
    
//===================================================================================================      
      
      
        free(pixels);
        FreeImage_Unload(dib);
	}

}
开发者ID:marcclintdion,项目名称:texture_BAKER,代码行数:35,代码来源:freeImage.cpp


示例9: FreeImage_ConvertTo32Bits

BOOL fipImage::convertTo32Bits() {
	if(_dib) {
		FIBITMAP *dib32 = FreeImage_ConvertTo32Bits(_dib);
		return replace(dib32);
	}
	return FALSE;
}
开发者ID:MrMasterplan,项目名称:PIC-stuff,代码行数:7,代码来源:fipImage.cpp


示例10: Init

int Init ( AAContext *aaContext )
{
    UserData *userData = (UserData*) aaContext->userData;
	userData->animation = (Animation*) malloc(sizeof(Animation));
	memset(userData->animation, 0x0, sizeof(Animation));
    glGenTextures(1, &userData->earth_texture);
	glBindTexture(GL_TEXTURE_2D, userData->earth_texture);
    FIBITMAP* bitmap = FreeImage_Load(
        FreeImage_GetFileType("earth.png", 0),
        "earth.png");
    FIBITMAP *pImage = FreeImage_ConvertTo32Bits(bitmap);
    int nWidth = FreeImage_GetWidth(pImage);
    int nHeight = FreeImage_GetHeight(pImage);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, nWidth, nHeight,
		0, GL_BGRA, GL_UNSIGNED_BYTE, (void*)FreeImage_GetBits(pImage));
	FreeImage_Unload(pImage);
	FreeImage_Unload(bitmap); // correct?
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

   const char vShaderStr[] =  
	  "uniform mat4 u_mvp;      					 \n"
	  "attribute vec2 a_texCoords;                   \n"
	  "varying vec2 v_texCoords;						 \n"
      "attribute vec4 a_position;					 \n"
	  "out float debug;								\n"
      "void main()									 \n"
      "{											 \n"
	  "vec4 pos = u_mvp * a_position;		\n"
	  "gl_Position = pos;                      \n"
	  "v_texCoords = a_texCoords;					\n"
	  "debug = a_position.y;                      \n"
      "}                                             \n";
   
   const char fShaderStr[] =  
	  "in float debug;                                     \n"
	  "varying vec2 v_texCoords;								\n"
	  "uniform sampler2D s_earthTexture;                   \n"
      "precision mediump float;                            \n"
      "void main()                                         \n"
      "{                                                   \n"
	  "vec4 color = texture(s_earthTexture, v_texCoords);     \n"
//	  "if(debug>0) \n"
//	  "color = vec4(1.0, 0.0, 0.0, 1.0); \n"
	  "gl_FragColor = color;                               \n"
      "}                                                   \n";

   // Load the shaders and get a linked program object
   userData->programObject = LoadProgram ( vShaderStr, fShaderStr );

   // Get the attribute locations
   userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
   userData->mvpLoc = glGetUniformLocation(userData->programObject, "u_mvp");

   userData->texCoordsLoc = glGetAttribLocation(userData->programObject, "a_texCoords");
   userData->texLoc = glGetUniformLocation(userData->programObject, "s_earthTexture");
   glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
   glEnable(GL_DEPTH_TEST);
   return TRUE;
}
开发者ID:alexrusciano,项目名称:Rotations,代码行数:60,代码来源:Rotations.cpp


示例11: FreeImage_GetFileType

RGBAImage* RGBAImage::ReadFromFile(const char* filename)
{
	const FREE_IMAGE_FORMAT fileType = FreeImage_GetFileType(filename);
	if(FIF_UNKNOWN == fileType)
	{
		printf("Unknown filetype %s\n", filename);
		return 0;
	}

	FIBITMAP* freeImage = 0;
	if(FIBITMAP* temporary = FreeImage_Load(fileType, filename, 0))
	{
		freeImage = FreeImage_ConvertTo32Bits(temporary);
		FreeImage_Unload(temporary);
	}
	if(!freeImage)
	{
		printf( "Failed to load the image %s\n", filename);
		return 0;
	}

	RGBAImage *result = ToRGBAImage(freeImage);

	FreeImage_Unload(freeImage);

	return result;
}
开发者ID:AndrewShalimov,项目名称:perceptualdiff,代码行数:27,代码来源:RGBAImage.cpp


示例12: make_texture

GLuint make_texture(const char *filename) {

    GLuint texture;

    // Get the image file type from FreeImage.
    FREE_IMAGE_FORMAT fifmt = FreeImage_GetFileType(filename, 0);

    // Actually load the image file.
    FIBITMAP *dib = FreeImage_Load(fifmt, filename, 0);

    // Now, there is no guarantee that the image file
    // loaded will be GL_RGB, so we force FreeImage to
    // convert the image to GL_RGB.
    dib = FreeImage_ConvertTo32Bits(dib);

    if (dib != NULL) {
        glGenTextures(1, &texture);
        glBindTexture(GL_TEXTURE_2D, texture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

        // This is important to note, FreeImage loads textures in
        // BGR format. Now we could just use the GL_BGR extension
        // But, we will simply swap the B and R components ourselves.
        // Firstly, allocate the new bit data doe the image.
        //BYTE *bits = malloc(FreeImage_GetWidth(dib) * FreeImage_GetHeight(dib) * 4);

        // get a pointer to FreeImage's data.
        BYTE *pixels = (BYTE*) FreeImage_GetBits(dib);

        // Iterate through the pixels, copying the data
        // from 'pixels' to 'bits' except in RGB format.
        /*
        int pix;
        for (pix = 0; pix < FreeImage_GetWidth(dib) * FreeImage_GetHeight(dib); pix++) {
            bits[pix * 4 + 0] = pixels[pix * 4 + 2];
            bits[pix * 4 + 1] = pixels[pix * 4 + 1];
            bits[pix * 4 + 2] = pixels[pix * 4 + 0];
            bits[pix * 4 + 3] = pixels[pix * 4 + 3];
        }*/

        // The new 'glTexImage2D' function, the prime difference
        // being that it gets the width, height and pixel information
        // from 'bits', which is the RGB pixel data..
        //glTexImage2D(GL_TEXTURE_2D, 0, 4, FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), 0,
        //       GL_RGBA, GL_UNSIGNED_BYTE, bits);
        glTexImage2D(GL_TEXTURE_2D, 0, 4, FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), 0,
                GL_BGRA, GL_UNSIGNED_BYTE, pixels);


        // Unload the image.
        // and free the bit data.
        FreeImage_Unload(dib);
        //free(bits);
    } else {
        fprintf(stderr, "Can't load texture: %s\n", filename);
    }
    
    return texture;
}
开发者ID:rnentjes,项目名称:OpenGL,代码行数:60,代码来源:shaderUtils.c


示例13: stuff

bool FreeimagelibPlugin::LoadDoc(cpcl::IOStream *input, plcl::Doc **r) {
	FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)freeimagelib_format;
	FreeimagelibStuff stuff(input);
	boost::shared_ptr<FIBITMAP> fibitmap(FreeImage_LoadFromHandle(fif, &stuff.io, stuff.io_handle), FreeImage_Unload);
	if (!fibitmap) {
		cpcl::Error(cpcl::StringPieceFromLiteral("FreeimagelibPlugin::LoadDoc(): unable to load image"));
		return false;
	}
	
	if (FreeImage_GetImageType(fibitmap.get()) != FIT_BITMAP) {
		boost::shared_ptr<FIBITMAP> tmp(FreeImage_ConvertToType(fibitmap.get(), FIT_BITMAP), FreeImage_Unload);
		if (!tmp || (FreeImage_GetImageType(tmp.get()) != FIT_BITMAP)) {
			cpcl::Error(cpcl::StringPieceFromLiteral("FreeimagelibPlugin::LoadDoc(): unable to convert the image to FIT_BITMAP"));
			return false;
		}
		fibitmap = tmp;
	}

	unsigned int const bpp = FreeImage_GetBPP(fibitmap.get());
	if (!(bpp == 24 || bpp == 32)) {
		boost::shared_ptr<FIBITMAP> tmp((bpp > 32) ? FreeImage_ConvertTo32Bits(fibitmap.get()) : FreeImage_ConvertTo24Bits(fibitmap.get()), FreeImage_Unload);
		if (!tmp) {
			cpcl::Trace(CPCL_TRACE_LEVEL_ERROR,
				"FreeimagelibPlugin::LoadDoc(): unable to convert image with bpp %u",
				bpp);
		}
		fibitmap = tmp;
	}

	if (r)
		*r = new FreeimagelibDoc(fibitmap);
	return true;
}
开发者ID:hatc,项目名称:ekc,代码行数:33,代码来源:freeimagelib_plugin.cpp


示例14: bits

/*
* \brief Method that import a texture to be used on the model
* \param[in] fTexture a constant char array containing the path to the file of the texture
* \param[in] tex_number an unsigned integer representing the type of texture (i.e. 0 = Diffuse color, 1 = Normalmap, 2 = Specular Color)
* \return a boolean indicating if the import was successful of not
*/
GLboolean Model::importTexture(const GLchar * fTexture, GLuint tex_number)
{
	GLboolean import_is_ok = GL_FALSE;
	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	FIBITMAP *dib(0);
	BYTE* bits(0);
	GLuint width(0), height(0);

	fif = FreeImage_GetFileType(fTexture, 0);

	if (FreeImage_FIFSupportsReading(fif))
	{
		dib = FreeImage_Load(fif, fTexture);
		dib = FreeImage_ConvertTo32Bits(dib);
		bits = FreeImage_GetBits(dib);
		width = FreeImage_GetWidth(dib);
		height = FreeImage_GetHeight(dib);
		import_is_ok = GL_TRUE;

		glBindTexture(GL_TEXTURE_2D, m_texture_id[tex_number]);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, &bits[0]);
		glGenerateMipmap(GL_TEXTURE_2D);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);

		FreeImage_Unload(dib);
	}
	return import_is_ok;
}
开发者ID:mobeaudoin,项目名称:ogl-first-engine,代码行数:35,代码来源:Model.cpp


示例15: switch

/**
 * Helper to encapsulate Bpp conversion using FreeImage, taking into consideration color type. Creates a new bitmap if needed. Can return the same one.
 * @param pHandle		FIBITMAP as defined by the Freeimage library.
 * @param pNewBpp		the new bpp that the supplied FIBITMAP is to be coverted to.
 */
FIBITMAP* FreeImageHelper::convertBpp(FIBITMAP* pHandle, int pNewBpp) {	
	//Convert the bit depth
	FIBITMAP *converted = NULL;
	
	//Convert Bpp only if needed
	if (pNewBpp != static_cast<int>(FreeImage_GetBPP(pHandle))) {
		//Transform bpp to the pixel format
		switch (pNewBpp) {
			case (4):
				converted = FreeImage_ConvertTo4Bits(pHandle);
				break;
			case (8):
				converted = FreeImage_ConvertTo8Bits(pHandle);
				break;
			case(16):
				converted = FreeImage_ConvertTo16Bits565(pHandle);  //There's option of 16Bits555. But leaves unused bits. Chosen 565 because it's most common
				break;
			case(24):
			   converted = FreeImage_ConvertTo24Bits(pHandle);    
			    break;
			case(32): {
			    converted = FreeImage_ConvertTo32Bits (pHandle); 
				}
			    break;
			default:
				converted = NULL;
				break;
		}
	} else {
		//No change, just set 'converted' handle to current one
		converted = pHandle;
	}

	return converted;
}
开发者ID:Javilop,项目名称:indielib-crossplatform,代码行数:40,代码来源:FreeImageHelper.cpp


示例16: getBmpFromPixels

void ofImage_<PixelType>::changeTypeOfPixels(ofPixels_<PixelType> &pix, ofImageType newType){
	int oldType = pix.getImageType();
		
	if (oldType == newType) {
		return; // no need to reallocate
	}

	FIBITMAP * bmp = getBmpFromPixels(pix);
	FIBITMAP * convertedBmp = nullptr;

	switch (newType){
		case OF_IMAGE_GRAYSCALE:
			convertedBmp = FreeImage_ConvertToGreyscale(bmp);
			break;
		case OF_IMAGE_COLOR:
			convertedBmp = FreeImage_ConvertTo24Bits(bmp);
			break;
		case OF_IMAGE_COLOR_ALPHA:
			convertedBmp = FreeImage_ConvertTo32Bits(bmp);
			break;
		default:
			ofLogError("ofImage") << "changeTypeOfPixels(): unknown image type: " << newType;
			break;
	}
	
    putBmpIntoPixels(convertedBmp, pix, false);

	if (bmp != nullptr) {
		FreeImage_Unload(bmp);
	}
	if (convertedBmp != nullptr) {
		FreeImage_Unload(convertedBmp);
	}
}
开发者ID:BaptisteTheoriz,项目名称:openFrameworks,代码行数:34,代码来源:ofImage.cpp


示例17: test32BitsChannels

void test32BitsChannels(unsigned width, unsigned height) {
	BOOL bResult = FALSE;

	// create a test 8-bit image
	FIBITMAP *src = createZonePlateImage(width, height, 128);
	if(src != NULL) {
		// convert to 32-bit
		FIBITMAP *tmp = FreeImage_ConvertTo32Bits(src);
		FreeImage_Unload(src);
		src = tmp;
	}
	assert(src != NULL);

	// save for further examination
	bResult = FreeImage_Save(FIF_PNG, src, "zoneplate.png", PNG_DEFAULT);
	assert(bResult);

	// test get/set channel
	// -------------------------	
	FIBITMAP *channel = FreeImage_GetChannel(src, FICC_ALPHA);
	assert(channel != NULL);
	bResult = FreeImage_SetChannel(src, channel, FICC_ALPHA);
	assert(bResult);	
	FreeImage_Unload(channel);

	FreeImage_Unload(src);
}
开发者ID:dschaefer,项目名称:dasEngine,代码行数:27,代码来源:testChannels.cpp


示例18: TestFIA_DrawImageDstRectTest3

static void
TestFIA_DrawImageDstRectTest3(CuTest* tc)
{
  const char *file = TEST_DATA_DIR "fly.bmp";

  FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);

  CuAssertTrue(tc, dib1 != NULL);

  FIBITMAP *dib2 = FreeImage_ConvertTo32Bits(dib1);
  
  CuAssertTrue(tc, dib2 != NULL);
  
  FIBITMAP *dst = FreeImage_Allocate(790,582, 32, 0, 0, 0);
   
  CuAssertTrue(tc, dst != NULL);
   
  FIA_Matrix *matrix = FIA_MatrixNew();

  FIA_MatrixScale(matrix, 2.0, 2.0, FIA_MatrixOrderPrepend);
  
   int err = FIA_DrawImageToDst(dst, dib2, matrix, 0,0,350/2,271/2, FIA_RGBQUAD(128,128,128), 1);

  CuAssertTrue(tc, err != FIA_ERROR);
  
  FIA_MatrixDestroy(matrix);
  
  CuAssertTrue(tc, dst != NULL);

  FIA_SaveFIBToFile(dst, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_DrawImageDstRectTest3.bmp", BIT24);

  FreeImage_Unload(dib1);
  FreeImage_Unload(dib2);
  FreeImage_Unload(dst);
}
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:35,代码来源:FreeImageAlgorithms_DrawingTests.cpp


示例19: BmpFilterLoadBitmap

HBITMAP BmpFilterLoadBitmap(BOOL *bIsTransparent, const wchar_t *ptszFilename)
{
	FIBITMAP *dib = (FIBITMAP*)Image_Load(ptszFilename, IMGL_RETURNDIB);
	if (dib == nullptr)
		return nullptr;

	FIBITMAP *dib32 = nullptr;
	if (FreeImage_GetBPP(dib) != 32) {
		dib32 = FreeImage_ConvertTo32Bits(dib);
		FreeImage_Unload(dib);
	}
	else dib32 = dib;

	if (dib32 == nullptr)
		return nullptr;

	if (FreeImage_IsTransparent(dib32))
		if (bIsTransparent)
			*bIsTransparent = TRUE;

	if (FreeImage_GetWidth(dib32) > 128 || FreeImage_GetHeight(dib32) > 128) {
		FIBITMAP *dib_new = FreeImage_MakeThumbnail(dib32, 128, FALSE);
		FreeImage_Unload(dib32);
		if (dib_new == nullptr)
			return nullptr;
		dib32 = dib_new;
	}

	HBITMAP bitmap = FreeImage_CreateHBITMAPFromDIB(dib32);
	FreeImage_Unload(dib32);
	FreeImage_CorrectBitmap32Alpha(bitmap, FALSE);
	return bitmap;
}
开发者ID:tweimer,项目名称:miranda-ng,代码行数:33,代码来源:image_utils.cpp


示例20: read_from_file

std::shared_ptr<RGBAImage> read_from_file(const std::string &filename)
{
    const auto file_type = FreeImage_GetFileType(filename.c_str());
    if (FIF_UNKNOWN == file_type)
    {
        throw RGBImageException("Unknown filetype '" + filename + "'");
    }

    FIBITMAP *free_image = nullptr;
    if (auto temporary = FreeImage_Load(file_type, filename.c_str(), 0))
    {
        free_image = FreeImage_ConvertTo32Bits(temporary);
        FreeImage_Unload(temporary);
    }
    if (not free_image)
    {
        throw RGBImageException("Failed to load the image " + filename);
    }

    auto result = to_rgba_image(free_image);

    FreeImage_Unload(free_image);

    return result;
}
开发者ID:ivokabel,项目名称:perceptualdiff,代码行数:25,代码来源:rgba_image.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FreeImage_DeInitialise函数代码示例发布时间:2022-05-30
下一篇:
C++ FreeImage_Allocate函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap