diff --git a/nimPNG/filters.nim b/nimPNG/filters.nim index e60d6aa..81107ed 100644 --- a/nimPNG/filters.nim +++ b/nimPNG/filters.nim @@ -1,4 +1,4 @@ -import math +import math, ../nimPNG/nimz type PNGFilter* = enum @@ -101,55 +101,64 @@ proc filterZero*(output: var openArray[byte], input: openArray[byte], w, h, bpp: input.toOpenArray(prevIndex, input.len-1), byteWidth, lineBytes, FLT_NONE) prevIndex = inIndex - -#[ + + proc filterMinsum*(output: var openArray[byte], input: openArray[byte], w, h, bpp: int) = let lineBytes = (w * bpp + 7) div 8 let byteWidth = (bpp + 7) div 8 #adaptive filtering - var sum = [0, 0, 0, 0, 0] - var smallest = 0 - - #five filtering attempts, one for each filter type - var attempt: array[0..4, string] - var bestType = 0 - var prevLine: DataBuf + var + sum = [0, 0, 0, 0, 0] + smallest = 0 + # five filtering attempts, one for each filter type + attempt: array[0..4, seq[byte]] + bestType = 0 + prevIndex = 0 for i in 0..attempt.high: - attempt[i] = newString(lineBytes) + attempt[i] = newSeq[byte](lineBytes) - for y in 0..h-1: - #try the 5 filter types + for y in 0..