f
This commit is contained in:
parent
79e9ee7cd4
commit
b284d7bada
2 changed files with 11 additions and 23 deletions
|
@ -1,4 +1,3 @@
|
||||||
packageName = "pixie"
|
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
author = "Andre von Houck and Ryan Oldenburg"
|
author = "Andre von Houck and Ryan Oldenburg"
|
||||||
description = "Full-featured 2d graphics library for Nim."
|
description = "Full-featured 2d graphics library for Nim."
|
||||||
|
|
|
@ -151,18 +151,12 @@ proc parseImageData(
|
||||||
uncompressed = try: uncompress(data) except ZippyError: failInvalid()
|
uncompressed = try: uncompress(data) except ZippyError: failInvalid()
|
||||||
valuesPerPixel =
|
valuesPerPixel =
|
||||||
case header.colorType:
|
case header.colorType:
|
||||||
of 0:
|
of 0: 1
|
||||||
1
|
of 2: 3
|
||||||
of 2:
|
of 3: 1
|
||||||
3
|
of 4: 2
|
||||||
of 3:
|
of 6: 4
|
||||||
1
|
else: 0 # Not possible, parseHeader validates
|
||||||
of 4:
|
|
||||||
2
|
|
||||||
of 6:
|
|
||||||
4
|
|
||||||
else:
|
|
||||||
0 # Not possible, parseHeader validates
|
|
||||||
valuesPerByte = 8 div header.bitDepth.int
|
valuesPerByte = 8 div header.bitDepth.int
|
||||||
rowBytes = ceil((header.width.int * valuesPerPixel) / valuesPerByte).int
|
rowBytes = ceil((header.width.int * valuesPerPixel) / valuesPerByte).int
|
||||||
totalBytes = rowBytes * header.height.int
|
totalBytes = rowBytes * header.height.int
|
||||||
|
@ -367,16 +361,11 @@ proc encodePng*(
|
||||||
if len != width * height * channels:
|
if len != width * height * channels:
|
||||||
raise newException(PixieError, "Invalid PNG data size")
|
raise newException(PixieError, "Invalid PNG data size")
|
||||||
|
|
||||||
let colorType = block:
|
let colorType = case channels:
|
||||||
case channels:
|
of 1: 0.uint8
|
||||||
of 1:
|
of 2: 4
|
||||||
0.uint8
|
of 3: 2
|
||||||
of 2:
|
of 4: 6
|
||||||
4
|
|
||||||
of 3:
|
|
||||||
2
|
|
||||||
of 4:
|
|
||||||
6
|
|
||||||
else:
|
else:
|
||||||
raise newException(PixieError, "Invalid PNG number of channels")
|
raise newException(PixieError, "Invalid PNG number of channels")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue