Determine palette bit from first *non-black* pixel on the row

This commit is contained in:
Rob McMullen 2017-06-22 10:27:58 -07:00
parent a5907dc2e3
commit 2c4a951a27
1 changed files with 7 additions and 3 deletions

View File

@ -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