diff --git a/pixie.nimble b/pixie.nimble index bf4e915..fa96bd3 100644 --- a/pixie.nimble +++ b/pixie.nimble @@ -1,4 +1,4 @@ -version = "3.0.1" +version = "3.0.2" author = "Andre von Houck and Ryan Oldenburg" description = "Full-featured 2d graphics library for Nim." license = "MIT" diff --git a/src/pixie/images.nim b/src/pixie/images.nim index 81935d5..6a69db1 100644 --- a/src/pixie/images.nim +++ b/src/pixie/images.nim @@ -337,15 +337,13 @@ proc minifyBy2*(image: Image, power = 1): Image {.raises: [PixieError].} = result.setRgbaUnsafe(result.width - 1, y, rgbx) if srcHeightIsOdd: - let y = result.height - 1 - for x in 0 ..< resultEvenWidth: let rgbx = mix( - src.getRgbaUnsafe(x * 2 + 0, y), - src.getRgbaUnsafe(x * 2 + 1, y), + src.getRgbaUnsafe(x * 2 + 0, src.height - 1), + src.getRgbaUnsafe(x * 2 + 1, src.height - 1), 0.5 ) * 0.5 - result.setRgbaUnsafe(x, y, rgbx) + result.setRgbaUnsafe(x, result.height - 1, rgbx) if srcWidthIsOdd: result.setRgbaUnsafe( diff --git a/tests/images/diffs/rock_minified.png b/tests/images/diffs/rock_minified.png new file mode 100644 index 0000000..59642d4 Binary files /dev/null and b/tests/images/diffs/rock_minified.png differ diff --git a/tests/images/diffs/rock_minified2.png b/tests/images/diffs/rock_minified2.png new file mode 100644 index 0000000..80bac3f Binary files /dev/null and b/tests/images/diffs/rock_minified2.png differ diff --git a/tests/images/magnifiedBy4.png b/tests/images/magnifiedBy4.png index 3f18f7c..4eae1dc 100644 Binary files a/tests/images/magnifiedBy4.png and b/tests/images/magnifiedBy4.png differ diff --git a/tests/images/masters/rock_minified.png b/tests/images/masters/rock_minified.png new file mode 100644 index 0000000..6629445 Binary files /dev/null and b/tests/images/masters/rock_minified.png differ diff --git a/tests/images/masters/rock_minified2.png b/tests/images/masters/rock_minified2.png new file mode 100644 index 0000000..826f67a Binary files /dev/null and b/tests/images/masters/rock_minified2.png differ diff --git a/tests/images/minifiedBy4.png b/tests/images/minifiedBy4.png index 532c931..4b84ebd 100644 Binary files a/tests/images/minifiedBy4.png and b/tests/images/minifiedBy4.png differ diff --git a/tests/images/rendered/minify_rock.png b/tests/images/rendered/minify_rock.png new file mode 100644 index 0000000..e624164 Binary files /dev/null and b/tests/images/rendered/minify_rock.png differ diff --git a/tests/images/rendered/rock_minified.png b/tests/images/rendered/rock_minified.png new file mode 100644 index 0000000..9030c1a Binary files /dev/null and b/tests/images/rendered/rock_minified.png differ diff --git a/tests/images/rendered/rock_minified2.png b/tests/images/rendered/rock_minified2.png new file mode 100644 index 0000000..f0eae45 Binary files /dev/null and b/tests/images/rendered/rock_minified2.png differ diff --git a/tests/images/rock.png b/tests/images/rock.png new file mode 100644 index 0000000..4fb7f67 Binary files /dev/null and b/tests/images/rock.png differ diff --git a/tests/test_images_draw.nim b/tests/test_images_draw.nim index b035137..b0a5ade 100644 --- a/tests/test_images_draw.nim +++ b/tests/test_images_draw.nim @@ -258,3 +258,15 @@ block: b.fill(rgba(0, 0, 0, 255)) a.draw(b, scale(vec2(0.5, 0.5))) doDiff(a, "minify_odd") + +block: + let + rock = readImage("tests/images/rock.png") + minified = rock.minifyBy2() + doDiff(minified, "rock_minified") + +block: + let + rock = readImage("tests/images/rock.png") + minified = rock.minifyBy2(2) + doDiff(minified, "rock_minified2")