2012-05-30 62 views
3

我编写代码来裁剪图像,但我得到图像的其他部分,而不是在给定的矩形。图像裁剪给图像的错误部分

CGImageRef cr = CGImageCreateWithImageInRect([imageCrop.image CGImage], rectangle.frame); 
    imageCrop.frame=rectangle.frame; 
    imageCrop.image = [[[UIImage alloc] initWithCGImage:cr] autorelease]; 
    CGImageRelease(cr); 

回答

0

如果您收到这可能是因为你提供UIImageimageOrientation属性值的图像的另一部分。在裁剪之前考虑图像的方向。

图像方向会影响绘制时图像数据的显示方式。默认情况下,图像以“向上”的方向显示。但是,如果图像具有关联的元数据(如EXIF信息),则此属性包含该元数据指示的方向。对于此属性的可能值的列表,请参阅UIImageOrientation

+0

应该是什么形象定位? –

+0

@IdreesAshraf我用更多的信息更新了我的答案 – voromax

0
// Try using following line of code- 

    CGImageRef cr = CGImageCreateWithImageInRect([imageCrop.image CGImage], rectangle.frame); 
    imageCrop.image =[UIImage imageWithCGImage:croppedCGImage scale:1.0f orientation:self.imageOrientation]; 
    CGImageRelease(cr); 
+0

再次弄错了部分 –