ipad擦除图像时性能下降

时间:2015-06-08 20:26:24

标签: ios image performance eraser

我有一个iOS应用程序,可以让我用触摸擦除图像。它在iphone上运行良好,但在ipad air上却落后很多。它在iphone上使用~40MB的内存,在ipad上使用~200MB。有什么想法吗?

- (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 个答案:

没有答案