resize remove +1

This commit is contained in:
Ryan Oldenburg 2021-01-27 16:45:56 -06:00
parent a6103ac444
commit fe1cfc41a6

View file

@ -500,12 +500,15 @@ proc draw*(a, b: Image, pos = vec2(0, 0), blendMode = bmNormal) {.inline.} =
a.draw(b, translate(pos), blendMode)
proc resize*(srcImage: Image, width, height: int): Image =
if width == srcImage.width and height == srcImage.height:
result = srcImage.copy()
else:
result = newImage(width, height)
result.draw(
srcImage,
scale(vec2(
(width + 1).float / srcImage.width.float,
(height + 1).float / srcImage.height.float
width.float32 / srcImage.width.float32,
height.float32 / srcImage.height.float32
)),
bmOverwrite
)