I have several rectangular images (in landscape and portrait mode) and want to draw them onto a transparent square image, so that all images became the same size without cropping them. How would I create a transparent UIImage and draw another on top?
Thanks for any hints.
Deep copying UIImage *newImage = [UIImage imageWithData:UIImagePNGRepresentation(oldImage)]; This will copy the data but will require setting the orientation property before handing it to something like UIImageView for proper display. Another way to deep copy would be to draw into the context and grab the result.
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
CGBitmapContextCreate
. You'll need to determine what the size of the resulting composite image here. You can think of this as a sort of canvas.CGContextDrawImage
. This will draw images onto the same context.CGBitmapContextCreateImage
.[UIImage imageWithCGIImage:]
.Code examples can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With