在iPhone中裁剪图像
我喜欢在UIImageView中裁剪图像。你能提供对我有帮助的完整源代码吗。它可能对你有帮助在iPhone中裁剪图像,iphone,crop,Iphone,Crop,我喜欢在UIImageView中裁剪图像。你能提供对我有帮助的完整源代码吗。它可能对你有帮助 UIImage* whole = [UIImage imageNamed:@"whole.jpg"]; //I know this image is 300x300 CGImageRef cgImg = CGImageCreateWithImageInRect(whole.CGImage, CGRectMake(x, y, 100, 100)); UIImage* part = [UIIma
UIImage* whole = [UIImage imageNamed:@"whole.jpg"]; //I know this image is 300x300
CGImageRef cgImg = CGImageCreateWithImageInRect(whole.CGImage, CGRectMake(x, y, 100, 100));
UIImage* part = [UIImage imageWithCGImage:cgImg];
UIImageView* Croppedimage = [[UIImageView alloc] initWithImage:part];
下面是更有用的链接
祝你好运,它可能会帮助你
UIImage* whole = [UIImage imageNamed:@"whole.jpg"]; //I know this image is 300x300
CGImageRef cgImg = CGImageCreateWithImageInRect(whole.CGImage, CGRectMake(x, y, 100, 100));
UIImage* part = [UIImage imageWithCGImage:cgImg];
UIImageView* Croppedimage = [[UIImageView alloc] initWithImage:part];
下面是更有用的链接
祝你好运我曾经在同一个UIImageview中裁剪过图像 1) 将图像存储在ImageView中 2) 获取相同的uiimageview并将其存储为Uiimage 3) 裁剪图像并将其还原 下面的代码将有所帮助 -(iAction)setCropItem:(id)发送方 {
}我曾经在同一个UIImageview中裁剪图像 1) 将图像存储在ImageView中 2) 获取相同的uiimageview并将其存储为Uiimage 3) 裁剪图像并将其还原 下面的代码将有所帮助 -(iAction)setCropItem:(id)发送方 {
}如果需要UI控件来裁剪图像,请尝试。它是一个自定义视图控制器,提供了一个简单、可配置且易于使用的UI,用于在iPhone应用程序中裁剪和缩放照片
这是和。如果您需要一个UI控件来裁剪图像,请尝试。它是一个自定义视图控制器,提供了一个简单、可配置且易于使用的UI,用于在iPhone应用程序中裁剪和缩放照片 这是和的 } } } 在这里,您可以在imageView中进行裁剪,裁剪后的图像将显示在ImageViewNew中 } } }
这里你可以在imageView中裁剪,裁剪后的图像将显示在ImageViewNew中谢谢你的建议最后我在上周六找到了答案。这与上面的代码相同,我使用CGImageCreateWithImageInRect()裁剪图像,但我以前将uiimageview存储为uiimage,然后在同一uiimageview中裁剪图像感谢您的建议,最后我在上周六找到了答案。这与上面的代码相同,我使用CGImageCreateWithImageInRect()裁剪图像,但我将uiimageview存储为uiimage,然后在同一uiimageview中裁剪图像
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event{
// get touch event
UITouch *touch = [[event allTouches] anyObject];
StartPoint = [touch locationInView:touch.view];
if (Img_Screen!=nil) {
[Img_Screen removeFromSuperview];
Img_Screen=nil;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
// get touch event
UITouch *touch = [[event allTouches] anyObject];
EndPoint = [touch locationInView:touch.view];
[self finishedTouchInside];
-(void)finishedTouchInside{
CGFloat width=EndPoint.x-StartPoint.x;
CGFloat hieght=EndPoint.y-StartPoint.y;
CGRect myImageRect = CGRectMake(StartPoint.x, StartPoint.y, width, hieght);
Img_Screen= [[UIImageView alloc] initWithFrame:myImageRect];
CGImageRef imageRef = CGImageCreateWithImageInRect([imgView.image CGImage], myImageRect);
// or use the UIImage wherever you like
[Img_Screen setImage:[UIImage imageWithCGImage:imageRef]];
CGImageRelease(imageRef);
[self.view addSubview:Img_Screen];
imageViewNew.image=[UIImage imageWithCGImage:imageRef];