Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I must be too late to answer this question, but I have got a better way to get this job done.</p> <pre><code>static inline double radians (double degrees) {return degrees * M_PI/180;} +(UIImage*)editedImageFromMediaWithInfo:(NSDictionary*)info{ if(![info objectForKey:UIImagePickerControllerCropRect])return nil; if(![info objectForKey:UIImagePickerControllerOriginalImage])return nil; UIImage *originalImage=[info objectForKey:UIImagePickerControllerOriginalImage]; CGRect rect=[[info objectForKey:UIImagePickerControllerCropRect] CGRectValue]; CGImageRef imageRef = CGImageCreateWithImageInRect([originalImage CGImage], rect); CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef); CGContextRef bitmap = CGBitmapContextCreate(NULL, rect.size.width, rect.size.height, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo); if (originalImage.imageOrientation == UIImageOrientationLeft) { CGContextRotateCTM (bitmap, radians(90)); CGContextTranslateCTM (bitmap, 0, -rect.size.height); } else if (originalImage.imageOrientation == UIImageOrientationRight) { CGContextRotateCTM (bitmap, radians(-90)); CGContextTranslateCTM (bitmap, -rect.size.width, 0); } else if (originalImage.imageOrientation == UIImageOrientationUp) { // NOTHING } else if (originalImage.imageOrientation == UIImageOrientationDown) { CGContextTranslateCTM (bitmap, rect.size.width, rect.size.height); CGContextRotateCTM (bitmap, radians(-180.)); } CGContextDrawImage(bitmap, CGRectMake(0, 0, rect.size.width, rect.size.height), imageRef); CGImageRef ref = CGBitmapContextCreateImage(bitmap); UIImage *resultImage=[UIImage imageWithCGImage:ref]; CGImageRelease(imageRef); CGContextRelease(bitmap); CGImageRelease(ref); return resultImage; } </code></pre> <p>It only crops the original image with the relative CropRect, although this method dosen't scale the image, but it is short and sweet for me. Just for reference :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload