Save image with my own custom image in ios - ios

I want to save an image to camera roll with my own imagename in ios 5.I am using AV Foundation for accessing camera features.Please help me with possible solutions.

// Image to save
UIImage *img = [UIImage imageNamed:#"ImageName.png"];
// Request to save the image to camera roll
UIImageWriteToSavedPhotosAlbum(img, self,
#selector(image:didFinishSavingWithError:contextInfo:), nil);
Hope this helps..

Related

Implicit declaration of function 'UIImageWriteToSavedPhotosAlbum' is invalid in C99

I want save image to camera roll in apple Watch
this is my code:
UIImage *image = [UIImage imageNamed:#"w0-1.jpg"];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
can you help me please??
You cannot save image to saved photo album. You can only save image to your application folder.

iOS always add white background to images

I am writing an app process image. But when I change alpha of an image to 0, it mean that this image will be transparent. And then I save this image to photo library.
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
But when I open this image again, i see that it has white background.
Does anybody know why?
Did you saved as jpeg?
try this:
NSData* pngdata = UIImagePNGRepresentation (image);
UIImage* img = [UIImage imageWithData:pngdata];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);

Keep transparency in screenshot iOS

I am taking screenshot of a particular View in my Xib file with the following code...
UIView* captureView = self.view;
UIGraphicsBeginImageContextWithOptions(captureView.bounds.size, NO , 0.0f);
[captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
It works fine and saves JPG image to camera roll.
But problem is, There is another UIImageView on the top of my View, that UIImageView has a semi-transparent image in it.
My screenshot doesn't preserve that transparency in the screenshot it is taking.
I want to keep the transparency as it is in the actual screen.
How can you preserve the transparency in the screenshot?
If you specify "No" for the opaque property, your image must include an alpha channel for this to work. Check that your image has an alpha channel.
JPGs don't have transparency so as soon as you convert it to JPG alpha is gone.
This is a known limitation of UIImageWriteToSavedPhotosAlbum
it doesn't keep png.
try this. this code working for me
UIGraphicsBeginImageContext(baseViewOne.frame.size);
[[baseViewOne layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage * screenshota = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
also check cocoa coder screen shots
NSData* imdata = UIImagePNGRepresentation(_snapshotImgView.image);
UIImage* snapshotPNG = [UIImage imageWithData:imdata];
UIImageWriteToSavedPhotosAlbum(snapshotPNG, self, #selector(image:didFinishSavingWithError:contextInfo:), nil);

Image save in dynamic create folder in gallery

Here i m trying to save image in gallery. i done this but now i want to save captured image in date wise folder in gallery.
- (IBAction)saveImage:(id)sender {
UIGraphicsBeginImageContextWithOptions(drawingSlate.bounds.size, drawingSlate.opaque, 0.0);
[drawingSlate.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
}
here the image is save in photos, but i want to save with proper name and datewise folder.
Thanks

Can you save PNG's to the photo library in iOS5?

I've noticed that line drawings from the drawing app I'm making are very low quality when saved using this code:
UIImage *imageToSave = drawImage.image;
UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil);
As far as I can understand, you can't set the JPG quality when using UIImageWriteToSavedPhotosAlbum.
Is there a way to save the UIImage as a PNG to the photo library directly, or some way to increase the JPG quality? When doing a screenshot (pressing on/off+home on the iPad) the quality of the grabbed picture is perfect, but I can't expect people to save images that way.
Any help greatly appreciated!
Try this
NSData* pngdata = UIImagePNGRepresentation (drawImage.image); //PNG wrap
UIImage* img = [UIImage imageWithData:pngdata];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);

Resources