From 8a7886a63d7758013575a642fedb52873fd1e109 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Sun, 24 Apr 2016 08:38:57 -0400 Subject: [PATCH] ketmar paeth fix --- png.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/png.d b/png.d index 288a380..8b3bd7a 100644 --- a/png.d +++ b/png.d @@ -1748,9 +1748,9 @@ immutable(ubyte)[] unfilter(ubyte filterType, in ubyte[] data, in ubyte[] previo auto arr = data.dup; foreach(i; 0 .. arr.length) { ubyte prev = i < bpp ? 0 : arr[i - bpp]; - ubyte prevLL = i < bpp ? 0 : previousLine[i - bpp]; + ubyte prevLL = i < bpp ? 0 : (i < previousLine.length ? previousLine[i - bpp] : 0); - arr[i] += PaethPredictor(prev, previousLine[i], prevLL); + arr[i] += PaethPredictor(prev, (i < previousLine.length ? previousLine[i] : 0), prevLL); } return assumeUnique(arr);