This commit is contained in:
Ryan Oldenburg 2021-01-24 18:42:09 -06:00
parent cb70bee1ec
commit e95f78038d

View file

@ -172,11 +172,8 @@ proc magnifyBy2*(image: Image, scale2x: int): Image =
proc magnifyBy2*(image: Image): Image =
image.magnifyBy2(2)
when defined(release):
{.pop.}
proc toPremultipliedAlpha*(image: Image) =
## Converts an image to premultiplied alpha from straight.
## Converts an image to straight alpha from premultiplied alpha.
var i: int
when defined(amd64) and not defined(pixieNoSimd):
# When supported, SIMD convert as much as possible
@ -190,12 +187,11 @@ proc toPremultipliedAlpha*(image: Image) =
var
color = mm_loadu_si128(image.data[j].addr)
alpha = mm_and_si128(color, alphaMask)
alpha = mm_or_si128(alpha, mm_srli_epi32(alpha, 16))
var
colorEven = mm_slli_epi16(color, 8)
colorOdd = mm_and_si128(color, oddMask)
alpha = mm_or_si128(alpha, mm_srli_epi32(alpha, 16))
colorEven = mm_mulhi_epu16(colorEven, alpha)
colorOdd = mm_mulhi_epu16(colorOdd, alpha)
@ -228,6 +224,9 @@ proc toStraightAlpha*(image: Image) =
c.g = ((c.g.uint32 * multiplier) div 255).uint8
c.b = ((c.b.uint32 * multiplier) div 255).uint8
when defined(release):
{.pop.}
proc draw*(a, b: Image, mat: Mat3, blendMode = bmNormal)
proc draw*(a, b: Image, pos = vec2(0, 0), blendMode = bmNormal) {.inline.}