Question

I have one UIImage which I want to deep copy to another (so that I may add it to an NSMUtableArray of images)

I cannot get it to deep copy, I have looked at zones and such but this no luck.

This is what I have trieD:

_incrementalImage = UIGraphicsGetImageFromCurrentImageContext();

UIImage *imgcpy = [[UIImage allocWithZone:[_incrementalImage zone]];
[stack addObject:imgcpy];

Basically I need a copy of incrementalImage onto stack that won't change if _incrementalImage or currentImageContext changes.

Was it helpful?

Solution

UIImage *image1 = [UIImage imageNamed:@"someImage"];
UIImage *image2 = [UIImage imageWithCGImage:image1.CGImage];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top