Skip to content

Commit

Permalink
Fix non-DXT image channels
Browse files Browse the repository at this point in the history
All Plasma image data, other than DXT, is stored as BGR in plMipmap
  • Loading branch information
Hoikas committed Aug 21, 2018
1 parent fd8c6c2 commit 1845165
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/PrpShop/PRP/Surface/QMipmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void QTextureBox::setTexture(plMipmap* tex, int level)
fImageData = new unsigned char[size];
tex->DecompressImage(level, fImageData, size);

if (tex->getCompressionType() != plMipmap::kUncompressed) {
if (tex->getCompressionType() == plMipmap::kDirectXCompression) {
// Manipulate the data from RGBA to BGRA
unsigned int* dp = (unsigned int*)fImageData;
for (size_t i=0; i<size; i += 4) {
Expand Down Expand Up @@ -372,9 +372,9 @@ static void makeJColorSurface(const plMipmap* tex, hsStream* S)
dds.fLinearSize = dds.fHeight * dds.fWidth * 3;
dds.fPixelFormat.fFlags = plDDSurface::DDPF_RGB;
dds.fPixelFormat.fBitDepth = 24;
dds.fPixelFormat.fRBitMask = 0xFF0000;
dds.fPixelFormat.fRBitMask = 0x0000FF;
dds.fPixelFormat.fGBitMask = 0x00FF00;
dds.fPixelFormat.fBBitMask = 0x0000FF;
dds.fPixelFormat.fBBitMask = 0xFF0000;

// Strip down data to 24 bit color
unsigned char* data = new unsigned char[dds.fLinearSize];
Expand Down Expand Up @@ -427,9 +427,9 @@ static bool getJColorSurface(const plDDSurface& dds, plMipmap* tex)
}
if ((dds.fPixelFormat.fFlags & plDDSurface::DDPF_RGB) == 0 ||
(dds.fPixelFormat.fBitDepth != 24) ||
(dds.fPixelFormat.fRBitMask != 0xFF0000) ||
(dds.fPixelFormat.fRBitMask != 0x0000FF) ||
(dds.fPixelFormat.fGBitMask != 0x00FF00) ||
(dds.fPixelFormat.fBBitMask != 0x0000FF)) {
(dds.fPixelFormat.fBBitMask != 0xFF0000)) {
QMessageBox::critical(NULL, QObject::tr("Error importing JPEG"),
QObject::tr("DDS file should be in RGB888 format"));
return false;
Expand Down

0 comments on commit 1845165

Please sign in to comment.