3.0.2 bugfix

This commit is contained in:
Ryan Oldenburg 2021-10-19 20:12:40 -05:00
parent f7ca3fc480
commit 08beb6b947
13 changed files with 16 additions and 6 deletions

View file

@ -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"

View file

@ -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(

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
tests/images/rock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -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")