From e78872f3df05bb1441bc135f58b8a8b1081b53d4 Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 27 Apr 2024 17:53:42 +0200 Subject: png: fix indexed color with tRNS --- src/img/png.nim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/img/png.nim') diff --git a/src/img/png.nim b/src/img/png.nim index 1e75121b..db1fa5a9 100644 --- a/src/img/png.nim +++ b/src/img/png.nim @@ -254,8 +254,10 @@ proc readtRNS(reader: var PNGReader) = of pcIndexedColor: if reader.limit - reader.i > reader.palette.len: reader.err "too many trns values" - for i in 0 ..< reader.palette.len: - reader.palette[i].a = reader.readU8() + for c in reader.palette.mitems: + if reader.i >= reader.limit: + break + c.a = reader.readU8() func paethPredictor(a, b, c: uint8): uint8 = let pa0 = int(b) - int(c) @@ -387,12 +389,12 @@ proc readPLTE(reader: var PNGReader) = let len = reader.limit - reader.i if len mod 3 != 0: reader.err "palette length not divisible by 3" - reader.palette = newSeq[ARGBColor](len) - for i in 0 ..< len div 3: + reader.palette = newSeq[ARGBColor](len div 3) + for c in reader.palette.mitems: let r = reader.readU8() let g = reader.readU8() let b = reader.readU8() - reader.palette[i] = rgba(r, g, b, 255) + c = rgba(r, g, b, 255) reader.plteseen = true proc readIDAT(reader: var PNGReader) = -- cgit 1.4.1-2-gfad0 a4cf160051d975a892dda5ca7ba60dba'>tree commit diff stats
path: root/src/utils/proctitle.nim
blob: 4694be0b70855c2fb4efe94e7805096918689ed4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38