small
This commit is contained in:
parent
a252dad7b3
commit
e1c98b0822
2 changed files with 8 additions and 8 deletions
|
@ -47,9 +47,10 @@ proc toPremultipliedAlpha*(c: Color): Color {.inline.} =
|
||||||
|
|
||||||
proc toStraightAlpha*(c: Color): Color {.inline.} =
|
proc toStraightAlpha*(c: Color): Color {.inline.} =
|
||||||
## Converts a color to from premultiplied alpha to straight.
|
## Converts a color to from premultiplied alpha to straight.
|
||||||
if c.a == 0:
|
if c.a != 0 and c.a != 1:
|
||||||
return
|
result = c
|
||||||
result.r = c.r / c.a
|
else:
|
||||||
result.g = c.g / c.a
|
result.r = c.r / c.a
|
||||||
result.b = c.b / c.a
|
result.g = c.g / c.a
|
||||||
result.a = c.a
|
result.b = c.b / c.a
|
||||||
|
result.a = c.a
|
||||||
|
|
|
@ -437,10 +437,9 @@ proc encodePng*(
|
||||||
raise newException(PixieError, "Invalid PNG number of channels")
|
raise newException(PixieError, "Invalid PNG number of channels")
|
||||||
|
|
||||||
let data = cast[ptr UncheckedArray[uint8]](data)
|
let data = cast[ptr UncheckedArray[uint8]](data)
|
||||||
const signature = [137.uint8, 80, 78, 71, 13, 10, 26, 10]
|
|
||||||
|
|
||||||
# Add the PNG file signature
|
# Add the PNG file signature
|
||||||
result.add(signature)
|
result.add(pngSignature)
|
||||||
|
|
||||||
# Add IHDR
|
# Add IHDR
|
||||||
result.addUint32(13.uint32.swap())
|
result.addUint32(13.uint32.swap())
|
||||||
|
|
Loading…
Reference in a new issue