new to Android
new to Android

Reputation: 1

Drawing on Canvas with an image on background and save image

I want to open an image from SD card, while image is on display I want to draw on it using touch and motion events and save the image back. Any help or pointer to any sample code would be of great help.

Upvotes: 0

Views: 1031

Answers (1)

AJcodez
AJcodez

Reputation: 34166

I'm sure there are many ways, and many ways better than this but this is how I would do it:

Basically in my understanding you need to open the image from an SD card to a bitmap to a imageview in your activity. http://www.higherpass.com/Android/Tutorials/Working-With-Images-In-Android/2/

Then you need to go pixel by pixel and get each value for the color so you can change it in an onTouchEvent. http://developer.android.com/reference/android/graphics/Bitmap.html See getPixel() and setPixel()

The user gets to draw stuff on it. You need some way to capture the motion event, and change your data model of the image you just got by getting all of the pixels. You could use a surfaceview or something similar. Android: creating a Bitmap with SurfaceView content

Finally you need to save the picture to the SD card. Android write to sd card folder

Hopefully this helped

Upvotes: 1

Related Questions