Address: http://blog.csdn.net/you_and_me12/article/details/7262915
Edit (scale down, graffiti, etc.) the image and save it as an image of the specified format and size.
Post Code first:
Bitmap bmp = Bitmap.createBitmap(480, 800, Config.ARGB_8888);Canvas canvas = new Canvas(bmp);canvas.drawBitmap(this.bmp, matrix, paint);canvas.save(Canvas.ALL_SAVE_FLAG);canvas.restore();File file = new File("/sdcard/akai/");if(!file.exists())file.mkdirs();try {FileOutputStream fos = new FileOutputStream(file.getPath() + "/2.png");bmp.compress(Bitmap.CompressFormat.PNG, 100, fos);fos.close();System.out.println("saveBmp is here");} catch (Exception e) {e.printStackTrace();}
Explanation:
1. Create a bitmap image and specify the size;
2. Create a new canvas on the image, draw it on the canvas, and save it;
3. directory file to be saved. Note that if the written directory is "/sdcard/Akai/", you must first create a file. mkdirs (); otherwise, no found is returned for fileoutputstream;
4. Add permissions: <uses-Permission Android: Name = "android. Permission. write_external_storage"/>