Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drawing text or gesture on image saved on sd card

Tags:

android

Till now in my application i am scaling image and drawing it on screen according to screen size. after that user can draw text or any thing on it using his finger. and after that i convert view to Bitmap and i resize that bitmap and make it to the same height and width as real image. now the problem is in resizing to the quality of image become worse so i need to change in real image. So now can some one tell me how can i draw two canvas which overlay each other or i can draw image on ImageView and in canvas i only draw that Path which user draw using his fingure ? and the biggest challenge is how i can combine two images one is which has user inputed lines or curves and one is real image ?

like image 514
kartik trivedi Avatar asked Nov 05 '22 14:11

kartik trivedi


1 Answers

Load the bitmap in original resolution. Then use 2 phases:

1) Where user ineracts (draws) on screen, draw the Bitmap to screen Canvas using scale matrix so that it fits screen. And draw your finger paint on top of that.

2) When saving, create new Canvas, set its target to be your image Bitmap, and draw your overlay finger paint on top of this. Again use matrix, but inverse, because now you have originally scaled Bitmap, and want to draw on top of it something that was previously drawn on scaled bitmap. Your Bitmap now has additional graphics drawn on it, and you can save it to a file.

like image 86
Pointer Null Avatar answered Nov 15 '22 05:11

Pointer Null