fix(ppm): respect hidden layers when rendering frames

Read both layer-visibility flags and omit disabled layers from rendered images.
This commit is contained in:
rekushi committed 2026-10-29 04:24:33 +00:00
1 parent 26987fc497
commit a61a22ab43
1 file changed
+4 -2
+4 -2
View File
@@ -155,6 +155,7 @@ class PPM:
self.RawThumbnail = None
self.SoundData = None
self.forced_speed = forced_speed
self.LayerVisibility = (True, True)
def ReadFile(self, path, DecodeThumbnail=False, ReadFrames=True, ReadSound=False):#Load: (thumbnail, frames, sound)
f = open(path, "rb")
ret = self.Read(f.read(), DecodeThumbnail, ReadFrames, ReadSound)
@@ -199,6 +200,7 @@ class PPM:
#read the animation sequence header:
self.Looped = data[0x06A6] >> 1 & 0x01 == 1#Unverified?
self.LayerVisibility = (not bool(data[0x06A6] & 0x10), not bool(data[0x06A6] & 0x20))
AnimationOffset = 0x6a8 + AscDec(data[0x6a0:0x6a4], True)
FrameOffsets = [AnimationOffset + AscDec(data[0x06a8+i*4:0x06a8+i*4+4], True) for i in range(self.FrameCount)]
@@ -269,8 +271,8 @@ class PPM:
out = np.zeros((256, 192), dtype=">u4")
out[:] = Palette[0]
out[Frame[1]] = Color2
out[Frame[0]] = Color1
if self.LayerVisibility[1]: out[Frame[1]] = Color2
if self.LayerVisibility[0]: out[Frame[0]] = Color1
return out
def GetThumbnail(self, force=False):