AFAIR .bmp numbers rows bottom to top, while .tga --- the other way around. That's why those images are flipped.Originally Posted by KShots
AFAIR .bmp numbers rows bottom to top, while .tga --- the other way around. That's why those images are flipped.Originally Posted by KShots
Ah, I think I see what's going on, then... though I'm still confused why OGL handles it correctly.
Yeah, it looks like you're right, it's not rotated 90 degrees counter-clockwise, it's upside down. It's really hard to tell with the size of the icons, but I think you're right. It also seems that the red and the blue bytes are swapped.
I'll probably have to have a function that goes in and adjusts that inside a QImage in the case of targa files. I'm not entirely sure what writing a QImageIOPlugin gives me if I'm reading the data from memory rather than a file (with the header stripped out).
I'm still not sure what's going on with the BMP stuff above, either... that corruption really bothers me.
EDIT: Fixing the targa was... well... easy enough. I had to do an image = image.rgbSwapped(); and an image = image.mirrored() to get it to show up correctly... but it did. I guess that'll have to do for the targas.
Still mystified with the .bmp corruption
EDIT2: I think I've figured out what's going on with the bitmaps... by definition, as bitmaps, they're 24-bits per pixel. QImage only seems to take 32-bits per pixel (unless I'm missing something important). Therefore, when QImage reads in a pixel, it's expecting 0xFFRRGGBB... and I'm giving it 0xRRGGBB... so the 1st pixel is 0xRRGGBBRR, then 2nd pixel is 0xGGBBRRGG, and so on. No wonder it looks corrupted. Any ideas on how to force QImage to read in 24-bits rather than 32?
Last edited by KShots; 20th July 2006 at 05:02.
Life without passion is death in disguise
You are looking for QImage::Format_ARGB32 to read in 0xAARRGGBB. However, it won't work for targa since targa is 0xBBGGRRAA (AA = alpha-channel) - if I remember correctly (should be, wrote my own targa reader two days ago... but left it at work).
If you are loading targa images keep in mind that the targa header is 18 bytes so if you read it as a struct the sizeof(tgaheaderstruct) will still be 20 (unless #pragma pack(1) was specified). That reading 20 instead of 18 bytes also explains wrong colours as the pointer onto the datastream starts with the wrong color code.
Yeah, I got my targas working a while ago, I used the functions mentioned in my last post to correct it - my problem now is with my bitmapsOriginally Posted by Methedrine
Hmm... that explains why I recently had to rebuild my texture loader recently - it just suddenly refused to load the header correctly. I ended up having to read it in variable by variable to get it to read the right sized chunk.Originally Posted by Methedrine
Anyways... the targa's been behaving well... any ideas on the bitmaps?
Life without passion is death in disguise
Alright... I think I solved my problem(s). It appears Qt does not support loading in bitmaps from raw data - I had to convert my (already loaded) bitmap into a 32-bit image through opengl, then pass it over to Qt, like so:On the one hand, I'm a little disappointed that Qt has no way of handling raw 24-bit images... but on the other hand, I found that I didn't need to store my textures in memory if I can retrieve them from OGL easilyQt Code:
//I start with a 24-bit bitmap raw-loaded into OpenGL unsigned char * pixelData = new unsigned char * [4 * texture->GetWidth() * texture->GetHeight()]; glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelData); //Now I have a 32-bit texture loaded into memory... delete [] pixelData; image = image.rgbSwapped(); image = image.mirrored();To copy to clipboard, switch view to plain text mode
Life without passion is death in disguise
I think I'd have used QFile to read the targa into a QByteArray (simply add the missing byte for a rgb32!) which in turn I'd then use to construct a QImage which would then be assigned to a QPixmap.
But then again if you are writing something based upon OpenGL you're probably doing it correctly anyway.
Bookmarks