Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ FreeImage报告图像颜色类型错误_C++_Opengl_Freeimage - Fatal编程技术网

C++ FreeImage报告图像颜色类型错误

C++ FreeImage报告图像颜色类型错误,c++,opengl,freeimage,C++,Opengl,Freeimage,我有以下代码来加载纹理 PackageTexture AssetImporter::ProcessTexture(const boost::filesystem::path& assetPath, const TextureType textureType) { PackageTexture texture; const std::string filename = assetPath.filename().string(); FREE_IMAGE_FORMAT

我有以下代码来加载纹理

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。A.tga图像正确报告为RGBA32


可能是什么问题?

首先,FreeImage\u GetColorType返回位图颜色类型它可能与原始图像不同

从文档:

颜色模型 颜色模型是一个抽象的数学模型,描述了颜色的表现方式 表示为数字元组,通常为三个或四个值或颜色分量,例如RGB和CMYK是颜色模型。FreeImage主要使用RGB[A]颜色模型 表示内存中的像素