i have made simple application which load image in canvas scale it according to screen height and width and after that user can write and draw something on it using his finger and once user complete its drawing. He should be able to save it. But i have to save the image as same width and height as original image.(not according to phone screen size). So i am scaling the image to its original height and width. But it is only able to scale if i use Bitmap type Bitmap.Config.RGB_565 as it uses law memory(but very poor quality). For others type like Bitmap.Config.ALPHA_8, Bitmap.Config.ARGB_8888 it is giving MemoryOutOfException. The code to re size image to its original width and height is as follow.
public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { int width = bm.getWidth(); int height = bm.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // create a matrix for the manipulation Matrix matrix = new Matrix(); // resize the bit map matrix.postScale(scaleWidth, scaleHeight); // recreate the new Bitmap BitmapFactory.Options options = new BitmapFactory.Options(); options.inTempStorage = new byte[16*1024]; //bm. //BitmapFactory.decodeByteArray(bm.getRowBytes(), 0, length, opts) Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); // return Bitmap.createScaledBitmap(bm, newWidth, newHeight, true); return resizedBitmap; } The following is code to create blank bitmap on which i draw the content which is in my view and then i try to resize it. Bitmap b = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.RGB_565); The main problem with Bitmap.Config.RGB_565 is the quality of image is very poor compare to original image which has very good quality. so i want to use Bitmap.Config.ARGB_8888 if possible. any suggestion and advise is more then welcome. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en