android - how to convert PictureDrawable into Bitmap -
How can I convert a bitmap object to a PictureDrawable object? I have shown the following code below and it gives zero indicator. > >> Private Bitmap pictureDrawable2Bitmap Bitmap to PictureDrawable Convert (PictureDrawable pictureDrawable) {bitmap bitmap = Bitmap.createBitmap (pictureDrawable.getIntrinsicWidth), ImageDriveBlobalGetIntercityHigh (), Configuration.Argb_8888); Toast.makeText (HTMLActivity.this, "bitmap" + bitmap.toString (), Toast.LENGTH_LONG) .show (); Canvas canvas = new canvas (bitmap); Canvas.drawPicture (pictureDrawable.getPicture ()); Return bitmap; }
The sample to show what I am doing in my code;
Private picture diagram; Private string url; Private WebView WebView; Private bitmap HTML bitmap; Private Pictorial HTMLPic Draw; // goal is to change WebView - & gt; Picture - & gt; Picture drainage - & gt; Bitmap image = webview.capturePicture (); HTMLPicDraw = New Picture (Picture); // HTMLPicDraw is a PictureDrawable object is good, no tap pointer exception here // is left to go from PictureDrawable to Bitmap
use belove code is working for me .....
// view public static bitmap getBitmapFromView (see) get bitmap { Bitmap returnedBitmap = bitmap .createBitmap (view.getWidth (), view.getHeight (), Bitmap.Config.ARGB_8888); Canvas canvas = new canvas (returned bitmap); Pulled bgDrawable = view.getBackground (); If (bgDrawable! = Null) bgDrawable.draw (canvas); / * Other canvas color (color. WHITE); * / View.draw (canvas); Returned bitmap; }
Comments
Post a Comment