How to convert image to Rgba

I was making game. I made a character sprite but it’s not transparent. Later i found i needed use Rgba but my image exporter program exports as only ARGB how i can do that. Do you know a website to convert rgb. I tried few sites but these sites only gives me a file .rgba i don’t understand.
Im using freeglut.

First, let’s be clear on terminology. OpenGL format identifiers refer to the order of bytes in memory, so GL_RGBA means that the byte for the red component is first while GL_BGRA means that the byte for the blue component is first. In both cases, the alpha component is last.

Some APIs describe formats in terms of 32-bit words, so “ARGB” would mean that the alpha component is in the top 8 bits of the word: 0xAARRGGBB. On a little-endian architecture (e.g. x86 or x86-64), this would be equivalent to GL_BGRA. Windows APIs have a preference for BGRA, so this layout isn’t uncommon.

So first check whether GL_BGRA works. If it doesn’t (i.e. the exporter really is exporting the alpha channel first), the simplest solution is to swap the data in memory after loading it, e.g.

unsigned char *data = ...;
for (int i = 0; i < num_pixels; i++) {
    unsigned char a = data[0], r = data[1], g=data[2], b=data[3];
    data[0]=r; data[1]=g; data[2]=b; data[3]=a;
    data += 4;
}

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.