Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-26-2008, 07:45 PM   #1 (permalink)
Registered Member
 
tkilmer's Avatar
 
Join Date: May 2008
Posts: 583
tkilmer is an unknown quantity at this point
Default UIImageView and photo library

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.

Thanks
Tkilmer
tkilmer is offline   Reply With Quote
Old 06-27-2008, 03:50 PM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Location: Onomatopoeia, Lugubriousylvania
Posts: 225
bonehead is an unknown quantity at this point
Default Re: UIImageView and photo library

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.
bonehead is offline   Reply With Quote
Old 06-28-2008, 10:45 AM   #3 (permalink)
Registered Member
 
tkilmer's Avatar
 
Join Date: May 2008
Posts: 583
tkilmer is an unknown quantity at this point
Default Re: UIImageView and photo library

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.
Code:
UIImageView *background = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
background.image = someimagecollectedfromphotoalbum
[background addSubView:anotherImageFromPhotoAlbum];
[background addSubView:anotherImageFromPhotoAlbum];
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?

Thanks
Tkilmer
tkilmer is offline   Reply With Quote
Old 06-28-2008, 11:17 AM   #4 (permalink)
New Member
 
Join Date: Apr 2008
Location: Onomatopoeia, Lugubriousylvania
Posts: 225
bonehead is an unknown quantity at this point
Default Re: UIImageView and photo library

Quote:
Originally Posted by tkilmer
Code:
UIImageView *background = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
background.image = someimagecollectedfromphotoalbum
[background addSubView:anotherImageFromPhotoAlbum];
[background addSubView:anotherImageFromPhotoAlbum];
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.

Take a look at the docs for:

CGBitmapContextCreate
CGContextDrawImage
CGBitmapContextCreateImage

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.
bonehead is offline   Reply With Quote
Old 06-28-2008, 11:45 AM   #5 (permalink)
Registered Member
 
tkilmer's Avatar
 
Join Date: May 2008
Posts: 583
tkilmer is an unknown quantity at this point
Default Re: UIImageView and photo library

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.
tkilmer is offline   Reply With Quote
Old 06-28-2008, 12:11 PM   #6 (permalink)
New Member
 
Join Date: Apr 2008
Location: Onomatopoeia, Lugubriousylvania
Posts: 225
bonehead is an unknown quantity at this point
Default Re: UIImageView and photo library

Quote:
Originally Posted by tkilmer
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:

+ (UIImage *)imageWithCGImageCGImageRef)cgImage
bonehead is offline   Reply With Quote
Old 06-28-2008, 12:14 PM   #7 (permalink)
Registered Member
 
tkilmer's Avatar
 
Join Date: May 2008
Posts: 583
tkilmer is an unknown quantity at this point
Default Re: UIImageView and photo library

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?

Thanks
tkilmer is offline   Reply With Quote
Old 04-24-2009, 04:48 AM   #8 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 6
iphonejudy is on a distinguished road
Default

Hi i need to know how u convert all images to a single imageview.Can i?
iphonejudy is offline   Reply With Quote
Old 11-08-2009, 01:30 PM   #9 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 13
robart is on a distinguished road
Default multiple images?

Quote:
Originally Posted by bonehead View Post
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!
robart is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Photo Library Image IDs javid.alimohideen iPhone SDK Development 3 07-30-2009 07:04 AM
TouchXML Library Use uprise78 iPhone SDK Development 10 05-20-2009 09:06 AM
Scale & Rotate Gestures - UIImageView col iPhone SDK Development 1 07-14-2008 07:33 AM
Want to add a Photo button shebinc iPhone SDK Development 1 05-18-2008 11:59 AM
UIImageView Help Nitrex88 iPhone SDK Development 3 04-23-2008 11:50 PM


» Advertisements
» Online Users: 335
5 members and 330 guests
blueorb, guusleijsten, Kryckter, LEARN2MAKE, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:50 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0