0

I've cropped my image using the code below.

- (UIImage *)crop:(CGRect)rect image:(UIImage *)image {
  if (image.scale > 1.0f) {
    rect = CGRectMake(rect.origin.x * image.scale,
                      rect.origin.y * image.scale,
                      rect.size.width * image.scale,
                      rect.size.height * image.scale);
  }

  CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, rect);
  UIImage *result = [UIImage imageWithCGImage:imageRef scale:image.scale orientation:image.imageOrientation];
  CGImageRelease(imageRef);
  return result;
}

- (void)function
{
  CGRect nf = CGRectMake(0, 0, 325, 303); //The area I need to crop

  imageView.image = [self crop:nf image:imageView.image];
  // Here I need to resize the new image
}

Now, I need to resize this picture that I cropped. I tried :

  • Changing the frame -> no effect
  • Scaling image with 'CGAffineTransformMakeScale' -> no effect

I need your help please.

EDIT : I tried to change frame like this :

imageView.frame = CGRectMake(x, y, width, height);

Aeradriel
  • 1,224
  • 14
  • 36
  • Can you post the code of what you've tried?? – AlgoCoder Mar 19 '14 at 10:50
  • possible duplicate of [The simplest way to resize an UIImage?](http://stackoverflow.com/questions/2658738/the-simplest-way-to-resize-an-uiimage) – Wain Mar 19 '14 at 10:51

2 Answers2

0

Try this

 [image drawInRect:CGRectMake(0, 0,width,height)];

Post some code of What you've tried

Refer this Answer The simplest way to resize an UIImage?

Community
  • 1
  • 1
AlgoCoder
  • 1,706
  • 5
  • 19
  • 40
0

I guess I wasn't using CGAffineTransformMakeScale correctly because I finally reach it writing

imageView.transform = CGAffineTransformMakeScale(0.x, 0.x);
Aeradriel
  • 1,224
  • 14
  • 36