Reputation: 4221
I have drawn a canvas and i want to know how to get a pixel color of the canvas ?
Upvotes: 1
Views: 1372
Reputation: 8671
Create a mutable Image
the same size as your Canvas
. Then, any operations you perform on your Canvas's Graphics
object, perform the same ones on your Image's Graphics object.
Finally, get the pixel data from the Image using getRGB()
; it should be the same as the Canvas.
Upvotes: 1
Reputation: 3226
If you are targeting a platform that supports the NokiaUI API you can use the DirectGraphics#getPixels to read pixel data. On mobile platforms with graphics accelerator hardware, reading pixels tend to be slower so you should use this very sparingly.
Upvotes: 1
Reputation: 41510
Unfortunately, you can't. Graphics
class, which is used to draw to Canvas
, is for painitng only, it can't give you any information on the pixels.
Upvotes: 1