Example usage for android.graphics Paint setDither

List of usage examples for android.graphics Paint setDither

Introduction

In this page you can find the example usage for android.graphics Paint setDither.

Prototype

public void setDither(boolean dither) 

Source Link

Document

Helper for setFlags(), setting or clearing the DITHER_FLAG bit Dithering affects how colors that are higher precision than the device are down-sampled.

Usage

From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java

private void DrawEvents() {
    Bitmap charty = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
    Canvas EventsCanvas = new Canvas(charty);
    final Paint paint = new Paint();

    paint.setStyle(Paint.Style.FILL);
    paint.setColor(getResources().getColor(R.color.DarkBlue));
    paint.setAntiAlias(true);/*from  ww w  . j  av  a2s.c  o m*/
    EventsCanvas.drawOval(new RectF(1, 1, 199, 199), paint);

    RadialGradient gradient = new RadialGradient(200, 200, 200, 0xFF6b7681, 0xFF000000,
            android.graphics.Shader.TileMode.CLAMP);
    paint.setDither(true);
    paint.setShader(gradient);
    EventsCanvas.drawOval(new RectF(6, 6, 194, 194), paint);

    //Special Bits
    int Scale = 100;

    if (EventCount > 100)
        ;
    Scale = EventCount + 50;

    drawScale(EventsCanvas, true, EventCount, Scale);
    drawGaugeTitle(EventsCanvas, "Events Count");
    drawGaugeNeedle(EventsCanvas, EventCount, Scale);
    //drawGloss(EventsCanvas);

    ((ImageView) findViewById(R.id.EventsGauge)).setImageBitmap(charty);
}

From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java

private void DrawDevices() {
    Bitmap charty = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
    Canvas DeviceCanvas = new Canvas(charty);
    final Paint paint = new Paint();

    paint.setStyle(Paint.Style.FILL);
    paint.setColor(getResources().getColor(R.color.DarkBlue));
    paint.setAntiAlias(true);//from   w w w.j  a v a 2s  .  co  m
    DeviceCanvas.drawOval(new RectF(1, 1, 199, 199), paint);

    RadialGradient gradient = new RadialGradient(100, 50, 150, 0xFF6b7681, 0xFF000000,
            android.graphics.Shader.TileMode.CLAMP);
    paint.setDither(true);
    paint.setShader(gradient);
    DeviceCanvas.drawOval(new RectF(6, 6, 194, 194), paint);

    int Scale = 10;

    //Special Bits
    if (DeviceCount < 500)
        Scale = 750;

    if (DeviceCount < 250)
        Scale = 350;

    if (DeviceCount < 100)
        Scale = 150;

    if (DeviceCount < 50)
        Scale = 50;
    try {
        drawScale(DeviceCanvas, false, DeviceCount, Scale);
        drawGaugeTitle(DeviceCanvas, "Device Count");
        drawGaugeNeedle(DeviceCanvas, DeviceCount, Scale);
        //drawGloss(EventsCanvas);
        ((ImageView) findViewById(R.id.DeviceGauge)).setImageBitmap(charty);
    } catch (Exception e) {
        e.printStackTrace();
    }
}