1810: case 3: auto arr = data.dup; foreach(i; 0 .. arr.length) { auto prev = i < bpp ? 0 : arr[i - bpp]; if (i >= previousLine.length) break; arr[i] += cast(ubyte) /*std.math.floor*/( cast(int) (prev + previousLine[i]) / 2); }
adding if (i >= previousLine.length) break; prevents some crashes and seems to work.