From 2c4a951a27a6b9afc1d7c03dbfad466960716353 Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Thu, 22 Jun 2017 10:27:58 -0700 Subject: [PATCH] Determine palette bit from first *non-black* pixel on the row --- HiSprite.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/HiSprite.py b/HiSprite.py index 755d94e..a5887b5 100755 --- a/HiSprite.py +++ b/HiSprite.py @@ -500,11 +500,18 @@ class HGR(ScreenFormat): for row in range(source.height): bitStream = "" + highBit = "0" + highBitFound = False # Compute raw bitstream for row from PNG pixels for pixelIndex in range(source.width): pixel = self.pixelColor(source.pixelData,row,pixelIndex) bitStream += bitDelegate(pixel) + + # Determine palette bit from first non-black pixel on each row + if not highBitFound and pixel != self.black and pixel != self.key: + highBit = highBitDelegate(pixel) + highBitFound = True # Shift bit stream as needed bitStream = shiftStringRight(bitStream, shift, self.bitsPerPixel) @@ -530,9 +537,6 @@ class HGR(ScreenFormat): bitChunk = bitChunk[::-1] - # Determine palette bit from first pixel on each row - highBit = highBitDelegate(source.pixelData[row][0]) - byteSplits[byteIndex] = highBit + bitChunk bitPos += 7