Hi, Thanks !
I think I cant use Canvas.scale() cause every image needs a different size, but Canvas.drawBitmap seems ok. I considered it, but thought these rects are clipping rects and not resizing. Will try that. Shimon On Dec 4, 7:29 pm, Romain Guy <romain...@android.com> wrote: > Your current solution is a terrible performance hog. On every frame > drawn you create (and allocate) a new Bitmap! Instead of calling > createScaledBitmap() you should just change the scale factor of the > Canvas (Canvas.scale()) or use a variation of drawBitmap() that takes > a size (for instance, Canvas.drawBitmap(Bitmap, Rect source, Rect > destination, Paint)). > > > > > > On Fri, Dec 4, 2009 at 8:20 AM, TAKEphONE <shimo...@gmail.com> wrote: > > Hi, > > > I have a problem - I am writing an application that displays up to 12 > > images on screen, and moves them around, plus reads touch events. I am > > using a sample code I found, and it works great. Now I need adding 3D > > - meaning emulating the objects moving in the Z axis, too (in/out of > > screen). > > > To do this, I need to resize the images as they move. > > > To test this, I changed the following line in my onDraw (Panel) code: > > > canvas.drawBitmap(bitmap, coords.getX(), coords.getY(), null); > > > to: > > > Bitmap bmpScaled = Bitmap.createScaledBitmap(bitmap, 112, 112, false); > > canvas.drawBitmap(bmpScaled, coords.getX(), coords.getY(), null); > > > Which works, BUT - movement on screen, plus response to touch events > > becomes real Jiggly. > > > Checking the log I see that every call to createScaledBitmap causes > > garbage collection of around 90mS, which causes the total app to > > respond jiggly. > > > Tried preparing 20 sized bitmaps beforehand, but since that moves the > > calls to those createScaledBitmap to the beginning of the app - it > > takes forever to load... > > > Can you think of any workaround or other way to achieve the scaling > > effect ? > > > TIA > > > Shimon > > > -- > > 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 > > -- > Romain Guy > Android framework engineer > romain...@android.com > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them -- 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