java - Draw on Loaded image on Android -


i load pic using code

uri selectedimage = data.getdata(); string[] filepathcolumn = { mediastore.images.media.data };  cursor cursor = getcontentresolver().query(selectedimage, filepathcolumn, null, null, null); cursor.movetofirst();  int columnindex = cursor.getcolumnindex(filepathcolumn[0]); string picturepath = cursor.getstring(columnindex); cursor.close();  imageview imageview = (imageview) findviewbyid(r.id.imageview); imageview.setimagebitmap(bitmapfactory.decodefile(picturepath));` 

it work , shows pic on imageview not want draw circle on , save, can draw using code

bitmapfactory.options myoptions = new bitmapfactory.options(); myoptions.indither = true; myoptions.inscaled = false; myoptions.inpreferredconfig = bitmap.config.argb_8888;// important myoptions.inpurgeable = true; bitmap bitmap = bitmapfactory.decoderesource(getresources(),r.drawable.ic_luncher); paint paint = new paint(); paint.setantialias(true); paint.setcolor(color.blue);  bitmap workingbitmap = bitmap.createbitmap(bitmap); bitmap mutablebitmap = workingbitmap.copy(bitmap.config.argb_8888, true);   canvas canvas = new canvas(mutablebitmap); canvas.drawcircle(60, 50, 25, paint);  imageview imageview = (imageview)findviewbyid(r.id.imageview); imageview.setadjustviewbounds(true); imageview.setimagebitmap(mutablebitmap);` 

but cant draw because set 'ic_luncher' on resource of bitmap. user can not draw on loaded pic, code should replace

bitmap bitmap = bitmapfactory.decoderesource(getresources(),r.drawable.ic_luncher);?

rather using bitmap.copy, try creating new bitmap of same size via createbitmap, draw launcher icon new bitmap. can draw on top of that.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -