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:
1 parent
26987fc497
commit
a61a22ab43
1 file changed
+4
-2
+4
-2
@@ -155,6 +155,7 @@ class PPM:
|
|||||||
self.RawThumbnail = None
|
self.RawThumbnail = None
|
||||||
self.SoundData = None
|
self.SoundData = None
|
||||||
self.forced_speed = forced_speed
|
self.forced_speed = forced_speed
|
||||||
|
self.LayerVisibility = (True, True)
|
||||||
def ReadFile(self, path, DecodeThumbnail=False, ReadFrames=True, ReadSound=False):#Load: (thumbnail, frames, sound)
|
def ReadFile(self, path, DecodeThumbnail=False, ReadFrames=True, ReadSound=False):#Load: (thumbnail, frames, sound)
|
||||||
f = open(path, "rb")
|
f = open(path, "rb")
|
||||||
ret = self.Read(f.read(), DecodeThumbnail, ReadFrames, ReadSound)
|
ret = self.Read(f.read(), DecodeThumbnail, ReadFrames, ReadSound)
|
||||||
@@ -199,6 +200,7 @@ class PPM:
|
|||||||
|
|
||||||
#read the animation sequence header:
|
#read the animation sequence header:
|
||||||
self.Looped = data[0x06A6] >> 1 & 0x01 == 1#Unverified?
|
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)
|
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)]
|
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 = np.zeros((256, 192), dtype=">u4")
|
||||||
out[:] = Palette[0]
|
out[:] = Palette[0]
|
||||||
out[Frame[1]] = Color2
|
if self.LayerVisibility[1]: out[Frame[1]] = Color2
|
||||||
out[Frame[0]] = Color1
|
if self.LayerVisibility[0]: out[Frame[0]] = Color1
|
||||||
|
|
||||||
return out
|
return out
|
||||||
def GetThumbnail(self, force=False):
|
def GetThumbnail(self, force=False):
|
||||||
|
|||||||
Reference in new issue
Block a user
