Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Bitmap shaped Rhomboid

I have to implement Bitmap whose shape is like a rhomboid(For ref. I have attached sample image for it.) and the source image is rectangular. I do want to make the image to be skewed, cut the image in this shape.

Sample view of Gallery

Can anyone give me any idea how it can be implemented?

like image 874
dev_android Avatar asked Jun 24 '26 20:06

dev_android


1 Answers

Create a Path of the shape you need and use the canvas.clipPath() method prior to drawing each of the bitmaps.

I have done this with a circle:

Path mPath = new Path();

mPath.addCircle(centerx, centery, radius, Path.Direction.CCW);

canvas.clipPath(mPath, Region.Op.REPLACE);
canvas.drawBitmap(....);

There are various path methods that you can use to create the desired path (path.addArc, path.lineTo, etc).

like image 132
eyespyus Avatar answered Jun 27 '26 12:06

eyespyus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!