Hey guys

I posted this before the weekend but it seems to have dissappeared so
sorry if you're seeing this for a second time (I can't find any way of
find 'my posts' in Google groups either). I was hoping that one of you
might have had some experience with this.

I am creating a Live Wallpaper and I'm painting to the canvas on every
Runnable.run call with a changing colour and i'm hoping to put a
gradient over the top but the gradient i'm creating is banding
horribly. After Googling around for a day I came up with 2 solutions:
set the dither to true
set the canvas bitmap to ARGB_8888

i've tried doing the first one (set dither to true) on the
getWallpaper() and the Paint object but it's not helped (I can't see
any dithering at all) so I've tried changing the canvas bitmap but i'm
not sure how to actually display it

// _canvasBmp = Bitmap.createBitmap(metrics.widthPixels,
metrics.heightPixels, Bitmap.Config.ARGB_8888);

_shadowPaint.setStyle(Paint.Style.FILL);
_shadowPaint.setShader(new RadialGradient(metrics.widthPixels / 2,
metrics.heightPixels / 2, metrics.heightPixels / 2, 0x00000000,
0x33000000, Shader.TileMode.CLAMP));
_shadowPaint.setDither(true); // this hasn't seemed to have done
anything

// my main rendering method is this (based on the Google live
wallpaper example)
void drawFrame()
{
        final SurfaceHolder holder = getSurfaceHolder();

        Canvas c = null;
        try
        {
                c = holder.lockCanvas();

                // this was my attempt to update the bitmap to one that was
ARGB_8888 but it didn't render at all
                //c.setBitmap(_canvasBmp);

                if (c != null)
                {
                        // draw something
                        drawBackground(c);
                        drawTouchPoint(c);
                        drawShading(c);
                        drawBorder(c);

                        getWallpaper().setDither(true); // yet another attempt 
to get some
kind of dithering going to no avail
                }
        }
        finally
        {
                if (c != null)
                        holder.unlockCanvasAndPost(c);
        }

        _handler.removeCallbacks(_drawClock);

        if (_isVisible)
        {
                _handler.postDelayed(_drawClock, 1000 / 25);
        }
}


private void drawShading(Canvas c)
{
        c.drawRect(_screenBounds, _shadowPaint);
}

Thanks in advance for your time

best
obie

-- 
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]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to