Oh I want to save the image created by user in the fingerprint through the save menu.
activity class here
public int mImageCount = 0; /** Called when the activity is first created. * / @Override Public Zero onCreate (bundled savedInstanceState) {super.onCreate (savedInstanceState); SetContentView (R.layout.main); Button Ridge = (button) VVBIID (RID Reset); Res.setOnClickListener (New View.OnClickListener) {@Override Click Public Zero (see V) {// TODO Auto generated method TouchEventView touch view = (TouchEventView) findViewById (R.id.mydrawview1); touchView.clear ( );}}); } @ Override Public Boolean On Crate Option Menu (menu menu) {MenuInflater inflater = getMenuInflater (); Inflater.inflate (R.Menu menu_name, menu); Back true; } @ Override Public Boolean On Option Itam Select (Menu Item) {Switch (ITAT. ITMID)} {Case R.ID. SV: Save (); Back true; Case R.id.open: Open (); Back true; Default: Return Super.Options item selected (item); }} Public Zero Save () {TouchEventView touchview = (TouchEventView) findViewById (R.id.mydrawview1); File myDir = new file ("/ sdcard / saved_images"); If (! MyDir.exists ()) myDir.mkdirs (); MImageCount ++; String fname = "image-" + mimagecount + ".jpg"; File file = new file (myDir, fname); If (file.exists ()) file.delete (); Touchview.saveAsJpg (file); Toast. Make Text (this, "Image is saved", 7000). Show (); } Public Zero Open () {TextView TV = New Text View (this); Tv.setText ("Hello, Android"); SetContentView (TV); }} 'Here is a square view
Public Segment TouchEventView View {Private Static Bitmap mBitmap; Private paint paint = new paint (); Private Path Path = New Path (); Private canvas MacNovas; Private path mPath; Private paint mBitmapPaint; Public TouchEventView (context references, AttributeSet attrs) {super (references, attrs); Paint.setAntiAlias (right); Paint.setColor (Color.WHITE); Paint.setStyle (Paint.Style.STROKE); Paint.setStrokeJoin (Paint.Join.ROUND); Paint.setStrokeWidth (5F); Mbitmap = Bitmap.CreditMetaMap (320, 480, Bitmap.sf.Arg_8888); MCanvas = new canvas (MBITMAP); MPath = new path (); MBitmapPaint = new paint (paint.DITHER_FLAG); } @ Override Protected Zero (Canvas Canvas) {Canvas Left Color (0xFFAAAAAA); Canvas.drawBitmap (mbitmap, 0, 0, mbitmapPaint); Canvas skeleton (path, paint); } Public Zero Clear () {Path = New Path (); Invalid (); } @ Override Public Boolean on touch event (motion event event) {float eventx = event.getX (); Boat eventY = event.getY (); Switch (event.getAction ()) {case MotionEvent.ACTION_DOWN: path.moveTo (eventX, eventY); Back true; Case Motion Event Action_ MOVE: Path. Line Two (EventX, EventA); break; MotionEvent.ACTION_UP case: Nothing to break; Default: Return false; } // A resize invalid (); Back true; } Public Zero Savage SGPG (File F) {String FNAN = F.AtAzolitePath (); FileOutputStream fos = Faucet; Try {Fos = new FileOutputStream (f); Take the bitmap of the // view and write it as JPEG. MBitmap.compress (compressed format.jpg, 95, foss); } Catch (Throwable Pre) {ex.printStackTrace (); }}} 'I have edited my code. Only saves a blank screen. Why finger painting is not being saved? PLG help me
You are never starting touch visibility Insert this line: Find TouchWeekView TouchView = (TouchAventView) VVBIID (RIDMDVVA1); to Public Zero save () , and delete the declaration on the second line.
Comments
Post a Comment