I am trying to crop an image. Sometimes the calculated cropped image outreach the initial size (since the cropping is calculated by the use of a distance). How is it possible instead of receiving an out of bounds error, to fill the rest with black (the same effect as in wrapAffine rotation).
Well, cropping is by definition reducing the size of an image. So if you want to potentially extend the image at the same time, and fill it with black, you could enlarge it first. Something like the following algorithm:
You could wrap this up into a class and give it the same interface as the crop filter, then you would have a generic solution.