Parsing through a PNG file

Godot Version 4.1.1

I am currently trying to write a script that can identify weather or not a pixel in a PNG file is black or white. I have gotten it to work but for some reason, instead of (0,0) starting from the top left of the PNG and going left to right, highest to lowest, it seems to be going from top right and going right to left, highest to lowest. any idea on why that could be?

visual aide:

and the link to the pastebin code : Image Parsing -

Looks fine to me?

You’re looping through columns first then rows, but the coordinates are right

the comments in check_pxl() seem to be mixing up and down though

1 Like

all of those should return 0000, i think the pixels touching the edges are to blame.
i realized after looking through the code that i am cheking columns then rows but the rows are still inverted

this was the original example and the order i want to get is 10,6,9,5

but the numbers i end up getting is 9,5,10,6

i am getting the correct numbers in the correct location, just getting them in a reversed sequence

as for thr fliped up/down comments, i was unaware of godot using -y as “up” in 2D space

you were correct in the inverse signage for the checks

That image doesn’t match what you’re saying.

The top left pixel has a black pixel to the Right and Down. So it should be:
0 1 0 1 = 5
except your code switched up and down so it’s
1 0 0 1 = 9

if you fix up and down you should expect
5 6
9 10

So in column order 5, 9, 6, 10

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.