java - Android bitmaps and capturing screen -
java - Android bitmaps and capturing screen -
i have app generates study in tablelayout variable number of tablerows.
i utilize next code capture table bitmap:
tablelayout tl = (tablelayout)findviewbyid(r.id.csrtablelayout); bitmap csr = bitmap.createbitmap(tl.getwidth(), tl.getheight(), bitmap.config.argb_8888); canvas canvas = new canvas(csr); tl.draw(canvas);
after capture screen bitmap, attach email using:
//folder exists file file = new file(folder.getabsolutepath()+"/csr"+csrnum+".jpg"); bufferedoutputstream bos = null; fileoutputstream fos = null; seek { fos=new fileoutputstream(file); bos=new bufferedoutputstream(fos); if(bos!=null) { seek { csr.compress(bitmap.compressformat.jpeg, 60, bos); } grab (outofmemoryerror e) { toast.maketext(customerreportactivity.this, "out of memory!", toast.length_short).show(); } { fos.flush(); fos.close(); bos.flush(); bos.close(); } } } grab (exception e) { e.printstacktrace(); } if(file.exists()) { intent = new intent(intent.action_send); i.setflags(intent.flag_activity_new_task); i.settype("message/rfc822"); string emailto[] = {"***@****.***"}; i.putextra(intent.extra_email,emailto); i.putextra(intent.extra_subject,"..."); i.putextra(intent.extra_text, "..."); i.putextra(intent.extra_stream,uri.parse("file://"+file.getabsolutepath())); startactivity(i); } else { toast.maketext(customerreportactivity.this, "error attaching study email!", toast.length_short).show(); }
the problem table can quite large, such 1600x2400dp. have gotten outofmemoryerror on line "bitmap.createbitmap(...)" there alternative method capture screen while not overflowing vm heap? if understand correctly, calling bitmap.createbitmap(...) creating bitmap total size plain white. possible create no pixel info , fill in 1 time called csr.compress(...) way stays small? ideas/suggestions appreciated! in advance!
why don't split images multiple smaller regions , send....you can stitch them back....or if have patience , skill...you can stitch images reading smaller image files saved on disk , send stitched image...you can utilize translate , clip canvas before sending draw() method required regions
java android bitmap out-of-memory
Comments
Post a Comment