summaryrefslogtreecommitdiff
path: root/samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java
diff options
context:
space:
mode:
authorChristian Mehlmauer <FireFart@gmail.com>2010-05-20 21:02:04 +0200
committerChristian Mehlmauer <FireFart@gmail.com>2010-06-12 12:13:18 +0200
commit62e92d7a2a3fd2798901ec2e7c452ff0e4067163 (patch)
treef2e9f60c4735feb3a6e443a15578de58d0fb54d2 /samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java
parent4b5c09f29e37c8d07dcba57e4c4da13089a9d63d (diff)
Cleaned up Samples by removing unsed imports and variables.
Changed deprecated Config.LOGD to Config.DEBUG Removed unnecessary whitespaces Change-Id: I01414dd83eb6f9a41e56762dd7fc00e7f1115039
Diffstat (limited to 'samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java')
-rw-r--r--samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java21
1 files changed, 9 insertions, 12 deletions
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java b/samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java
index 8fff231d3..90d345062 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java
@@ -18,15 +18,12 @@ package com.example.android.apis.graphics;
import com.example.android.apis.R;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
-import android.view.KeyEvent;
import android.view.*;
import java.io.InputStream;
-import java.io.ByteArrayOutputStream;
public class AlphaBitmap extends GraphicsActivity {
@@ -35,23 +32,23 @@ public class AlphaBitmap extends GraphicsActivity {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Bitmap mBitmap;
private Bitmap mBitmap2;
private Bitmap mBitmap3;
private Shader mShader;
-
+
private static void drawIntoBitmap(Bitmap bm) {
float x = bm.getWidth();
float y = bm.getHeight();
Canvas c = new Canvas(bm);
Paint p = new Paint();
p.setAntiAlias(true);
-
+
p.setAlpha(0x80);
c.drawCircle(x/2, y/2, x/2, p);
-
+
p.setAlpha(0x30);
p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
p.setTextSize(60);
@@ -59,28 +56,28 @@ public class AlphaBitmap extends GraphicsActivity {
Paint.FontMetrics fm = p.getFontMetrics();
c.drawText("Alpha", x/2, (y-fm.ascent)/2, p);
}
-
+
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
InputStream is = context.getResources().openRawResource(R.drawable.app_sample_code);
mBitmap = BitmapFactory.decodeStream(is);
mBitmap2 = mBitmap.extractAlpha();
mBitmap3 = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
drawIntoBitmap(mBitmap3);
-
+
mShader = new LinearGradient(0, 0, 100, 70, new int[] {
Color.RED, Color.GREEN, Color.BLUE },
null, Shader.TileMode.MIRROR);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
Paint p = new Paint();
float y = 10;
-
+
p.setColor(Color.RED);
canvas.drawBitmap(mBitmap, 10, y, p);
y += mBitmap.getHeight() + 10;