Slow performance on ipad erasing image

71 views Asked by At

I have an iOS app that lets me erase an image with touch. It runs fine on iphone, but it lags a lot on ipad air. It uses ~40MB of memory on iphone, but ~200MB on ipad. Any ideas?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    lastTouch = [touch locationInView:self.backImageView];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    currentTouch = [touch locationInView:self.backImageView];


    CGPoint eraserPoint = CGPointMake(currentTouch.x - self.eraser.size.width/2, currentTouch.y - self.eraser.size.height/2);
    self.backImageView.image = [self eraseImageAtPoint:eraserPoint inImageView:self.backImageView fromEraser:self.eraser];


}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

}


- (UIImage *)eraseImageAtPoint: (CGPoint)point inImageView: (UIImageView *)imgView fromEraser: (UIImage *)eraser {

    UIGraphicsBeginImageContextWithOptions(imgView.frame.size, NO, 0.0f );
    [imgView.image drawInRect:CGRectMake(0, 0, imgView.frame.size.width, imgView.frame.size.height)];
    [eraser drawAtPoint:point blendMode:kCGBlendModeDestinationOut alpha:self.eraserSpeedSlider.value];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;
}
0

There are 0 answers