From fb62f2369863325911079c240b357456e326d952 Mon Sep 17 00:00:00 2001 From: Joseph Davies Date: Sun, 23 Oct 2022 12:52:37 -0700 Subject: [PATCH] Remove deprecated DDS<->JPG conversion functions. --- src/PrpShop/PRP/Surface/QMipmap.cpp | 129 ---------------------------- 1 file changed, 129 deletions(-) diff --git a/src/PrpShop/PRP/Surface/QMipmap.cpp b/src/PrpShop/PRP/Surface/QMipmap.cpp index 8e0ae9c..be9f1f6 100644 --- a/src/PrpShop/PRP/Surface/QMipmap.cpp +++ b/src/PrpShop/PRP/Surface/QMipmap.cpp @@ -339,135 +339,6 @@ QMipmap::QMipmap(plCreatable* pCre, QWidget* parent) connect(iPort, &QLinkLabel::activated, this, &QMipmap::onImportImage); } -static void swapColorChannels(unsigned char* data, size_t size) -{ - unsigned int* dp = reinterpret_cast(data); - for (size_t i=0; i> 16 - | (*dp & 0x000000FF) << 16; - dp++; - } -} - -static void makeJColorSurface(const plMipmap* tex, hsStream* S) -{ - if (tex->getCompressionType() != plBitmap::kJPEGCompression) { - QMessageBox::critical(NULL, QObject::tr("Error exporting JPEG"), - QObject::tr("Texture is not in a supported export format"), - QMessageBox::Ok); - return; - } - - plDDSurface dds; - dds.fFlags = plDDSurface::DDSD_CAPS | plDDSurface::DDSD_HEIGHT - | plDDSurface::DDSD_WIDTH | plDDSurface::DDSD_PIXELFORMAT - | plDDSurface::DDSD_LINEARSIZE; - dds.fCaps = plDDSurface::DDSCAPS_TEXTURE; - dds.fHeight = tex->getHeight(); - dds.fWidth = tex->getWidth(); - dds.fLinearSize = dds.fHeight * dds.fWidth * 3; - dds.fPixelFormat.fFlags = plDDSurface::DDPF_RGB; - dds.fPixelFormat.fBitDepth = 24; - dds.fPixelFormat.fRBitMask = 0xFF0000; - dds.fPixelFormat.fGBitMask = 0x00FF00; - dds.fPixelFormat.fBBitMask = 0x0000FF; - - // Strip down data to 24 bit color - unsigned char* data = new unsigned char[dds.fLinearSize]; - tex->extractColorData(data, dds.fLinearSize); - swapColorChannels(data, dds.fLinearSize); - dds.setData(dds.fLinearSize, data); - delete[] data; - - dds.write(S); -} - -static void makeJAlphaSurface(const plMipmap* tex, hsStream* S) -{ - if (tex->getCompressionType() != plBitmap::kJPEGCompression) { - QMessageBox::critical(NULL, QObject::tr("Error exporting JPEG"), - QObject::tr("Texture is not in a supported export format"), - QMessageBox::Ok); - return; - } - - plDDSurface dds; - dds.fFlags = plDDSurface::DDSD_CAPS | plDDSurface::DDSD_HEIGHT - | plDDSurface::DDSD_WIDTH | plDDSurface::DDSD_PIXELFORMAT - | plDDSurface::DDSD_LINEARSIZE; - dds.fCaps = plDDSurface::DDSCAPS_TEXTURE; - dds.fHeight = tex->getHeight(); - dds.fWidth = tex->getWidth(); - dds.fLinearSize = dds.fHeight * dds.fWidth; - dds.fPixelFormat.fFlags = plDDSurface::DDPF_LUMINANCE; - dds.fPixelFormat.fBitDepth = 8; - dds.fPixelFormat.fLuminanceBitMask = 0xFF; - - // Strip down data to alpha luminance - unsigned char* data = new unsigned char[dds.fLinearSize]; - tex->extractAlphaData(data, dds.fLinearSize); - dds.setData(dds.fLinearSize, data); - delete[] data; - - dds.write(S); -} - -static bool getJColorSurface(const plDDSurface& dds, plMipmap* tex) -{ - if ((dds.fFlags & plDDSurface::DDSD_HEIGHT) == 0 || - (dds.fFlags & plDDSurface::DDSD_WIDTH) == 0 || - (dds.fFlags & plDDSurface::DDSD_PIXELFORMAT) == 0) { - QMessageBox::critical(NULL, QObject::tr("Error importing JPEG"), - QObject::tr("DDSurface does not contain required fields"), - QMessageBox::Ok); - return false; - } - if ((dds.fPixelFormat.fFlags & plDDSurface::DDPF_RGB) == 0 || - (dds.fPixelFormat.fBitDepth != 24) || - (dds.fPixelFormat.fRBitMask != 0xFF0000) || - (dds.fPixelFormat.fGBitMask != 0x00FF00) || - (dds.fPixelFormat.fBBitMask != 0x0000FF)) { - QMessageBox::critical(NULL, QObject::tr("Error importing JPEG"), - QObject::tr("DDS file should be in RGB888 format")); - return false; - } - - tex->Create(dds.fWidth, dds.fHeight, 0, plBitmap::kJPEGCompression, plBitmap::kRGB8888); - tex->setColorData(dds.getData(), dds.getDataSize()); - swapColorChannels(reinterpret_cast(tex->getImageData()), dds.getDataSize()); - return true; -} - -static bool getJAlphaSurface(const plDDSurface& dds, plMipmap* tex) -{ - if ((dds.fFlags & plDDSurface::DDSD_HEIGHT) == 0 || - (dds.fFlags & plDDSurface::DDSD_WIDTH) == 0 || - (dds.fFlags & plDDSurface::DDSD_PIXELFORMAT) == 0) { - QMessageBox::critical(NULL, QObject::tr("Error importing JPEG"), - QObject::tr("DDSurface does not contain required fields"), - QMessageBox::Ok); - return false; - } - if ((dds.fPixelFormat.fFlags & plDDSurface::DDPF_LUMINANCE) == 0 || - (dds.fPixelFormat.fBitDepth != 8) || - (dds.fPixelFormat.fLuminanceBitMask != 0xFF)) { - QMessageBox::critical(NULL, QObject::tr("Error importing JPEG"), - QObject::tr("DDS file should be in Luminance 8-bit format"), - QMessageBox::Ok); - return false; - } - - if (tex->getWidth() != dds.fWidth || tex->getHeight() != dds.fHeight) { - QMessageBox::critical(NULL, QObject::tr("Error importing JPEG"), - QObject::tr("Alpha DDS size does not match image size"), - QMessageBox::Ok); - return false; - } - tex->setAlphaData(dds.getData(), dds.getDataSize()); - return true; -} - void QMipmap::onExportImage() { QString exportDir = getExportDir(); plMipmap* tex = plMipmap::Convert(fCreatable);