diff --git a/core/PRP/Surface/plMipmap.h b/core/PRP/Surface/plMipmap.h index 3b80cab3..dff6f2d4 100644 --- a/core/PRP/Surface/plMipmap.h +++ b/core/PRP/Surface/plMipmap.h @@ -82,6 +82,7 @@ class HSPLASMA_EXPORT plMipmap : public plBitmap unsigned int getWidth() const { return fWidth; } unsigned int getHeight() const { return fHeight; } const void* getImageData() const { return fImageData; } + void* getImageData() { return fImageData; } size_t getTotalSize() const { return fTotalSize; } size_t getNumLevels() const { return fLevelData.size(); } unsigned int getLevelSize(size_t idx) const { return fLevelData[idx].fSize; } diff --git a/core/Util/plJPEG.cpp b/core/Util/plJPEG.cpp index 13815247..d18d9b44 100644 --- a/core/Util/plJPEG.cpp +++ b/core/Util/plJPEG.cpp @@ -192,6 +192,18 @@ void plJPEG::DecompressJPEG(hsStream* S, void* buf, size_t size) offs += out_stride; } + // Data stored as RGB on disk but Plasma uses BGR + if (reinterpret_cast(buf) % alignof(uint32_t) != 0) + throw hsBadParamException(__FILE__, __LINE__, "buf should be aligned on a 32-bit boundary"); + + uint32_t* dp = reinterpret_cast(buf); + for (size_t i=0; i> 16 + | (*dp & 0x000000FF) << 16; + dp++; + } + jpeg_finish_decompress(&ji.dinfo); }