From b284d7badae1dc11820e3cc769f487c7dd4283b8 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Fri, 20 Nov 2020 20:42:05 -0600 Subject: [PATCH] f --- pixie.nimble | 1 - src/pixie/fileformats/png.nim | 33 +++++++++++---------------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/pixie.nimble b/pixie.nimble index 3604207..0ab5f66 100644 --- a/pixie.nimble +++ b/pixie.nimble @@ -1,4 +1,3 @@ -packageName = "pixie" version = "0.0.1" author = "Andre von Houck and Ryan Oldenburg" description = "Full-featured 2d graphics library for Nim." diff --git a/src/pixie/fileformats/png.nim b/src/pixie/fileformats/png.nim index 3a75136..2c1dcaf 100644 --- a/src/pixie/fileformats/png.nim +++ b/src/pixie/fileformats/png.nim @@ -151,18 +151,12 @@ proc parseImageData( uncompressed = try: uncompress(data) except ZippyError: failInvalid() valuesPerPixel = case header.colorType: - of 0: - 1 - of 2: - 3 - of 3: - 1 - of 4: - 2 - of 6: - 4 - else: - 0 # Not possible, parseHeader validates + of 0: 1 + of 2: 3 + of 3: 1 + of 4: 2 + of 6: 4 + else: 0 # Not possible, parseHeader validates valuesPerByte = 8 div header.bitDepth.int rowBytes = ceil((header.width.int * valuesPerPixel) / valuesPerByte).int totalBytes = rowBytes * header.height.int @@ -367,16 +361,11 @@ proc encodePng*( if len != width * height * channels: raise newException(PixieError, "Invalid PNG data size") - let colorType = block: - case channels: - of 1: - 0.uint8 - of 2: - 4 - of 3: - 2 - of 4: - 6 + let colorType = case channels: + of 1: 0.uint8 + of 2: 4 + of 3: 2 + of 4: 6 else: raise newException(PixieError, "Invalid PNG number of channels")