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

C++ FreeImage_GetBPP函数代码示例

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

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



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

示例1: 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


示例2: FreeImage_Load

void TextureLoader::load(GLuint* tex_name, FREE_IMAGE_FORMAT fif, const char* file)
{
	FIBITMAP* image = FreeImage_Load(fif, file);

	int tex_width = FreeImage_GetWidth(image);
	int tex_height = FreeImage_GetHeight(image);


	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

	glGenTextures(1, tex_name);
	glBindTexture(GL_TEXTURE_2D, *tex_name);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_DECAL);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_DECAL);

	//printf("BPP: %d\n", FreeImage_GetBPP(image));
	
	int bpp = FreeImage_GetBPP(image) / 8;

	GLenum format = GL_RGBA;

	if(bpp == 3)
		format = GL_RGB;

	gluBuild2DMipmaps(GL_TEXTURE_2D, bpp, tex_width, tex_height, format, GL_UNSIGNED_BYTE, FreeImage_GetBits(image));
}
开发者ID:Khedesh,项目名称:Traffic,代码行数:33,代码来源:texture_loader.cpp


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


示例4: convertBpp

/**
 * 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


示例5: FreeImage_GetImageType

/**
 * Freeimage format to Indielib format.
 * @param pHandle		the FIBITMAP that is used for calculation
 */
int FreeImageHelper::calculateINDFormat(FIBITMAP* pHandle) {

	FREE_IMAGE_TYPE imgType = FreeImage_GetImageType(pHandle);

	//Bitmap type (most common)
	if (FIT_BITMAP == imgType) {
		//Depending on the freeimage color type analysis, we determine our IND_ColorFormat
		FREE_IMAGE_COLOR_TYPE colorType = FreeImage_GetColorType(pHandle);

		
			
		if (FIC_MINISBLACK == colorType || FIC_MINISWHITE == colorType) {
			return IND_LUMINANCE;
		} else if (FIC_PALETTE == colorType) {
			return IND_COLOUR_INDEX;
		} else if (FIC_RGB == colorType) {
			//HACK: This is because when converting to 32 bits, even though there is alpha channel,
			//the color analysis function returns FIC_RGB, as alpha is opaque. We rely on that to know
			//if we have alpha channel so it's not good.
			if (FreeImage_GetBPP(pHandle) == 32) {
				return IND_RGBA;
			} else {
				return IND_RGB;
			}
		} else if (FIC_RGBALPHA == colorType) {
			return IND_RGBA;
		}
	}

	//TODO: OTHER IMAGE TYPES

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


示例6: TestFIA_IO

static void
TestFIA_IO(CuTest* tc)
{
	FIBITMAP *dib1 = NULL, *dib2 = NULL;
	FREE_IMAGE_TYPE type;
	int bpp, err;
    
    const char *file = TEST_DATA_DIR "001.tif";
	dib1 = FIA_LoadFIBFromFile(file);

	CuAssertTrue(tc, dib1 != NULL);

	bpp = FreeImage_GetBPP(dib1);
	type = FreeImage_GetImageType(dib1);

	CuAssertTrue(tc, bpp == 24);
	CuAssertTrue(tc, type == FIT_BITMAP);
	
	err = FIA_SaveFIBToFile (dib1, TEST_DATA_OUTPUT_DIR "/IO/save-colour-test.bmp", BIT8);

	CuAssertTrue(tc, err == FIA_SUCCESS);

	dib2 = FIA_LoadFIBFromFile(TEST_DATA_OUTPUT_DIR "/IO/save-colour-test.bmp");

	err = FIA_BitwiseCompare(dib1, dib2);

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


示例7: finalize

	bitmap_ptr finalize(bool showProgress = true) {
		if (chunks.empty()) {
			return nullptr;
		}
		if (showProgress) {
			std::cout << "Adding all accepted chunks to the final image\n";
		}
		
		const auto it = chunks.begin();
		bitmap_ptr firstChunk = GenericLoader(*it);
		
		auto currentHeight = 0;

		const auto type = FreeImage_GetImageType(firstChunk.get());
		
		const auto bpp = FreeImage_GetBPP(firstChunk.get());
		
		bitmap_ptr finalImage(FreeImage_AllocateT(type, width, height, bpp));

		auto RGBChunkWorker = [=, &finalImage, &currentHeight](const std::string& el)
		{
			bitmap_ptr chunk = GenericLoader(el);
			auto chunkHeight = FreeImage_GetHeight(chunk.get());
			auto chunk_img = FreeImage_Copy(chunk.get(), 0, 0, this->width, chunkHeight);
			if (chunk_img) {
				FreeImage_Paste(finalImage.get(), chunk_img, 0, currentHeight, 256);
			}
			currentHeight += chunkHeight;
		};

		std::for_each(chunks.begin(), chunks.end(), RGBChunkWorker);
		return finalImage;
	}
开发者ID:imapp-pl,项目名称:gnr-taskcollector,代码行数:33,代码来源:TaskCollector.cpp


示例8: NPP_ASSERT_MSG

void
FreeImageStack::loadImage(unsigned int iSlice, npp::ImageNPP_8u_C1 & rImage)
const
{
    NPP_ASSERT_MSG(iSlice < slices(), "Slice index exceeded number of slices in stack.");
    FIBITMAP * pBitmap = FreeImage_LockPage(pImageStack_, iSlice);
    NPP_ASSERT_NOT_NULL(pBitmap);
            // make sure this is an 8-bit single channel image
    NPP_DEBUG_ASSERT(FreeImage_GetColorType(pBitmap) == FIC_MINISBLACK);
    NPP_DEBUG_ASSERT(FreeImage_GetBPP(pBitmap) == 8);
    
    NPP_DEBUG_ASSERT(FreeImage_GetWidth(pBitmap) == nWidth_);
    NPP_DEBUG_ASSERT(FreeImage_GetHeight(pBitmap) == nHeight_);
    unsigned int    nSrcPitch = FreeImage_GetPitch(pBitmap);
    unsigned char * pSrcData  = FreeImage_GetBits(pBitmap);
    
    if (rImage.width() == nWidth_ && rImage.height() == nHeight_)
    {
        NPP_CHECK_CUDA(cudaMemcpy2D(rImage.data(), rImage.pitch(), pSrcData, nSrcPitch, 
                                    nWidth_, nHeight_, cudaMemcpyHostToDevice));
    }
    else
    {
                // create new NPP image
        npp::ImageNPP_8u_C1 oImage(nWidth_, nHeight_);
                // transfer slice data into new device image
        NPP_CHECK_CUDA(cudaMemcpy2D(oImage.data(), oImage.pitch(), pSrcData, nSrcPitch, 
                                    nWidth_, nHeight_, cudaMemcpyHostToDevice));
                // swap the result image with the reference passed into this method
        rImage.swap(oImage);
    }
                // release locked slice
    FreeImage_UnlockPage(pImageStack_, pBitmap, FALSE);
}
开发者ID:peterlu,项目名称:ConDDM,代码行数:34,代码来源:FreeImageStack.cpp


示例9: FIA_ShiftImageEdgeToCenter

FIBITMAP* DLL_CALLCONV
FIA_ShiftImageEdgeToCenter(FIBITMAP *src)
{
	int width = FreeImage_GetWidth(src);
	int height = FreeImage_GetHeight(src);
	int xhalf = (width / 2);
	int yhalf = (height / 2);
	int bytes_pp = FreeImage_GetBPP(src) / 8;
	int xhalf_bytes = xhalf * bytes_pp;

	//std::cout << "width " << width << std::endl;
	//std::cout << "xhalf " << xhalf << std::endl;
	
	FIBITMAP *dst = FIA_CloneImageType(src, width, height);

	for(int y=0; y < yhalf; y++) { 
		
		BYTE* srcbits = (BYTE *) FIA_GetScanLineFromTop(src, y);
		BYTE* outbits = (BYTE *) FIA_GetScanLineFromTop(dst, y + yhalf);

		memcpy(outbits + xhalf_bytes, srcbits, xhalf_bytes);
		memcpy(outbits, srcbits + xhalf_bytes, xhalf_bytes);
	}

	for(int y=yhalf; y < height; y++) { 
		
		BYTE* srcbits = (BYTE *) FIA_GetScanLineFromTop(src, y);
		BYTE* outbits = (BYTE *) FIA_GetScanLineFromTop(dst, y - yhalf);

		memcpy(outbits + xhalf_bytes, srcbits, xhalf_bytes);
		memcpy(outbits, srcbits + xhalf_bytes, xhalf_bytes);
	}

	return dst;
}
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:35,代码来源:FreeImageAlgorithms_FFT.cpp


示例10: invertColor

/**
Invert only color components, skipping Alpha/Black
(Can be useful as public/utility function)
*/
static
BOOL invertColor(FIBITMAP* dib) {
	FREE_IMAGE_TYPE type = FreeImage_GetImageType(dib);
	const unsigned Bpp = FreeImage_GetBPP(dib)/8;
	
	if((type == FIT_BITMAP && Bpp == 4) || type == FIT_RGBA16) {
		const unsigned width = FreeImage_GetWidth(dib);
		const unsigned height = FreeImage_GetHeight(dib);
		BYTE *line_start = FreeImage_GetScanLine(dib, 0);
		const unsigned pitch = FreeImage_GetPitch(dib);
		const unsigned triBpp = Bpp - (Bpp == 4 ? 1 : 2);
				
		for(unsigned y = 0; y < height; y++) {
			BYTE *line = line_start;

			for(unsigned x = 0; x < width; x++) {
				for(unsigned b=0; b < triBpp; ++b) {
					line[b] = ~line[b];
				}
					
				line += Bpp;
			}
			line_start += pitch;
		}
		
		return TRUE;
	}
	else {
		return FreeImage_Invert(dib);
	}
}
开发者ID:EduardoFF,项目名称:argos2-RoboNetSim,代码行数:35,代码来源:PSDParser.cpp


示例11: 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


示例12: FreeImage_GetWidth

template<class Tdst, class Tsrc> FIBITMAP* 
CONVERT_TYPE<Tdst, Tsrc>::convert(FIBITMAP *src, FREE_IMAGE_TYPE dst_type) {

	FIBITMAP *dst = NULL;

	unsigned width	= FreeImage_GetWidth(src);
	unsigned height = FreeImage_GetHeight(src);
	unsigned bpp	= FreeImage_GetBPP(src);

	// allocate dst image

	dst = FreeImage_AllocateT(dst_type, width, height, bpp, 
			FreeImage_GetRedMask(src), FreeImage_GetGreenMask(src), FreeImage_GetBlueMask(src));
	if(!dst) return NULL;

	// convert from src_type to dst_type
	
	for(unsigned y = 0; y < height; y++) {
		const Tsrc *src_bits = reinterpret_cast<Tsrc*>(FreeImage_GetScanLine(src, y));
		Tdst *dst_bits = reinterpret_cast<Tdst*>(FreeImage_GetScanLine(dst, y));

		for(unsigned x = 0; x < width; x++) {
			*dst_bits++ = static_cast<Tdst>(*src_bits++);
		}
	}

	return dst;
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:28,代码来源:ConversionType.cpp


示例13: FreeImage_GetBackgroundColor

BOOL DLL_CALLCONV
FreeImage_GetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor) {
	if(dib && bkcolor) {
		if(FreeImage_HasBackgroundColor(dib)) {
			// get the background color
			RGBQUAD *bkgnd_color = &((FREEIMAGEHEADER *)dib->data)->bkgnd_color;
			memcpy(bkcolor, bkgnd_color, sizeof(RGBQUAD));
			// get the background index
			if(FreeImage_GetBPP(dib) == 8) {
				RGBQUAD *pal = FreeImage_GetPalette(dib);
				for(unsigned i = 0; i < FreeImage_GetColorsUsed(dib); i++) {
					if(bkgnd_color->rgbRed == pal[i].rgbRed) {
						if(bkgnd_color->rgbGreen == pal[i].rgbGreen) {
							if(bkgnd_color->rgbBlue == pal[i].rgbBlue) {
								bkcolor->rgbReserved = (BYTE)i;
								return TRUE;
							}
						}
					}
				}
			}

			bkcolor->rgbReserved = 0;

			return TRUE;
		}
	}

	return FALSE;
}
开发者ID:2php,项目名称:ogre-android,代码行数:30,代码来源:BitmapAccess.cpp


示例14: 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


示例15: TestFIA_ColourTextTest

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

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);
    
    FIBITMAP *dst = FreeImage_ConvertTo24Bits(src);

    FIA_DrawHorizontalColourText (dst, 10, 10, FIA_AGG_FONT_VERDANA_12_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 0));
    FIA_DrawHorizontalColourText (dst, 10, 40, FIA_AGG_FONT_VERDANA_16, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 0, 255));
    FIA_DrawHorizontalColourText (dst, 10, 60, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));
	FIA_DrawHorizontalColourText (dst, 1000, 600, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));
	FIA_DrawHorizontalColourText (dst, -500, -600, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));
	FIA_DrawHorizontalColourText (dst, 0, 200, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));
	FIA_DrawHorizontalColourText (dst, 0, 300, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));

	bpp = FreeImage_GetBPP(dst);

    CuAssertTrue(tc, dst != NULL);

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

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


示例16: m_path

		Texture::Texture(std::string path)
			: m_path(path)
		{
			Texture* previousTexture = TextureStore::get(m_path);
			if (previousTexture != nullptr)
			{
				m_location = previousTexture->getLocation();
				m_width = previousTexture->getWidth();
				m_height = previousTexture->getHeight();
				return;
			}
			TextureStore::add(this);

			GLubyte* textureData = loadToBitmap(m_path);

			glGenTextures(1, &m_location);
			glBindTexture(GL_TEXTURE_2D, m_location);

			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, textureData);

			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

			glGenerateMipmap(GL_TEXTURE_2D);

			GLuint bitsPerPixel = FreeImage_GetBPP(m_bitmap);
			FreeImage_Unload(m_bitmap32);
			if (bitsPerPixel != 32)
				FreeImage_Unload(m_bitmap);
		}
开发者ID:Christopherbikie,项目名称:Bipolar,代码行数:30,代码来源:Texture.cpp


示例17: AlphaBlend

/**
Pre-multiplies a 32-bit image's red-, green- and blue channels with it's alpha channel 
for to be used with e.g. the Windows GDI function AlphaBlend(). 
The transformation changes the red-, green- and blue channels according to the following equation:  
channel(x, y) = channel(x, y) * alpha_channel(x, y) / 255  
@param dib Input/Output dib to be premultiplied
@return Returns TRUE on success, FALSE otherwise (e.g. when the bitdepth of the source dib cannot be handled). 
*/
BOOL DLL_CALLCONV 
FreeImage_PreMultiplyWithAlpha(FIBITMAP *dib) {
	if (!dib) return FALSE;
	
	if ((FreeImage_GetBPP(dib) != 32) || (FreeImage_GetImageType(dib) != FIT_BITMAP)) {
		return FALSE;
	}

	int width = FreeImage_GetWidth(dib);
	int height = FreeImage_GetHeight(dib);

	for(int y = 0; y < height; y++) {
		BYTE *bits = FreeImage_GetScanLine(dib, y);
		for (int x = 0; x < width; x++, bits += 4) {
			const BYTE alpha = bits[FI_RGBA_ALPHA];
			// slightly faster: care for two special cases
			if(alpha == 0x00) {
				// special case for alpha == 0x00
				// color * 0x00 / 0xFF = 0x00
				bits[FI_RGBA_BLUE] = 0x00;
				bits[FI_RGBA_GREEN] = 0x00;
				bits[FI_RGBA_RED] = 0x00;
			} else if(alpha == 0xFF) {
				// nothing to do for alpha == 0xFF
				// color * 0xFF / 0xFF = color
				continue;
			} else {
				bits[FI_RGBA_BLUE] = (BYTE)((alpha * (WORD)bits[FI_RGBA_BLUE]) / 255);
				bits[FI_RGBA_GREEN] = (BYTE)((alpha * (WORD)bits[FI_RGBA_GREEN]) / 255);
				bits[FI_RGBA_RED] = (BYTE)((alpha * (WORD)bits[FI_RGBA_RED]) / 255);
			}
		}
	}
	return TRUE;
}
开发者ID:Ayane,项目名称:BLPConverter,代码行数:43,代码来源:Display.cpp


示例18: sFileName_

FreeImageStack::FreeImageStack(const std::string & rFileName): sFileName_(rFileName)
                                                             , pImageStack_(0)
                                                             , nWidth_(0)
                                                             , nHeight_(0)
                                                             , pBitmap_32f_(0)
                                                             , nMaxXY_(0)
                                                             , nMaxOffset_(0)
{
            // open the bitmap
    pImageStack_ = FreeImage_OpenMultiBitmap(FIF_TIFF, (sFileName_ + ".tif").c_str(), 
                                             FALSE, // create new
                                             TRUE,  // open read-only
                                             FALSE, // keep all slices in memory
                                             TIFF_DEFAULT);
    NPP_ASSERT_NOT_NULL(pImageStack_);
    NPP_ASSERT_NOT_NULL(slices());
    FIBITMAP * pBitmap = FreeImage_LockPage(pImageStack_, 0);
            // store away the size of the first image
            // this information is later used to insure that all slices
            // accessed are of the same size. if they are not an exception
            // is thrown when such a deviating slice is being accessed
    nWidth_  = FreeImage_GetWidth(pBitmap);
    nHeight_ = FreeImage_GetHeight(pBitmap);
    NPP_ASSERT(FreeImage_GetColorType(pBitmap) == FIC_MINISBLACK);
    NPP_ASSERT(FreeImage_GetBPP(pBitmap) == 8);
    FreeImage_UnlockPage(pImageStack_, pBitmap, FALSE);
}
开发者ID:peterlu,项目名称:ConDDM,代码行数:27,代码来源:FreeImageStack.cpp


示例19: NanScope

Image *Image::New(FIBITMAP* dib) {
  NanScope();

  Local<Value> arg = NanNew<Integer>(0);
  Local<Object> obj = NanNew<FunctionTemplate>(constructor_template)->GetFunction()->NewInstance(1, &arg);

  Image *image = ObjectWrap::Unwrap<Image>(obj);

  int w,h,pitch;
  FREE_IMAGE_TYPE type = FreeImage_GetImageType(dib);

  obj->SetInternalField(0, NanNew<External>(dib));
  obj->Set(NanNew<String>("width"), NanNew<Integer>(w=FreeImage_GetWidth(dib)));
  obj->Set(NanNew<String>("height"), NanNew<Integer>(h=FreeImage_GetHeight(dib)));
  obj->Set(NanNew<String>("bpp"), NanNew<Integer>((int)FreeImage_GetBPP(dib)));
  obj->Set(NanNew<String>("pitch"), NanNew<Integer>(pitch=FreeImage_GetPitch(dib)));
  obj->Set(NanNew<String>("type"), NanNew<Integer>(type));
  obj->Set(NanNew<String>("redMask"), NanNew<Integer>((int)FreeImage_GetRedMask(dib)));
  obj->Set(NanNew<String>("greenMask"), NanNew<Integer>((int)FreeImage_GetGreenMask(dib)));
  obj->Set(NanNew<String>("blueMask"), NanNew<Integer>((int)FreeImage_GetBlueMask(dib)));

  BYTE *bits = FreeImage_GetBits(dib);
  obj->Set(NanNew<String>("buffer"), NanNewBufferHandle((char*) bits, h * pitch));

  return image;
}
开发者ID:luismreis,项目名称:node-image,代码行数:26,代码来源:Image.cpp


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FreeImage_GetBits函数代码示例发布时间:2022-05-30
下一篇:
C++ FreeImage_DeInitialise函数代码示例发布时间: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