Mercurial > MadButterfly
comparison Android/java/org/madbutterfly/MBView.java @ 493:1b6228092a57 Android_Skia
Java code for MadButterfly JNI.
This is Java code that access MadButterfly JNI interface.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 26 Nov 2009 15:02:51 +0800 |
parents | |
children | 2d7df44e6299 |
comparison
equal
deleted
inserted
replaced
492:e95598916dfb | 493:1b6228092a57 |
---|---|
1 package org.madbutterfly; | |
2 | |
3 import android.view.SurfaceView; | |
4 import android.view.SurfaceHolder; | |
5 import android.content.Context; | |
6 import android.graphics.Canvas; | |
7 import android.graphics.Bitmap; | |
8 import android.graphics.Paint; | |
9 import android.graphics.Xfermode; | |
10 import android.graphics.PorterDuff; | |
11 import android.graphics.PorterDuffXfermode; | |
12 | |
13 class MBView extends SurfaceView { | |
14 redraw_man rdman; | |
15 Canvas cr, backend; | |
16 Bitmap cr_bmap, backend_bmap; | |
17 Paint copy_pnt; | |
18 int w, h; | |
19 | |
20 public MBView(Context context) { | |
21 super(context); | |
22 Paint paint; | |
23 Xfermode mode; | |
24 | |
25 rdman = null; | |
26 cr = null; | |
27 backend = null; | |
28 | |
29 mode = new PorterDuffXfermode(PorterDuff.Mode.SRC); | |
30 copy_pnt = new Paint(); | |
31 copy_pnt.setXfermode(mode); | |
32 } | |
33 | |
34 public redraw_man get_rdman() { | |
35 if(rdman != null) | |
36 return rdman; | |
37 | |
38 w = getWidth(); | |
39 h = getHeight(); | |
40 | |
41 cr_bmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); | |
42 cr = new Canvas(cr_bmap); | |
43 backend_bmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); | |
44 backend = new Canvas(backend_bmap); | |
45 | |
46 rdman = new redraw_man(cr, backend, this); | |
47 | |
48 return rdman; | |
49 } | |
50 | |
51 protected void onSizeChanged(int w, int h, int oldw, int oldh) { | |
52 this.w = w; | |
53 this.h = h; | |
54 cr_bmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); | |
55 cr.setBitmap(cr_bmap); | |
56 backend_bmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); | |
57 backend.setBitmap(backend_bmap); | |
58 } | |
59 | |
60 public void redraw() { | |
61 SurfaceHolder holder; | |
62 Canvas canvas; | |
63 | |
64 holder = getHolder(); | |
65 canvas = holder.lockCanvas(); | |
66 canvas.drawBitmap(backend_bmap, 0, 0, copy_pnt); | |
67 } | |
68 } |