Use snake case

This commit is contained in:
Andrew Murray 2023-11-14 22:04:02 +11:00
parent 261a7281cc
commit b4d7a0d476

View File

@ -375,14 +375,14 @@ class Ico1Decoder(ImageFile.PyDecoder):
def decode(self, buffer): def decode(self, buffer):
data = bytearray() data = bytearray()
bitmapLength = self.state.xsize * self.state.ysize // 8 bitmap_length = self.state.xsize * self.state.ysize // 8
firstBitmap = self.fd.read(bitmapLength) first_bitmap = self.fd.read(bitmap_length)
secondBitmap = self.fd.read(bitmapLength) second_bitmap = self.fd.read(bitmap_length)
for i, byte in enumerate(firstBitmap): for i, byte in enumerate(first_bitmap):
secondByte = byte ^ secondBitmap[i] second_byte = byte ^ second_bitmap[i]
for j in reversed(range(8)): for j in reversed(range(8)):
first = byte >> j & 1 first = byte >> j & 1
second = secondByte >> j & 1 second = second_byte >> j & 1
data += b"\x00" if (first == second) else b"\xff" data += b"\x00" if (first == second) else b"\xff"
data += b"\x00" if first else b"\xff" data += b"\x00" if first else b"\xff"
self.set_as_raw(bytes(data)) self.set_as_raw(bytes(data))
@ -393,20 +393,20 @@ class Ico1Encoder(ImageFile.PyEncoder):
_pushes_fd = True _pushes_fd = True
def encode(self, bufsize): def encode(self, bufsize):
firstBitmap = bytearray() first_bitmap = bytearray()
secondBitmap = bytearray() second_bitmap = bytearray()
w, h = self.im.size w, h = self.im.size
for y in range(h): for y in range(h):
for x in range(w): for x in range(w):
l, a = self.im.getpixel((x, y)) l, a = self.im.getpixel((x, y))
if x % 8 == 0: if x % 8 == 0:
firstBitmap += b"\x00" first_bitmap += b"\x00"
secondBitmap += b"\xff" second_bitmap += b"\xff"
if not a: if not a:
firstBitmap[-1] ^= 1 << (7 - x % 8) first_bitmap[-1] ^= 1 << (7 - x % 8)
if not l: if not l:
secondBitmap[-1] ^= 1 << (7 - x % 8) second_bitmap[-1] ^= 1 << (7 - x % 8)
data = firstBitmap + secondBitmap data = first_bitmap + second_bitmap
return len(data), 0, data return len(data), 0, data