Monday, December 16, 2013

iphone pictures cut

There are a parent uiview, in uiview inside a imageview, and a sub uiview, imageview used to initialize the picture, a uiview in imageview above cut, there are some touche event to make the uiview in imageview range, and set the minimum , the maximum value for the whole range of imageview, and realize the rotation angle shear effect. If the rotation, how to keep uiview range on imageview ~ only interception on uiview picture, regardless of whether the rotation angle ~, I was seeking ideas for beginners ~ ~
Reply:
Recently a post made a similar, no additional rotation ⋯ ⋯
Useful on looking through
Reply:
Can not find the words to tell my mailbox
Reply:
ljp8817@gmail.com
Reply:
Lest someone say I'm not authentic, affixed core code
 
- (Void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event
{
UITouch * touch = [touches anyObject];

CGPoint currentPoint = [touch locationInView: self];
CGRect rect = CGRectMake (currentPoint.x +3, currentPoint.y +3, v.bounds.size.width, v.bounds.size.height);
v.frame = rect;
v.image = [self createRectImage: pubImg rect: rect];
[V setNeedsDisplay];


}


- (UIImage *) createRectImage: (UIImage *) image rect: (CGRect) rect
{
/ / The size of CGContextRef

CGImageRef imageRef = CGImageCreateWithImageInRect ([image CGImage], rect);
UIImage * elementImage = [UIImage imageWithCGImage: imageRef];
return elementImage;
}


Reply:
Yesterday, I do a good job, you can cut the picture, but the rotation, then allowed to cut the picture ~ ~
seeking expert answers
For image processing (to get a picture of the part) may be one with the following code:

UIImage * image = [UIImage imageNamed: filename];

CGImageRef imageRef = image.CGImage;

CGRect rect = CGRectMake (origin.x, origin.y, size.width, size.height);

CGImageRef imageRefRect = CGImageCreateWithImageInRect (imageRef, rect);

UIImage * imageRect = [[UIImage alloc] initWithCGImage: imageRefRect];


The current view as to save photos to the album:



# Import

UIGraphicsBeginImageContext (currentView.bounds.size); / / currentView current view

[CurrentView.layer renderInContext: UIGraphicsGetCurrentContext ()];

UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext ();

UIGraphicsEndImageContext ();

UIImageWriteToSavedPhotosAlbum (viewImage, nil, nil, nil);


So UIimageView image rotation:


float rotateAngle = M_PI;

CGAffineTransform transform = CGAffineTransformMakeRotation (rotateAngle);

imageView.transform = transform;

Reply:
There is no way to make a uiview uiimageview and an overlap region for processing. . . .
Reply:
The reply was deleted at the moderator 2011-12-21 09:44:08

No comments:

Post a Comment