png image per-pixel access?

Monkey Forums/Monkey Programming/png image per-pixel access?

ElectricBoogaloo(Posted 2013) [#1]
Hello, it's me again, asking random questions that are probably answered in the manual if I could be bothered to read it properly. I'm just plowing ahead, and inexplicably managing to cope reasonably well. That's half the fun, right?

So, what's the best way to read the pixels from a png?
I *could* draw it to the screen, then grab that, then read that, but I'm worried that all my multiple-resolution code, as well as all the different targets, might make that a bit iffy.
Is there a quick and easy way to read the pixels from a png that's already in memory, and that will work more-or-less the same on all targets?


MikeHart(Posted 2013) [#2]
Simply answer, NO. In Monkey, right now you can only read the canvas, not an image. Maybe, if you read the png file into a databuffer, you can read that somehow if you know the content structure of a png file.


ElectricBoogaloo(Posted 2013) [#3]
Yeah, figured that'd be the case.
Making level editors, and the like, is going to be one tricky bugger with Monkey!
No matter. Keep going. I'll figure something out.


C10B(Posted 2013) [#4]
"I'll figure something out."

Please let us know if you do.
I'm about to convert a flash project to monkey, and in the flash version I check the pixel color of a "heat map" image which is never actually displayed on the screen.

I guess one alternative is to write a small app (in the language of your choice) that reads the heat map image, and writes each pixel color value and coordinates to a text file. In monkey you can then interrogate the text file for the info you want, rather than the image. The only limiting factor then is whether reading a certain location in what could be a lengthy text document is too slow.

As I need this feature myself, I might test my cunning idea and see how it performs.


Belimoth(Posted 2013) [#5]
I made a state class (similar to Diddy's screen's) that looks something like this:
Class State
	Method PreStart:Void()
	Method Start:Void()
	Method Update:Void()
	Method PreRender:Void()
	Method Render:Void()
End

PreRender is for grabbing things so that SetMatrix's, etc, don't interfere.