small
This commit is contained in:
parent
cb70bee1ec
commit
e95f78038d
1 changed files with 6 additions and 7 deletions
|
@ -172,11 +172,8 @@ proc magnifyBy2*(image: Image, scale2x: int): Image =
|
||||||
proc magnifyBy2*(image: Image): Image =
|
proc magnifyBy2*(image: Image): Image =
|
||||||
image.magnifyBy2(2)
|
image.magnifyBy2(2)
|
||||||
|
|
||||||
when defined(release):
|
|
||||||
{.pop.}
|
|
||||||
|
|
||||||
proc toPremultipliedAlpha*(image: Image) =
|
proc toPremultipliedAlpha*(image: Image) =
|
||||||
## Converts an image to premultiplied alpha from straight.
|
## Converts an image to straight alpha from premultiplied alpha.
|
||||||
var i: int
|
var i: int
|
||||||
when defined(amd64) and not defined(pixieNoSimd):
|
when defined(amd64) and not defined(pixieNoSimd):
|
||||||
# When supported, SIMD convert as much as possible
|
# When supported, SIMD convert as much as possible
|
||||||
|
@ -190,12 +187,11 @@ proc toPremultipliedAlpha*(image: Image) =
|
||||||
var
|
var
|
||||||
color = mm_loadu_si128(image.data[j].addr)
|
color = mm_loadu_si128(image.data[j].addr)
|
||||||
alpha = mm_and_si128(color, alphaMask)
|
alpha = mm_and_si128(color, alphaMask)
|
||||||
alpha = mm_or_si128(alpha, mm_srli_epi32(alpha, 16))
|
|
||||||
|
|
||||||
var
|
|
||||||
colorEven = mm_slli_epi16(color, 8)
|
colorEven = mm_slli_epi16(color, 8)
|
||||||
colorOdd = mm_and_si128(color, oddMask)
|
colorOdd = mm_and_si128(color, oddMask)
|
||||||
|
|
||||||
|
alpha = mm_or_si128(alpha, mm_srli_epi32(alpha, 16))
|
||||||
|
|
||||||
colorEven = mm_mulhi_epu16(colorEven, alpha)
|
colorEven = mm_mulhi_epu16(colorEven, alpha)
|
||||||
colorOdd = mm_mulhi_epu16(colorOdd, 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.g = ((c.g.uint32 * multiplier) div 255).uint8
|
||||||
c.b = ((c.b.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, mat: Mat3, blendMode = bmNormal)
|
||||||
proc draw*(a, b: Image, pos = vec2(0, 0), blendMode = bmNormal) {.inline.}
|
proc draw*(a, b: Image, pos = vec2(0, 0), blendMode = bmNormal) {.inline.}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue