In simple words I want to "revert" the crop operation. In crop you choose a rect and cut the image to the specified rect. In my case I need to do the opposite thing - to add empty space around the image and fill it with color. Note - image may have transparent background so I can't just draw one image over another image.
All the input data (rects and image) I already have. How to solve this task?
Basic process:
CGContextClearRect(CGContextRef c, CGRect rect);
or (Swift).clear(_ rect: CGRect)
Here is an example, using Swift:
and call it like this: