java - DrawCircle onTouch on bitmap image -
i doing project on drawcircle
on bitmap image. problem is, when draw, point not follow touch. related drawbitmap
problem? dont know how explain. .. when touch @ blue point (supposedly cursor, edited picture), give circle on red point. why not follow on touch? sorry if question not good, confused.
protected void onactivityresult(int requestcode, int resultcode, intent intent) { super.onactivityresult(requestcode, resultcode, intent); if (resultcode == result_ok) { if (requestcode == 0) { uri imagefileuri = intent.getdata(); try { bitmapfactory.options bmpfactoryoptions = new bitmapfactory.options(); bmpfactoryoptions.injustdecodebounds = true; bmp = bitmapfactory.decodestream(getcontentresolver().openinputstream( imagefileuri), null, bmpfactoryoptions); bmpfactoryoptions.injustdecodebounds = false; bmp = bitmapfactory.decodestream(getcontentresolver().openinputstream( imagefileuri), null, bmpfactoryoptions); alteredbitmap = bitmap.createbitmap(bmp.getwidth(), bmp .getheight(), config.argb_8888); alteredbitmap = alteredbitmap.copy(bmp.getconfig(), true); canvas = new canvas(alteredbitmap); paint = new paint(); paint.setantialias(true); paint.setcolor(color.red); // paint.setstrokewidth(10); // matrix = new matrix(); canvas.drawbitmap(bmp, 0,0, null); choosenimage.setimagebitmap(alteredbitmap); choosenimage.setontouchlistener(this); } catch (exception e) { log.v("error", e.tostring()); } } . //other codes here . . public boolean ontouch(view v, motionevent event) { if(event.getaction() != motionevent.action_down) return super.ontouchevent(event); point point = new point(); point.x1 = (int) event.getx(); point.y1 = (int) event.gety(); points.add(point); log.d(tag, "point: " + point); canvas.drawcircle( point.x1, point.y1,20, paint ); choosenimage.invalidate();
much more http://www.java2s.com/code/android/2d-graphics/drawonpictureandsave.htm . follow tutorial.
Comments
Post a Comment