Merging photos - iPhone SDK - iphone

I am making an app that adds a picture frame to a photo.
I would like to know how to have my Save button save both Images (the photo, and the frame) as one Image.
Right now it only saves one of the images.
In interface builder I have the save action saving the image that is loaded into an ImageView, with the frame ImageView overlaying that image.
I'd like to merge the two photos as one, so the save action can save the image with the frame.
Thanks!

If you've displayed the frame over the photo in your UI, just use UIScreenGetImage something like
...
CGImageRef screen = UIGetScreenImage();
UIImage* image = [UIImage imageWithCGImage:screen];
CGImageRelease(screen);
// You could, e.g., save the captured image to photo album
UIImageWriteToSavedPhotosAlbum(image, self, #selector(image:didFinishSavingWithError:contextInfo:), nil);

This probably isn't what you want, but if you load both images into OpenGL (there's a nice Apple sample that loads images in OpenGL), lay one on top of the other, and then write the result to an image (excellent tutorial here - http://www.bit-101.com/blog/?p=1861).
You don't even need to render it to the screen, so there's no fiddling around with EAGL.

Related

Capture specific CALayer (and subviews) to a video file (or data) in Real Time

I have a UIView (with its CALayer) which has a UIImageView as a sub-view.
The UIImageView is animated (imageView.animationImages).
I would like to capture the currently played animation to a video file, or video data (later to be converted to a video file), but not capture all the elements on the screen, like buttons and other UI, but just a specific UIView (not for a promo vid, but as part of the app's functionality).
I tried implementing ScreenCaptureView , but while it does let me capture a specific UIView into a video file in realtime, it won't capture the Animated UIImageView , it shows just the first frame...
I thought about using the CALayer's renderInContext: and then somehow appending the CGImage (current frame) to a video data and then making a video file from the data (or maybe appending directly to a video file).
I'm kinda stuck on the appending part... I don't really know what to do with the render data of the current frame.
Does anyone have any hints or suggestions?
Any help will be much appreciated :)
I made the a change to ScreenCaptureView.m and now it captures the UIImageView animation:
[self.layer renderInContext:context];
changed to:
[self.layer.presentationLayer renderInContext:context];
Although the performance is actually pretty bad on a device (iPhone 4)...

How to overlay one image over another image in iPhone

In my app i have one transparent image, now when user selects one image from photo library, that image have to be display over transparent image and make as an one uiiimage so that user can mail or share with it. I have used the following code, however image is not coming correct over transparent image
UIImage *backgroundImage = [UIImage imageNamed:#"iPhoneOverLay.png"];
UIGraphicsBeginImageContext(backgroundImage.size);
[backgroundImage drawInRect:CGRectMake(0, 0, backgroundImage.size.width, backgroundImage.size.height)];
[testImage drawInRect:CGRectMake(backgroundImage.size.width - testImage.size.width, backgroundImage.size.height - testImage.size.height, testImage.size.width, testImage.size.height)];
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Here testImage is selected from Photo Library or taken from camera
You draw the 2 images in the wrong order. Transparency is a property that makes things shine through that have been painted previously. Therefore you have to draw the (opaque) photo first and the (transparent) overlay second.

ios dropbox, loading thumbnail of image in table view

I have picture in my dropbox, which i need to show in Uitable view. I am able to show the picture by name, using metadata filemetadata, and when i click on any of cell i am successfully able to view the image in image view, by using the call to loadthumbnail.
But now, I want to show the thumbnail of image together with, image name, so that user have idea of image before opening it.
So, what is the simple way of doing it.
You should resize (thumb) the original UIImage's prior to showing the UITableView and save them in your app cache folder.
Something like this (out the top of my head)
CGSize targetSize = (CGSize){ 100, 80 };
UIGraphicsBeginImageContext(targetSize);
CGRect thumbnailRect = (CGRect){ 0, 0, targetSize.width, targetSize.height };
[sourceImage drawInRect:thumbnailRect];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// After this you should store the UIImage (NSData) as a file, so you could use it later on.
Try to go to the Start Menu then look for My Documents and look for a folder named Downloads. This worked for me on a download i could not see.
Good Luck!

Adding picture frame to a photo

I am making an app that adds a picture frame to a photo.I would like to know how to have my Save button save both Images (the photo, and the frame) as one Image.Right now it only saves one of the images.
In interface builder I have the save action saving the image that is loaded into an ImageView, with the frame ImageView overlaying that image.
I'd like to merge the two photos as one, so the save action can save the image with the frame.
Thanks!
In this may need to use the masking in the iphone where the unnecessary thing of the image is automatically remove and attach with the frame.
I think this help to implement best for the your applications
So you can refer the following link for Download and tutorial and Source also.
Reference link
You need to do some drawing using Core Graphics. This code should do what you want, possibly with some tweaks to the rectangles/sizes:
UIGraphicsBeginImageContext(image.size);
[image drawRect:CGRectMake(0, 0, image.size.width, image.size.height);
[frameImage drawRect:CGRectMake(0, 0, image.size.width, image.size.height);
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();

Library photos as source to UIImage

How to give images in photo library and camera as source to UIImage
/* On button click i want to save image */
myImage = /*What i have to give here to take camera or library images*/
UIImageWriteToSavedPhotosAlbum(myImage, self,
#selector(image:didFinishSavingWithError:contextInfo:), nil);
You need to use the UIImagePickerController object. It will present the modal view that allows either taking a picture or selecting an image from the device library. You should also become familiar with the UIImagePickerControllerDelegate protocol. With these two, it is easy to interact with both the camera and on-device library.