I now know how to add an image to the photo library; however, I still do not know how to convert all that is inside a UIImageView into an image. My program added multiple images into a single UIImageView. How do I take all the images inside the view and make a single UIImage to pass on to the UIImageWriteToSavedPhotosAlbum method. It has to be a UIImage and just performing UIImageView.image does not get me all the images.
I'm not sure I understand you. Are you adding multiple images to the UIImageView's animationImages property? I don't see how else to add multiple images to a single UIImageView (it has a single-image "image" property).
If you're using animationImages, you could walk the array of images and add them one at a time to the photo album.
Perhaps if you could post the relevant snippet of your code, we could help you further.
It is more of a photo collage program. I created a main UIImageView and I allowed the user to add more photos. When they select a new photo to add I add it to the UIImageView. Here is kind of how I do it.
When I end up saving the image, it is only the image that was initialized as the background. The other images in the collage are not added. Is there a way to take a screenshot and then use that UIImage and save it to the photo album?
When I end up saving the image, it is only the image that was initialized as the background. The other images in the collage are not added. Is there a way to take a screenshot and then use that UIImage and save it to the photo album?
Interesting...so you're using the view hierarchy to display multiple images as subviews of the background image. What you need to do is then "flatten" the hierarchy into a single image.
Basically you could create a blank CGContext to draw into, then use CGContextDrawImage to draw your images (in the proper Z-order, in the proper positions specified by the user) into that context. Then you'll have a CGBitmapContext that you can convert back to an CGImage, and then save the image as you were before.
Sounds like a fun application for a touchscreen device. Good luck, and I'd like to beta test it.
I am taking a look at the documents for those three items. To save the image in the photo gallery, it has to be a UIImage. It returns an image, but not a CGImage. Also, is there any sample or do you have any sample code that I can look at, to get an idea on how to implement it. I am having trouble putting it all together.
I am taking a look at the documents for those three items. To save the image in the photo gallery, it has to be a UIImage. It returns an image, but not a CGImage. Also, is there any sample or do you have any sample code that I can look at, to get an idea on how to implement it. I am having trouble putting it all together.
As far as I know, there's no sample code that shows step-by-step how to do this.
Converting a CGImage to UIImage is straightforward:
Yeah I actually just found that as I was looking around. So, I would create a context and add the images to that then convert it to a UIImage and save it? Or, when I create the context it takes what is inside the view and makes that into a CGImage?
I'm not sure I understand you. Are you adding multiple images to the UIImageView's animationImages property? I don't see how else to add multiple images to a single UIImageView (it has a single-image "image" property).
If you're using animationImages, you could walk the array of images and add them one at a time to the photo album.
Perhaps if you could post the relevant snippet of your code, we could help you further.
Help! I am using animationImages and need to save each image to photos. I have used UIImage *image = [UIImage imageNamed:@"image0.jpg"];
UIImageWriteToSavedPHotosAlbum (image, self, @selector(image:didFinishSavingWithError:contextIn fo, nil);
This works but can only do one image and I have 25. Also when button pushed to save I get a signal warning. Any help would be so great! Thanks!