Set and Get Pixel

For questions about using Classic.

Post » Thu Dec 23, 2010 5:59 am

Is there a simple way I can get the RGB of a pixel at point (x,y) and set the RGB of that pixel?
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Thu Dec 23, 2010 10:53 am

To set the colour of a pixel you can use the Canvas objects Draw Point action.

You may be able to get the colour of a pixel by positioning a tiny Canvas object over the pixel at runtime, then pasting the layout into it, and finally using the ImageManipulator to sample the RGB values from it... but that would probably be pretty hacky way to do it and I find the ImageManipulator often doesn't do what I expect it to.

Or, if you are initially setting the pixel colours yourself then you could create a 2D array per colour channel. That way you can always sample RGB values easily.

Hope that made some sense.
B
3
S
1
G
4
Posts: 42
Reputation: 1,609

Post » Thu Dec 23, 2010 12:55 pm

[url:3zqzhyj6]http://www.scirra.com/forum/viewtopic.php?f=2&t=8043&p=62012&hilit=rgb#p62012[/url:3zqzhyj6]
Image Image
B
161
S
48
G
91
Posts: 7,357
Reputation: 67,269


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests