Sando
Sando

Reputation: 1881

How to manipulate images in android canvas?

i am having an image in canvas.i want to get color at particular pixels and replace with user defined color.is it possible to do for abitmap placed in android canvas? Thanks in advance..

Upvotes: 2

Views: 1255

Answers (3)

Malcolm
Malcolm

Reputation: 41510

Unfortunately Canvas is more like a write-only object: you can draw on the Bitmap, but you can't really get almost any information on the Bitmap. But if you have access to the Bitmap itself, this is a very easy task: just use Bitmap.getPixel(int x, int y) to get the color of the pixels and then draw whatever you need on the Canvas or even just call Bitmap.setPixel(int x, int y, int color) without creating any Canvas at all.

Upvotes: 1

pumpkee
pumpkee

Reputation: 3357

Sure. just bitmap.getPixel(x, y) and setPixel(x, y, color). Make sure that the bitmap your working on is mutable.

Upvotes: 0

Related Questions