Merge pull request #311 from guzba/master

3.0.2 bugfix
This commit is contained in:
treeform 2021-10-19 19:11:50 -07:00 committed by GitHub
commit 351d8d0353
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 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" author = "Andre von Houck and Ryan Oldenburg"
description = "Full-featured 2d graphics library for Nim." description = "Full-featured 2d graphics library for Nim."
license = "MIT" license = "MIT"

View file

@ -337,15 +337,13 @@ proc minifyBy2*(image: Image, power = 1): Image {.raises: [PixieError].} =
result.setRgbaUnsafe(result.width - 1, y, rgbx) result.setRgbaUnsafe(result.width - 1, y, rgbx)
if srcHeightIsOdd: if srcHeightIsOdd:
let y = result.height - 1
for x in 0 ..< resultEvenWidth: for x in 0 ..< resultEvenWidth:
let rgbx = mix( let rgbx = mix(
src.getRgbaUnsafe(x * 2 + 0, y), src.getRgbaUnsafe(x * 2 + 0, src.height - 1),
src.getRgbaUnsafe(x * 2 + 1, y), src.getRgbaUnsafe(x * 2 + 1, src.height - 1),
0.5 0.5
) * 0.5 ) * 0.5
result.setRgbaUnsafe(x, y, rgbx) result.setRgbaUnsafe(x, result.height - 1, rgbx)
if srcWidthIsOdd: if srcWidthIsOdd:
result.setRgbaUnsafe( 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: 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)) b.fill(rgba(0, 0, 0, 255))
a.draw(b, scale(vec2(0.5, 0.5))) a.draw(b, scale(vec2(0.5, 0.5)))
doDiff(a, "minify_odd") 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")