| 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 to logoStream Byte [] logoBuf = logoStream. toByteArray (); // Save the image to byte [] Bitmap temp = BitmapFactory. decodeByteArray (logoBuf, 0, logoBuf. length ); // Read the image from byte [] to generate the 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 (); } } |