mirror of
https://github.com/KrisKennaway/ii-pix.git
synced 2024-10-02 15:54:31 +00:00
In 140px resolution show the output image with and without NTSC fringing
This commit is contained in:
parent
f9f1398969
commit
9f0cd870e7
18
convert.py
18
convert.py
@ -14,7 +14,6 @@ import screen as screen_py
|
||||
|
||||
# TODO:
|
||||
# - support alternate palettes properly
|
||||
# - include fringing in 140px output
|
||||
# - compare to bmp2dhr and a2bestpix
|
||||
# - support LR/DLR
|
||||
# - support HGR
|
||||
@ -72,15 +71,26 @@ def main():
|
||||
output_4bit, output_rgb = dither_pyx.dither_image(
|
||||
screen, resized, dither, lookahead)
|
||||
print(time.time() - start)
|
||||
screen.pack(output_4bit)
|
||||
|
||||
if args.resolution == 140:
|
||||
# Show un-fringed 140px output image
|
||||
out_image = Image.fromarray(image_py.linear_to_srgb(output_rgb).astype(
|
||||
np.uint8))
|
||||
if args.show_output:
|
||||
image_py.resize(out_image, 560, 384, srgb_output=True).show()
|
||||
|
||||
bitmap = screen.pack(output_4bit)
|
||||
output_rgb = screen.bitmap_to_image_rgb(bitmap)
|
||||
|
||||
# Show output image
|
||||
out_image = Image.fromarray(image_py.linear_to_srgb(output_rgb).astype(
|
||||
np.uint8))
|
||||
outfile = os.path.join(os.path.splitext(args.output)[0] + ".png")
|
||||
out_image.save(outfile, "PNG")
|
||||
if args.show_output:
|
||||
image_py.resize(out_image, 560, 384, srgb_output=True).show()
|
||||
|
||||
outfile = os.path.join(os.path.splitext(args.output)[0] + ".png")
|
||||
out_image.save(outfile, "PNG")
|
||||
|
||||
with open(args.output, "wb") as f:
|
||||
f.write(bytes(screen.main))
|
||||
f.write(bytes(screen.aux))
|
||||
|
12
screen.py
12
screen.py
@ -50,6 +50,18 @@ class Screen:
|
||||
self.aux[addr:addr + 40] = aux_col[y, :]
|
||||
self.main[addr:addr + 40] = main_col[y, :]
|
||||
|
||||
return bitmap
|
||||
|
||||
def bitmap_to_image_rgb(self, bitmap: np.ndarray) -> np.ndarray:
|
||||
image_rgb = np.empty((192, 560, 3), dtype=np.uint8)
|
||||
for y in range(self.Y_RES):
|
||||
pixel = [False, False, False, False]
|
||||
for x in range(560):
|
||||
pixel[x % 4] = bitmap[y, x]
|
||||
dots = self.palette.DOTS_TO_4BIT[tuple(pixel)]
|
||||
image_rgb[y, x, :] = self.palette.RGB[dots]
|
||||
return image_rgb
|
||||
|
||||
def pixel_palette_options(self, last_pixel_4bit, x: int):
|
||||
raise NotImplementedError
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user