Crop image in required shape other than rectangle
How to crop a image in Qt by marking points on image. As i found cropping based on rectangle only (cropped and taken bytearray of cropped image).
@yuvaram What other shapes do you need? Why is rectangle not enough?
Thank you @jsulm
my requirement is to crop the image for example ball (in circle shape), banana (curved shape). Shape may vary based on Object at run time. Some thing like photo shop has a feature of cropping based on marking points.
@yuvaram This is actually not cropping, it is rather clipping. The picture will be still a rectangle.
@yuvaram I don't think Qt provides anything for this. You will either need to implement it by yourself or use third party library like ImageMagic or OpenCV.
Create a mask
QImage mask(baseImage.size(),QImage::Format_MonoLSB);or use one of the available methods to get the mask (http://doc.qt.io/qt-5/qimage.html#createHeuristicMask, http://doc.qt.io/qt-5/qimage.html#createMaskFromColor) then iterate through every pixel and "delete" (
baseImage.setPixelColor(x,y,Qt::transparent);?) those that have a 0 in the mask