compile with Nim 1.0.0

This commit is contained in:
andri lim 2019-09-27 20:28:52 +07:00
parent 77cbfc3405
commit 149fffe4e7
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 42 additions and 42 deletions

View File

@ -2682,35 +2682,35 @@ proc filterScanLine(output: var DataBuf, scanLine, prevLine: DataBuf, len, byteW
of FLT_SUB:
for i in 0..byteWidth-1: output[i] = scanLine[i]
for i in byteWidth..len-1:
output[i] = chr(scanLine[i].uint - scanLine[i - byteWidth].uint)
output[i] = chr((scanLine[i].uint - scanLine[i - byteWidth].uint) and 0xFF)
of FLT_UP:
if not prevLine.isNil:
for i in 0..len-1:
output[i] = chr(scanLine[i].uint - prevLine[i].uint)
output[i] = chr((scanLine[i].uint - prevLine[i].uint) and 0xFF)
else:
for i in 0..len-1: output[i] = scanLine[i]
of FLT_AVERAGE:
if not prevLine.isNil:
for i in 0..byteWidth-1:
output[i] = chr(scanLine[i].uint - (prevLine[i].uint div 2))
output[i] = chr((scanLine[i].uint - (prevLine[i].uint div 2)) and 0xFF)
for i in byteWidth..len-1:
output[i] = chr(scanLine[i].uint - ((scanLine[i - byteWidth].uint + prevLine[i].uint) div 2))
output[i] = chr((scanLine[i].uint - ((scanLine[i - byteWidth].uint + prevLine[i].uint) div 2)) and 0xFF)
else:
for i in 0..byteWidth-1: output[i] = scanLine[i]
for i in byteWidth..len-1:
output[i] = chr(scanLine[i].uint - (scanLine[i - byteWidth].uint div 2))
output[i] = chr((scanLine[i].uint - (scanLine[i - byteWidth].uint div 2)) and 0xFF)
of FLT_PAETH:
if not prevLine.isNil:
#paethPredictor(0, prevLine[i], 0) is always prevLine[i]
for i in 0..byteWidth-1:
output[i] = chr(scanLine[i].uint - prevLine[i].uint)
output[i] = chr((scanLine[i].uint - prevLine[i].uint) and 0xFF)
for i in byteWidth..len-1:
output[i] = chr(scanLine[i].uint - paethPredictor(ord(scanLine[i - byteWidth]), ord(prevLine[i]), ord(prevLine[i - byteWidth])).uint)
output[i] = chr((scanLine[i].uint - paethPredictor(ord(scanLine[i - byteWidth]), ord(prevLine[i]), ord(prevLine[i - byteWidth])).uint) and 0xFF)
else:
for i in 0..byteWidth-1: output[i] = scanLine[i]
#paethPredictor(scanLine[i - byteWidth], 0, 0) is always scanLine[i - byteWidth]
for i in byteWidth..len-1:
output[i] = chr(scanLine[i].uint - scanLine[i - byteWidth].uint)
output[i] = chr((scanLine[i].uint - scanLine[i - byteWidth].uint) and 0xFF)
proc filterZero(output: var DataBuf, input: DataBuf, w, h, bpp: int) =
#the width of a scanline in bytes, not including the filter type

View File

@ -1,5 +1,5 @@
# Package
version = "0.2.4"
version = "0.2.5"
author = "Andri Lim"
description = "PNG encoder and decoder"
license = "MIT"

View File

@ -20,9 +20,9 @@ proc toBMP(png: PNGResult, fileName: string) =
bmp.data[px + 2] = chr(0xFF)
else:
let alpha = uint(x.data[px4 + 3])
bmp.data[px] = chr(uint8(255) + uint8(((x.data[px4 + 2].uint - 255'u) * alpha) shr 8))
bmp.data[px + 1] = chr(uint8(255) + uint8(((x.data[px4 + 1].uint - 255'u) * alpha) shr 8))
bmp.data[px + 2] = chr(uint8(255) + uint8(((x.data[px4 + 0].uint - 255'u) * alpha) shr 8))
bmp.data[px] = chr(uint8(255) + uint8((((x.data[px4 + 2].uint - 255'u) * alpha) shr 8) and 0xFF))
bmp.data[px + 1] = chr(uint8(255) + uint8((((x.data[px4 + 1].uint - 255'u) * alpha) shr 8) and 0xFF))
bmp.data[px + 2] = chr(uint8(255) + uint8((((x.data[px4 + 0].uint - 255'u) * alpha) shr 8) and 0xFF))
let bmpName = fileName & "_" & $frame & ".bmp"
#var s = newFileStream(bmpName, fmWrite)