Skip to content Skip to sidebar Skip to footer

Draw An Bitmap On A Canvas With A Custom Shape

I want to draw an image with the following shape on a canvas: The black must be replaced by my image. I currently draw the image as a whole. I just don't know how I can get that s

Solution 1:

Thanks to pskink I've got it:

intwidth=this.getMeasuredWidth();
intheight=this.getMeasuredHeight();

BitmapShader shader;
shader = newBitmapShader(header, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);

mPaint.setShader(shader);

Pathpath=newPath();

path.moveTo(0,0);
path.lineTo(0,height/2);
path.lineTo(width,height/4);
path.lineTo(width,0);

canvas.drawPath(path,mPaint);

Just use a shader and a path to do the job.

Post a Comment for "Draw An Bitmap On A Canvas With A Custom Shape"