Skip to content

Commit

Permalink
GL|Fixed: Red-blue swapped images
Browse files Browse the repository at this point in the history
It seems that if Image_LoadFromFileWithFormat() returns an image with
depth==3, someone else on a lower level is swapping the red and blue
channels. Now all paletted images are converted to 32-bit ARGB
regardless of whether there's an alpha channel.
  • Loading branch information
skyjake committed Jun 19, 2012
1 parent 9fcf34f commit 7a6a854
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions doomsday/engine/portable/src/image.cpp
Expand Up @@ -22,6 +22,8 @@

#include "de_base.h"
#include "de_console.h"
//#include "abstractfile.h"
//#include "filelist.h"
#include "m_misc.h"
#include "image.h"

Expand Down Expand Up @@ -158,23 +160,18 @@ boolean Image_LoadFromFileWithFormat(image_t* img, const char* format, DFile* fi
return false;
}

//Con_Message("Loading %s\n", Str_Text(AbstractFile_Path(DFile_File_Const(file))));

// Convert paletted images to RGB.
if(image.colorCount() && !image.hasAlphaChannel())
{
image = image.convertToFormat(QImage::Format_RGB888);
assert(!image.colorCount());
assert(image.depth() == 24);
}
else if(image.colorCount() && image.hasAlphaChannel())
if(image.colorCount())
{
image = image.convertToFormat(QImage::Format_ARGB32);
assert(!image.colorCount());
assert(image.depth() == 32);
}
else
{
// Swap the red and blue channels.
image = image.rgbSwapped();
}

// Swap the red and blue channels for GL.
image = image.rgbSwapped();

img->size.width = image.width();
img->size.height = image.height();
Expand Down

0 comments on commit 7a6a854

Please sign in to comment.