0

I'm try to scale an image in UIImageView i try to call this below code getting an error Memory leak. please any one help me.

 UIImage *imagess;
 CGFloat scale = [self.slider value];
 CIImage *ciimage  = [CIImage imageWithCGImage:image.CGImage];
 CGAffineTransform t = CGAffineTransformIdentity;
 t = CGAffineTransformConcat(t, CGAffineTransformMakeScale(scale, scale));


    @autoreleasepool {
        CIImage *timage = [ciimage imageByApplyingTransform:t];

        CIContext *context = [CIContext contextWithOptions:nil];
        CGImageRef imageRef = [context createCGImage:timage fromRect:[timage extent]];
        imagess = [UIImage imageWithCGImage:imageRef];
        self.ImageView.image = imagess;

        CFRelease(imageRef);
    }
Thobio
  • 57
  • 2
  • 7
  • Passing through CIImage is not how to scale. – matt Mar 25 '20 at 10:47
  • @matt then can you help me with that – Thobio Mar 25 '20 at 11:00
  • It depends where the image is coming from. You can https://developer.apple.com/documentation/uikit/uiimage/1624092-draw to redraw the image at smaller size. But if the image is on disk you should use the ImageIO framework to load a thumbnail directly. – matt Mar 25 '20 at 11:17
  • @matt the image is coming from UIImagePickerController camera – Thobio Mar 25 '20 at 11:20
  • So use the first way. Example: https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch02p063imageDownscaling/imageScaling/ViewController.swift – matt Mar 25 '20 at 11:28
  • Please don’t add irrelevant links. Zoom level of camera is unrelated to what you are asking here. – matt Mar 25 '20 at 11:29

0 Answers0