Home>

bitmap logobitmap=bitmapfactory.decoderesource (mcontext.getresources (), r.drawable.arcnote_logo);
bytearrayoutputstream logostream=new bytearrayoutputstream ();
boolean res=logobitmap.compress (bitmap.compressformat.png, 100, logostream);
// Read the image into logostream
byte [] logobuf=logostream.tobytearray ();
// Save the image in byte []
bitmap temp=bitmapfactory.decodebytearray (logobuf, 0, logobuf.length);
// Read the image from byte [] to generate a bitmap object temp
savemybitmap ("tttt", temp);
// Save the image to the SD card
public void savemybitmap (string bitname, bitmap mbitmap) {
 file f=new file ("/ sdcard /" + bitname + ".png");
 try {
  f.createnewfile ();
 } catch (ioexception e) {
  // todo auto-generated catch block
 }
 fileoutputstream fout=null;
 try {
  fout=new fileoutputstream (f);
 } catch (exception e) {
  e.printstacktrace ();
 }
 mbitmap.compress (bitmap.compressformat.png, 100, fout);
 try {
  fout.flush ();
 } catch (ioexception e) {
  e.printstacktrace ();
 }
 try {
  fout.close ();
 } catch (ioexception e) {
  e.printstacktrace ();
 }
}
  • Previous Loading and running JavaScript optimization topics
  • Next C # method of image sharpening