From 1373a2683ea4149a4a204a51a9b9cdccbe820782 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 6 Dec 2024 18:28:45 -0500 Subject: [PATCH] Allow Python to access the JPEG cache. This allows Python applications to save JPEGs from PRPs, preventing the Hank Hill hot dog effect from taking place in the future. --- Python/PRP/Surface/pyMipmap.cpp | 20 ++++++++++++++++++++ Python/PyHSPlasma.pyi | 2 ++ 2 files changed, 22 insertions(+) diff --git a/Python/PRP/Surface/pyMipmap.cpp b/Python/PRP/Surface/pyMipmap.cpp index b2de29c5..47fbe24f 100644 --- a/Python/PRP/Surface/pyMipmap.cpp +++ b/Python/PRP/Surface/pyMipmap.cpp @@ -350,11 +350,31 @@ PY_PROPERTY_READ(Mipmap, numLevels, getNumLevels) PY_PROPERTY_SETTER_MSG(Mipmap, numLevels, "To set the number of mip levels, you must re-create the mipmap object") PY_PROPERTY_GETSET_DECL(Mipmap, numLevels) +PY_GETSET_GETTER_DECL(Mipmap, jpegImage) +{ + return PyBytes_FromStringAndSize((const char*)self->fThis->getJpegImage(), + self->fThis->getJpegSize()); +} + +PY_PROPERTY_SETTER_MSG(Mipmap, jpegImage, "To set the image data, use the mipmap set methods") +PY_PROPERTY_GETSET_DECL(Mipmap, jpegImage) + +PY_GETSET_GETTER_DECL(Mipmap, jpegAlpha) +{ + return PyBytes_FromStringAndSize((const char*)self->fThis->getJpegAlpha(), + self->fThis->getJpegAlphaSize()); +} + +PY_PROPERTY_SETTER_MSG(Mipmap, jpegAlpha, "To set the image data, use the mipmap set methods") +PY_PROPERTY_GETSET_DECL(Mipmap, jpegAlpha) + static PyGetSetDef pyMipmap_GetSet[] = { pyMipmap_width_getset, pyMipmap_height_getset, pyMipmap_imageData_getset, pyMipmap_numLevels_getset, + pyMipmap_jpegImage_getset, + pyMipmap_jpegAlpha_getset, PY_GETSET_TERMINATOR }; diff --git a/Python/PyHSPlasma.pyi b/Python/PyHSPlasma.pyi index 0cbb4da2..bd1793bb 100644 --- a/Python/PyHSPlasma.pyi +++ b/Python/PyHSPlasma.pyi @@ -4110,6 +4110,8 @@ class plMipmap(plBitmap): height: int = ... imageData: bytes = ... + jpegAlpha: bytes = ... + jpegImage: bytes = ... numLevels: int = ... width: int = ...