我有以下代码来加载纹理。
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。
可能是什么问题?