Blp Uncompressed is bgra, not rgba

Reported bugs that have been closed and/or resolved

Moderators: XnTriq, helmut, xnview, Dreamer

Post Reply
Stiven
Posts: 4
Joined: Mon Feb 12, 2018 11:31 am

Blp Uncompressed is bgra, not rgba

Post by Stiven »

XnView: MP 0.98.4 - 64 bit
OS: Windows - 64bit

XnViewMP load BLP pictures with the wrong colors

Effect: just getting wrong picture colors

To reproduce:
1. Download original blp file from: https://wow.tools/casc/file/chash?conte ... les915.blp
2. This is how the image should look https://wow.tools/casc/preview/chash?bu ... 04dd466d8f
3. XnViewMP show up wrong colors when u open blp file.

I have attached how the image looks when u open that blp in XNViewMP
ShopBundles915.jpg
Expected colors:
ShopBundles915Correct.jpg
Solution:

The header of blp

Code: Select all

struct BlpFile{
    uint32_t fileIdent;
    int32_t version;
    uint8_t colorEncoding;
    uint8_t alphaChannelBitDepth;
    uint8_t preferredFormat;
    uint8_t mipmap_level_and_flags;
    int32_t width;
    int32_t height;
    int32_t offsets[16];
    int32_t lengths[16];
    uint8_t palette[1024];
};
if preferredFormat is 8 and colorEncoding is 3, the data is in BGRA format and it needs flipping to RGBA
For example:

Code: Select all

if (blpFile->colorEncoding == 3) {
    //Turn BGRA into RGBA

    validSize = 4 * width * height;
    mipmapStruct.texture = std::vector<uint8_t>(validSize, 0);
    for (int j = 0; j < width * height; j++) {
        uint8_t b = data[j * 4 + 0];
        uint8_t g = data[j * 4 + 1];
        uint8_t r = data[j * 4 + 2];
        uint8_t a = data[j * 4 + 3];

        mipmapStruct.texture[j * 4 + 0] = r;
        mipmapStruct.texture[j * 4 + 1] = g;
        mipmapStruct.texture[j * 4 + 2] = b;
        mipmapStruct.texture[j * 4 + 3] = a;
    }
}
User avatar
xnview
Author of XnView
Posts: 43442
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Blp Uncompressed is bgra, not rgba

Post by xnview »

:bugconfirmed: Thanks to your detailed description I can reproduce the problem.
Pierre.
User avatar
xnview
Author of XnView
Posts: 43442
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Blp Uncompressed is bgra, not rgba

Post by xnview »

This problem is supposed to be fixed in XnView MP 0.99.0. Please check and confirm the bug fix here.
Pierre.
Stiven
Posts: 4
Joined: Mon Feb 12, 2018 11:31 am

Re: Blp Uncompressed is bgra, not rgba

Post by Stiven »

The new uncompressed brgra was fixed but the problem is that I feel that now you have flipped all blp to RGBA what it shouldn't do. (I can't see the source code so I can see what's going on)

Now blp files that were working correctly before are broken.

Example:
Download BLP file:
https://wow.tools/casc/file/chash?conte ... 252376.blp

How it should look:
highmountaintaurenfemale_face_4252376.png
highmountaintaurenfemale_face_4252376.png (219.56 KiB) Viewed 2111 times
How it looks in xnviewmp (wrong):
FILEDATA_4252395.png
FILEDATA_4252395.png (219.31 KiB) Viewed 2111 times

I can confirm that bug I reported was fixed. But I feel this fix was implemented for all cases, which shouldn't be done. And now the normal blp formats are broken.
User avatar
xnview
Author of XnView
Posts: 43442
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Blp Uncompressed is bgra, not rgba

Post by xnview »

right, re-opened
Pierre.
User avatar
xnview
Author of XnView
Posts: 43442
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Blp Uncompressed is bgra, not rgba

Post by xnview »

This problem is supposed to be fixed in XnView MP 0.99.1. Please check and confirm the bug fix here.
Pierre.
Stiven
Posts: 4
Joined: Mon Feb 12, 2018 11:31 am

Re: Blp Uncompressed is bgra, not rgba

Post by Stiven »

Hello,

To confirm everything is working as intended now.

Thanks for the quick fix and release :)
Post Reply