I want to draw a bitmap on a rectangle. I use the values below:
this.meshWidth = 1;
this.meshHeight = 1;
this.verts = new float[8];
this.points[0].x = (float)(this.getWidth()/4);
this.points[0].y = (float)(this.getHeight()/4);
this.points[1].x = (float)(this.points[0].x+this.getWidth()/2);
this.points[1].y = (float)(this.points[0].y);
this.points[2].x = (float)(this.points[0].x);
this.points[2].y = (float)(this.points[0].y+this.getHeight()/2);
this.points[3].x = (float)(this.points[1].x);
this.points[3].y = (float)(this.points[2].y);
points array is my vertex array.
my onDraw method
public void onDraw(Canvas canvas){
//canvas.drawBitmap(bitmap, 20,20, null);
Paint paint = new Paint();
paint.setColor(Color.BLUE);
canvas.drawLine(this.points[0].x, this.points[0].y, this.points[1].x, this.points[1].y, paint);
canvas.drawLine(this.points[1].x, this.points[1].y, this.points[3].x, this.points[3].y, paint);
canvas.drawLine(this.points[3].x, this.points[3].y, this.points[2].x, this.points[2].y, paint);
canvas.drawLine(this.points[2].x, this.points[2].y, this.points[0].x, this.points[0].y, paint);
canvas.drawBitmapMesh(this.bitmap, meshWidth, meshHeight, verts, 0, null, 0, null);
}
The output is this
I want to draw bitmap on rectangle surrounded with blue lines..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With