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)
|
||||
|
||||
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
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue