"Invalid filter" error is thrown when loading a PNG image.
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- computer-graphics
Research direction
Start in format/png/Tools.hx at decodeLine, then reproduce the failure by loading the linked PNG through the Heaps path. Trace the filter value and PNG decoding state to identify why it reaches the invalid-filter branch; done means the image loads without that error.
Written by the indexing model from the issue text.
Description
As we discussed in the mailing list, an "Invalid Filter" error is thrown when loading the PNG at the bottom of this post. The error is thrown by this piece of code :
https://github.com/HaxeFoundation/format/blob/master/format/png/Tools.hx
inline function decodeLine(y, f, getValue) {
switch( f ) {
case 0:
for( x in 0...width ) {
decode(getValue);
bgra.set(w++,vb);
bgra.set(w++,vg);
bgra.set(w++,vr);
bgra.set(w++,va);
}
case 1:
var cr = 0, cg = 0, cb = 0, ca = 0;
for( x in 0...width ) {
decode(getValue);
cb += vb; bgra.set(w++,cb);
cg += vg; bgra.set(w++,cg);
cr += vr; bgra.set(w++,cr);
ca += va; bgra.set(w++,ca);
bgra.set(w++, va);
}
case 2:
var stride = y == 0 ? 0 : width * 4;
for( x in 0...width ) {
decode(getValue);
bgra.set(w, vb + bgra.get(w - stride)); w++;
bgra.set(w, vg + bgra.get(w - stride)); w++;
bgra.set(w, vr + bgra.get(w - stride)); w++;
bgra.set(w, va + bgra.get(w - stride)); w++;
}
case 3:
var cr = 0, cg = 0, cb = 0, ca = 0;
var stride = y == 0 ? 0 : width * 4;
for( x in 0...width ) {
decode(getValue);
cb = (vb + ((cb + bgra.get(w - stride)) >> 1)) & 0xFF; bgra.set(w++, cb);
cg = (vg + ((cg + bgra.get(w - stride)) >> 1)) & 0xFF; bgra.set(w++, cg);
cr = (vr + ((cr + bgra.get(w - stride)) >> 1)) & 0xFF; bgra.set(w++, cr);
cr = (va + ((ca + bgra.get(w - stride)) >> 1)) & 0xFF; bgra.set(w++, ca);
}
case 4:
var stride = width * 4;
var cr = 0, cg = 0, cb = 0, ca = 0;
for( x in 0...width ) {
decode(getValue);
cb = (filter(bgra, x, y, stride, cb, w) + vb) & 0xFF; bgra.set(w++, cb);
cg = (filter(bgra, x, y, stride, cg, w) + vg) & 0xFF; bgra.set(w++, cg);
cr = (filter(bgra, x, y, stride, cr, w) + vr) & 0xFF; bgra.set(w++, cr);
ca = (filter(bgra, x, y, stride, ca, w) + va) & 0xFF; bgra.set(w++, ca);
}
default:
throw "Invalid filter "+f;
}
}
The error occur when loading the PNG with Heaps.

- Dominant language
- Haxe
- Stars
- 141
- Forks
- 65
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from HaxeFoundation/format
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
HaxeFoundation/format#111 · 6 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
HaxeFoundation/format#107 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
HaxeFoundation/format#102 · 5 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
HaxeFoundation/format#100 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
HaxeFoundation/format#99 · 1 comment ·
All issues in HaxeFoundation/format
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
storytold/photocraft#16547 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
rust-windowing/glutin#1770 ·
-
compatibility prio:normal
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NatronGitHub/openfx-misc#320 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
awxkee/yuvutils-rs#149 ·