android - whole viewgroup to bitmap -
is possible full bitmap viewgroup-object?
this code takes 'screenshot' off view group that's on screen, want whole view, what's not on screen.
public void export(viewgroup view){ view.setdrawingcacheenabled(true); view.setdrawingcachequality(view.drawing_cache_quality_high); bitmap bitmap = view.getdrawingcache(true); }
here used scrollview whole view bitmap here u can use instead of scrollview anyother view group linerlayout etc..
bitmap map = loadbitmapfromview(getapplicationcontext(),scrollview); bytearrayoutputstream bytes = new bytearrayoutputstream(); map.compress(bitmap.compressformat.jpeg, 100, bytes); //you can create new file name "test.jpg" in sdcard folder. file f = new file("/sdcard" +"/" + "mainemailpdf.jpg"); f.createnewfile(); //write bytes in file fileoutputstream fo = new fileoutputstream(f); fo.write(bytes.tobytearray()); barray = bytes.tobytearray(); // remember close de fileoutput fo.close();
and loadbitmapfromview method is:
public static bitmap loadbitmapfromview(context context, view v) { toast.maketext(context, v.getmeasuredheight() + "::::::::::::" + v.getmeasuredwidth(), toast.length_long).show(); if (v.getmeasuredheight() > 0) { v.measure(layoutparams.wrap_content, layoutparams.wrap_content); bitmap b = bitmap.createbitmap(v.getwidth(), v.getheight(), bitmap.config.argb_8888); canvas c = new canvas(b); v.layout(0, 0, v.getwidth(), v.getwidth()); v.draw(c); return b; } return null; }
i hope helps :)
any query let me know.
Comments
Post a Comment