I am looking for a way to, in Objective-C, create a PNG from several smaller PNGs based on how the user sets things up. Is this possible using existing Apple classes, or do I need to use a 3rd party library? If 3rd party code is needed, can anyone recommend a good library? The simpler the better – simple filters (such as darkening/lightening the image) would be nice but not required.
Here is some pseudo-code, to give you a better idea of what I am looking for:
image = [myImageLibrary imageWithHeight:1024 width:768];
[image addImage:@"background.png" atX:0 andY:0 withRotation:0];
[image addImage:@"image2.png" atX:100 andY:200 withRotation:90];
[image saveAtLocation:@"output.png"];
At output.png we see image2.png placed on top of background.png and rotated 90 degrees
P.S. – I am sorry if this seems to be a duplicate of another question, I just have not found an answer that works for what I am trying to do.
Have you read the “Creating and Drawing Images” section of the Drawing and Printing Guide for iOS and the UIImage Class Reference docs?
What you’re after is perfectly possible – with a well built class you could pretty much use that pseudo code as-is.
As a starter for ten, you could:
UIGraphicsBeginImageContext.drawAtPoint: method of the UIImage classUIGraphicsGetImageFromCurrentImageContext.In terms of steps 1 and 3, see the UIKit Function Reference for more info. Additionally, the
imageWithCGImage:scale:orientation:method of the UIImage class may prove useful for performing transformations, etc. as a part of step 2.