Initial commit

This commit is contained in:
Michael Smith
2023-05-04 11:24:05 +02:00
commit f7b57817ff
9 changed files with 307971 additions and 0 deletions

26
bitmap.py Normal file
View File

@@ -0,0 +1,26 @@
import json
import pygame
from palette import Palette
class Bitmap:
def __init__(self, filepath):
with open(filepath,) as jsonfile:
image = json.load(jsonfile)
self.filename = image['filename']
self.width = image['width']
self.height = image['height']
self.pixels = image['pixels']
self.palette = Palette(image['colors'], image['cycles'])
self.surface = pygame.Surface((self.width, self.height), 0, 8)
self.surface.set_palette(self.palette.colors)
# Load image onto surface
with pygame.PixelArray(self.surface) as pixels:
for x in range(self.width):
for y in range(self.height):
offset = x + (y * self.width)
pixels[x, y] = self.pixels[offset]