deleting a UIImage saved in Photo Album - iphone

Hi i am new to IPhone development. i have saved UIIMages on the IPhone Simulator's Photo Album using the following code.
UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil , nil, nil);
As i am able to delete them manually by explicitly going to Photo library and delete them one by one.
Now i am using the imagePickerController in my app to view those saved pics.
I want to delete the image when i select the delete button in my app.
I would appreciate help with some code.

No it is not possible to do that. You can fake the photo album by creating your custom one. You have to save those photos somewhere in Documents or Library folder. Then you can do whatever you want. Here is the link to start.

Related

Capture screen remotely of iphone device. [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Programatically capture video of screen
I am building an app in which i have to capture the screen of iPhone mobile (rooted phone) remotely...
Means i have to capture screen from one iPhone to another iPhone remotely...
please suggest me...
Thanks in advance.
To programmatically capture screen snapshots, you can:
#import <QuartzCore/QuartzCore.h>
- (void)saveScreenSnapshot:(UIView *)view
{
UIGraphicsBeginImageContext(view.frame.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// do what you want with this image; I frequently just drop it in the device's photo album
//
// UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}
Alternatively, can get a PNG representation of that image via:
NSData *data = UIImagePNGRepresentation(image);
You obviously have to add the QuartzCore.framework to your target app's libraries.

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();

Merging photos - iPhone SDK

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.

How to save a png image to camera roll?

I'd like to save screenshots from my game to camera roll.
Right now I'm using UIImageWriteToSavedPhotosAlbum which saves the image in jpg format with way too much ugly jpg artifacts.
Is there a way to save an UIImage in png format to camera roll?
First you have to add AssetsLibrary Framework, than like this:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
UIImage *image = ... some image
[library writeImageDataToSavedPhotosAlbum: UIImagePNGRepresentation(image) metadata:nil completionBlock:nil];
The solution pointed out here is now deprecated - this post:
UIImageWriteToSavedPhotosAlbum saves to wrong size and quality
shows how to do this:
UIImage* im = [UIImage imageWithCGImage:myCGRef]; // make image from CGRef
NSData* imdata = UIImagePNGRepresentation ( im ); // get PNG representation
UIImage* im2 = [UIImage imageWithData:imdata]; // wrap UIImage around PNG representation
UIImageWriteToSavedPhotosAlbum(im2, nil, nil, nil); // save to photo album
Napolit "I'd like to save screenshots from my game to camera roll. Right now I'm using UIImageWriteToSavedPhotosAlbum which saves the image in jpg format with way too much...."
Have just stumbled across your question, most of which I can't answer. however, I do have an EASY & QUICK WAY to grab iPad screens. Simply press the SLEEP/WAKE button and the HOME (round button at bottom of the screen) button at the same time.
This tells how to represent a UIImage as a jpg or png: Save UIImage Object as PNG or JPEG File