我有下面的代码来加载纹理。
PackageTexture AssetImporter::ProcessTexture(const boost::filesystem::path& assetPath, const TextureType textureType)
{
PackageTexture texture;
const std::string filename = assetPath.filename().string();
FREE_IMAGE_FORMAT imageFormat = FreeImage_GetFileType(filename.c_str());
if (imageFormat == FIF_UNKNOWN)
imageFormat = FreeImage_GetFIFFromFilename(filename.c_str());
if (imageFormat == FIF_UNKNOWN || !FreeImage_FIFSupportsReading(imageFormat))
return texture;
FIBITMAP* bitmap = FreeImage_Load(imageFormat, assetPath.string().c_str());
if (!bitmap || !FreeImage_GetBits(bitmap) || !FreeImage_GetWidth(bitmap) || !FreeImage_GetHeight(bitmap))
return texture;
FREE_IMAGE_COLOR_TYPE colorType = FreeImage_GetColorType(bitmap);
uint32_t bitsPerPixel = FreeImage_GetBPP(bitmap);
uint32_t widthInPixels = FreeImage_GetWidth(bitmap);
uint32_t heightInPixels = FreeImage_GetHeight(bitmap);
....
FreeImage_Unload(bitmap);
return texture;
}问题是,"colorType“给了我错误的颜色类型。例如,.jpg被报告为rgb24,而它是bgr24,而.dds映像,即BRGA32,则报告为RGBA32。然而,.tga图像被正确地报告为RGBA32。
问题可能是什么?
发布于 2013-11-03 18:16:33
首先,FreeImage_GetColorType返回位图颜色类型(它可能与原始图像不同)。
从医生那里:
颜色模型颜色模型是一个抽象的数学模型,描述了颜色可以用数字元组表示的方式,通常表示为三或四个值或颜色分量(例如RGB和CMYK是颜色模型)。FreeImage主要使用RGBA颜色模型来表示内存中的像素。
https://stackoverflow.com/questions/19755283
复制相似问题