Thank you "Strees of Boston". In the above sample, I replaced the line
Bitmap mutablePhoto = photo.copy(Bitmap.Config.RGB_565, true); with Bitmap mutablePhoto = Bitmap.createScaledBitmap(photo, 480, 320, false); photo.recycle(); and now it works. Scaling down did the trick. Thanks again! Ph On Apr 2, 12:07 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote: > I have similar experiences. It seems you can have about 1 full size > pic open (as a bitmap) and a few small ones. Anything extra will give > you your error-message. In your example, until you call 'photo.recycle > ()' you have 2 large bitmaps open at the same time at some point > (photo and mutablePhoto)... and quite a large byte[] array (byte[] > data) is still allocated as well. > > From what i've read on these forums, you need to scale and/or crop > your image so that the final image(=bitmap) you're working on is no > larger (in pixels) than your screen (e.g. 320x480). > > On Apr 2, 2:56 pm, phil <philipp.bre...@gmail.com> wrote: > > > I am > > 1) taking a picture and > > 2) then draw another Bitmap on top of it > > 3) then I store it > > > I am doing it as follows and it works on the emulator. > > > On the device I get a OutOfMemoryError: bitmap size exceeds VM budget > > android.graphics.Bitmap.nativeCopy(Native Method) > > android.graphics.Bitmap.copy(Bitmap.java:199) > > in the line copy the Bitmap to get a mutable Bitmap. > > > private void captureImage() { > > Camera.PictureCallback pcbJpeg = new > > Camera.PictureCallback() { > > public void onPictureTaken(byte[] data, Camera c) { > > // Save Picture > > Log.v(LOG_TAG, "PictureCallback: > > data.length=" + data.length); > > Bitmap photo = > > BitmapFactory.decodeByteArray(data, 0, > > data.length); > > Bitmap mutablePhoto = > > photo.copy(Bitmap.Config.RGB_565, true); > > photo.recycle(); > > Canvas n = new Canvas(mutablePhoto); > > n.drawBitmap(myPointOfInterestView.b, 0, 0, > > null); > > > String url = > > Images.Media.insertImage(getContentResolver(), > > mutablePhoto, > > "title", null); > > mutablePhoto.recycle(); > > Log.i(LOG_TAG, url); > > } > > }; > > > What I am asking: > > > a) Is there a better way to do what I am doing? > > 1) take a picture > > 2) draw another Bitmap on top of it > > 3) then I store it > > > b) What is the best way to create a mutable Bitmap from the picture I > > just took with the camera? > > > In my app, resolution is not an issue. If it works better for small > > photos that would be fine. > > > Any help is appreciated, > > Best regards, > > Ph > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---