Skip to content

Commit

Permalink
Merge pull request #292 from Hoikas/jpeg_roundtrip
Browse files Browse the repository at this point in the history
Allow Python to access the JPEG cache.
  • Loading branch information
zrax authored Dec 7, 2024
2 parents b04ad4a + 1373a26 commit 66db9b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Python/PRP/Surface/pyMipmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
2 changes: 2 additions & 0 deletions Python/PyHSPlasma.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4110,6 +4110,8 @@ class plMipmap(plBitmap):

height: int = ...
imageData: bytes = ...
jpegAlpha: bytes = ...
jpegImage: bytes = ...
numLevels: int = ...
width: int = ...

Expand Down

0 comments on commit 66db9b8

Please sign in to comment.