Monday 15 March 2010

java - Android: Editing a picture with Canvas? -


I want to make an app that can edit the image. I want to be able to put circles on the image I now have a bitmap image view of the activity. Implementation Now I have placed the board behind a bitmap image on a view. How can I keep circles on images when I move the zoom in / image? This is my code:

  public class ImageDisplayActivity FragmentActivity {public static final String KEY_PATH = "img.jpg"; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.activity_image_display); Intent = getIntent (); String path = getIntent (). GetStringExtra (ImageDisplayActivity.KEY_PATH); Try {java.io.FileInputStream = this.openFileInput (path); Bitmap bitmap = bitmapfenderDecodedStream (in); Find ZoomInZoomOut Touch = (Zoom InZoom) VVBIID (RID. IMJIIDID); Touch = arrangeImageView (touch); Touch.setImageBitmap (bitmap); In.close (); } Hold (exception e) {e.printStackTrace (); } Button Button = (Button) Find ViewById (R.id.button2); Final ball mCanvasView; Find MCanvasView = (Ball) ViewById (R.id.ball1); Button.setOnClickListener (New View.OnClickListener () {@Override Public Zero onClick (see v) {mCanvasView.drawCircle ();}}); } Private Zoom InzoomAutot ImageViews (Zoom Inzoomut Emg) {try {img.setRotation (90); Img.setScaleX (2f); Img.setScaleY (2f); } Hold (exception e) {e.printStackTrace (); } Return IMG; }   

}

'ball' category:

  see public square ball {public paint mPaint; Public stable canvas Macawas; Private Inc mPivotX = 0; Private Inc mPivotY = 0; Private int radius = 60; // Constructor Public Ball (Reference Reference, Attributed Atters) {Super (context, ethers); MPaint = new paint (); } Public Zero DrawCrack () {int minX = Radius * 2; Int maxX = getWidth () - (radius * 2); Int miny = Radius * 2; Int maxY = getHeight () - (radius * 2); // Generate random numbers for X and Y locations of the circle on the screen random random = new random (); MPivotX = Random.xit (maxx - minx + 1) + minx; MPivotY = random.nextInt (max - miny + 1) + minway; // Required Refers to the scene by calling the Dre function invalid (); } // The one which I want to attract, is empty here (canvas canvas) {mCanvas = canvas; Super.onDraw (mCanvas); Canvas.drawColor (Color.GRAY); MPaint.setColor (Color.BLUE); MPaint.setStyle (Paint.Style.STROKE); MPaint.setAntiAlias ​​(right); Canvas arm carcill (MPVTEX, MPVT, radius, MPEP); }  

}

XML for image display activity:

  & lt; RelativeLayout xmlns: Android = "http: // schema .android.com / apk / res / android" xmlns: tools = "http://schemas.android.com/tools" Android: layout_width = "match_parent" android: layout_height = "Match_parent" Android: paddingLeft = "@ Dimen / activity_horizontal_margin" Android: paddingRight = "@ Dimen / activity_horizontal_margin" Android: paddingTop = "@ Dimen / activity_vertical_margin" Android: paddingBottom = "@ Dimen / activity_vertical_margin" Android: background = "@ drawable / Background "tool: reference =" com.commonsware .android.test1.ImageDisplayActivity "& gt; & Lt; Com: com.commonsware.android.test1.ball Android: id = "@ + id / ball1" Android: layout_width = "143dp" Android: layout_height = "169dp" Android: layout_column = "1" Android: layout_gravity = "left | top" Android: layout_row = "0" /> & Lt; Com: com.commonsware.android.test1.ZoomInZoomOut Android: id = "@ + id / IMAGEID" Android: layout_width = "match_parent" android: layout_height = "match_parent" android: layout_alignParentTop = "true" Android: layout_alignParentLeft = "true" Android: Layout_alignParentStart = "true" /> Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: text = "o" Android: layout_linkpointbotm = "android: android: atr / true" Android: layout_linePrintLft = "true" Android: layout_lagin parentstart = "true "/>  


No comments:

Post a Comment