I only have one image rendered (the background image) and I get the exact same results from canvas.translate() vs .drawbitmap. The problem seems to be either the time it takes for it to draw the bitmap, or the time it takes to run through the sin/cos formulas for the placement. The image is only a little larger than my phone's display (800 X 480) but I get the same results when drawing a 50x50px image.
This is my animation loop: int Speed = 50; double speedScale = (float) ((0.001*2*Math.PI)/Speed); double Dist = SystemClock.elapsedRealtime() * speedScale; NewX = (int) (OffsetX + Math.sin(Dist)*19); NewY = (int) (OffsetY + Math.cos(Dist)*19); c.drawBitmap(mBackground, NewX + OffsetX, NewY + OffsetY, null); On Mar 21, 10:28 pm, Peter Webb <r.peter.w...@gmail.com> wrote: > I don't think OpenGL will help. > > I use canvas.translate and canvas.rotate extensively in my wallpaper, > which runs very smoothly. AFAIK these commands just set mostly > hardware flags for where to draw, and appear to execute > instantaneously. > > You haven't posted any code, but I would make a bet on why it is > running at 3fps. > > You are displaying images. I bet you do a jpeg rendering every time > through your animation loop, and this is what is killing your > performance. > > Draw the image to a bitmap, only once at the start (when a new image > is first to be displayed). Persist it for the liefetime of the > animation loop. Only do another jpeg rendering when you have a new > image to display. > > In your animation loop: > > Translate the canvas > Draw the bitmap > Translate the canvas back > > If you have checked and you are *not* doing jpeg rendering in your > animation loop then you should find out what line is causing your 300 > mS delay (shouldn't be too hard!) and fix that. > > Peter Webb > > On Mar 22, 7:58 am, Jeffrey <jeffisagen...@gmail.com> wrote: > > > > > > > > > I am not getting any speed improvements over just changing the top/ > > left coordinates of the .drawbitmap() command. I'm going to look into > > using OpenGL as I think part of my problem is the (relatively) low > > resolution makes even fluid movement seem choppy when it's moving by 1 > > pixel increments. > > > On Mar 20, 11:35 pm, Peter Webb <r.peter.w...@gmail.com> wrote: > > > > Call canvas.translate(-x), draw, then call canvas.translate(x) > > > > You are moving the location on the canvas underneath where you draw, > > > after you have drawn whatever you need to move the canvas back. > > > > On Mar 21, 8:47 am, Jeffrey <jeffisagen...@gmail.com> wrote: > > > > > Is there a way around having to call canvas.drawbitmap() every time? > > > > And if I call canvas.translate() after drawing the image doesn't move, > > > > it instead moves everything that would draw *after* the call to > > > > canvas.translate(). > > > > > Thank you for your help so far, and I'm hoping you have just a little > > > > bit left in you :) > > > > > On Mar 20, 9:12 am, Riyad Kalla <rka...@gmail.com> wrote: > > > > > > Jeffrey, > > > > > > To what Peter said, mobile devices are very fill-rate-limited (at > > > > > least these current gen of phones) so depending on how you are > > > > > repainting that image over and over and over again to the Canvas, that > > > > > could explain the speed issue. > > > > > > If you tried a tiny little 16x16 icon and it went much faster with the > > > > > same code, then I think you've found your culprit. > > > > > > Regardless, Peter's approach sounds like the right way; upload image > > > > > data to the GPU one, then just move your "view" of it around in a > > > > > circle, panning across the image. > > > > > > On Mar 19, 3:07 pm, Jeffrey <jeffisagen...@gmail.com> wrote: > > > > > > > I'm trying to make a simple (or so I thought) live wallpaper that > > > > > > takes an image and moves it slowly in a circular motion, to make the > > > > > > picture seem less static and more like looking out a window. I took > > > > > > the live wallpaper tutorial from the SDK and stripped it down to the > > > > > > bare bones so I could add to it. But the issue is that no matter > > > > > > what > > > > > > size the image I'm moving, or what format (drawable or bitmap), it > > > > > > is > > > > > > only getting about 3 fps. > > > > > > > I don't know what to do to make this run faster, I have very limited > > > > > > programming knowledge so I don't know if I'm missing something > > > > > > stupid. > > > > > > > Also, this is the code I'm using to calculate the circular movement: > > > > > > > int NewX = (int) (OffsetX + Math.sin(Dist)*19); > > > > > > int NewY = (int) (OffsetY + Math.cos(Dist)*19); > > > > > > > where Dist is the speed it's moving and 19 is the radius of the > > > > > > circle. > > > > > > > Is there an easier way? I looked into Tween animation but I don't > > > > > > know > > > > > > how I would implement my circle code into it.- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text - -- 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