Save image to album
Closed this issue · 5 comments
Hello, first congratulations for the project. Sorry for my English.
I tried to save the image in the album but does not save the transformed image.
UIImageWriteToSavedPhotosAlbum([self captureView:self.view], self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
- (UIImage *)captureView:(UIView *)view
{
CGRect rect = [self.view bounds];
UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
Thank you very much.
You need to use this after renderInContext
https://github.com/hfossli/AGGeometryKit/blob/master/Source/UIImage%2BCATransform3D.h
Håvard
Sendt fra mobil
Den 17. feb. 2014 kl. 21:01 skrev elpatxificador notifications@github.com:
Hello, first congratulations for the project. Sorry for my English.
I tried to save the image in the album but does not save the transformed image.
UIImageWriteToSavedPhotosAlbum([self captureView:self.view], self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
(UIImage *)captureView:(UIView *)view
{
CGRect rect = [self.view bounds];
UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();return viewImage;
}
Thank you very much.—
Reply to this email directly or view it on GitHub.
I dont understand how to use this method:
- (UIImage *)imageWithTransform:(CATransform3D)transform anchorPoint:(CGPoint)anchorPoint;
My code:
- (void)createAndApplyQuad
{
AGQuad quad = AGQuadMakeWithCGPoints(self.topLeftControl.frame.origin,
self.topRightControl.frame.origin,
self.bottomRightControl.frame.origin,
self.bottomLeftControl.frame.origin);
if(AGQuadIsValid(quad))
{
self.imageViewMaskBald.layer.quadrilateral = quad;
}
}
- (void)panGestureChanged:(UIPanGestureRecognizer *)recognizer
{
UIImageView *view = (UIImageView *)[recognizer view];
CGPoint translation = [recognizer translationInView:self.view];
view.centerX += translation.x;
view.centerY += translation.y;
[recognizer setTranslation:CGPointZero inView:self.view];
view.highlighted = recognizer.state == UIGestureRecognizerStateChanged;
[self createAndApplyQuad];
}
My image call "self.imageViewMaskBald" is inside to other view. I want to make a screenshot of my container view.
Could give an example of how to use the method.
Thank you very much.
I'll send you something this evening
I run this and work fine.
Available in iOS 7.0 and later.
- (UIImage *)snapshot:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0);
// Render our snapshot into the image context
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
// Grab the image from the context
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
// Finish using the context
UIGraphicsEndImageContext();
return viewImage;
}
Thank you very much.
Perfect! That is great to know! I didn't know that method existed!