<https://lh3.googleusercontent.com/-yKMQ9N8KA7k/VthdtfJpcVI/AAAAAAAACF0/bef0oFEcb4E/s1600/device-2016-03-03-105200.png> This would actually draw a black color for your canvas. See screenshot.
On Sunday, November 25, 2012 at 7:25:15 PM UTC-5, Romain Guy wrote: > > Surfaces are double (or even triple) buffered. You are indeed not getting > in your canvas what's currently on screen but what was on screen a frame > ago. The easiest way to clear the surface is to call canvas.drawColor(0, > PorterDuff.Mode.CLEAR) (you can also use 0xff000000, PorterDuff.Mode.SRC). > > > On Sun, Nov 25, 2012 at 3:42 PM, Johan <[email protected] <javascript:> > > wrote: > >> I have some strange behaviour when repainting the screen with my live >> wallpaper. I'm scaling an image and drawing it to the screen, but on each >> draw (as the image is scaled smaller than the previous draw), I can still >> see the previous image below the new image. >> How do I clear the previous image out so that only the new scaled image >> is displayed? >> >> This is my code: >> >> private final Runnable mDraw = new Runnable() { >> public void run() { >> draw(); >> } >> }; >> >> void draw() { >> SurfaceHolder holder = getSurfaceHolder(); >> Canvas canvas = null; >> try { >> canvas = holder.lockCanvas(); >> if(canvas != null) { >> this.paintScreen(canvas); >> } >> }finally { >> if(canvas != null) { >> holder.unlockCanvasAndPost(canvas); >> } >> } >> mHandler.removeCallbacks(mDraw); >> if (mVisible) { >> mHandler.postDelayed(mDraw, 60000); >> } >> } >> >> Every minute my paintSurface function scales a bitmap (image loaded from >> resources), then uses canvas.drawBitmap to put the image on the screen. As >> I understand from the documentation, holde.lockCanvas()is not supposed to >> contain the image currently on the screen and every pixel has to be >> drawn... this doesn't seem to be the case since the previous pixels are >> obviously under the new pixels. >> >> Thanks, >> J >> (26 Sept '12 - 10:45 AM) >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> <javascript:> >> To unsubscribe from this group, send email to >> [email protected] <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > > > -- > Romain Guy > Android framework engineer > [email protected] <javascript:> > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/e0e401bb-079e-4519-a650-036d554ecfda%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

