반응형
package test.ImageEX;
import android.*;
import android.content.*;
import android.content.res.*;
import android.graphics.*;
import android.view.*;
public class ImageView extends View{
private Bitmap image;
public ImageView(Context context) {
super(context);
setBackgroundColor(Color.WHITE);
// TODO Auto-generated constructor stub
Resources r= context.getResources();
image =BitmapFactory.decodeResource(r,R.drawable.sample);
}
static int count1=0;
Paint p=new Paint();
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
//image ++
canvas.drawText("WIND : "+count1,180,20,p);
count1++;
int w= image.getWidth();
int h=image.getHeight();
canvas.drawBitmap(image, 0,0, null);
Rect src =new Rect(0,0,w,h);
Rect dst =new Rect(0,200,w*2,200+h*2);
canvas.drawBitmap(image, src,dst, null);
src =new Rect(0,0,w,h);
dst =new Rect(0,200,w/2,200+h/2);
canvas.drawBitmap(image, src,dst, null);
super.onDraw(canvas);
}
}
반응형