mirror of
https://github.com/status-im/nimPNG.git
synced 2025-01-28 21:34:47 +00:00
compile with Nim 1.0.0
This commit is contained in:
parent
77cbfc3405
commit
149fffe4e7
16
nimPNG.nim
16
nimPNG.nim
@ -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
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Package
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
author = "Andri Lim"
|
||||
description = "PNG encoder and decoder"
|
||||
license = "MIT"
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user