resize remove +1
This commit is contained in:
parent
a6103ac444
commit
fe1cfc41a6
1 changed files with 12 additions and 9 deletions
|
@ -500,12 +500,15 @@ proc draw*(a, b: Image, pos = vec2(0, 0), blendMode = bmNormal) {.inline.} =
|
||||||
a.draw(b, translate(pos), blendMode)
|
a.draw(b, translate(pos), blendMode)
|
||||||
|
|
||||||
proc resize*(srcImage: Image, width, height: int): Image =
|
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 = newImage(width, height)
|
||||||
result.draw(
|
result.draw(
|
||||||
srcImage,
|
srcImage,
|
||||||
scale(vec2(
|
scale(vec2(
|
||||||
(width + 1).float / srcImage.width.float,
|
width.float32 / srcImage.width.float32,
|
||||||
(height + 1).float / srcImage.height.float
|
height.float32 / srcImage.height.float32
|
||||||
)),
|
)),
|
||||||
bmOverwrite
|
bmOverwrite
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue