Ipad 如何通过核心图形绘制图像。

Ipad 如何通过核心图形绘制图像。,ipad,core-graphics,Ipad,Core Graphics,我正在从事一个项目,其中用户执行以下任务 选择他要绘制的图像 选择图像后。用户选择一个工具(名为Duplicate)。 当用户在UIImageVIew上移动它时,选定的图像将在其上绘制 它 对于第二部分,我尝试了以下代码,但它不起作用 UIGraphicsBeginImageContext(frontImageView.frame.size); [frontImageView.image drawInRect:CGRectMake(0, 0, frontImageView.frame.size.

我正在从事一个项目,其中用户执行以下任务

  • 选择他要绘制的图像
  • 选择图像后。用户选择一个工具(名为Duplicate)。 当用户在UIImageVIew上移动它时,选定的图像将在其上绘制 它
  • 对于第二部分,我尝试了以下代码,但它不起作用

    UIGraphicsBeginImageContext(frontImageView.frame.size);
    [frontImageView.image drawInRect:CGRectMake(0, 0, frontImageView.frame.size.width, frontImageView.frame.size.height)];
    context = UIGraphicsGetCurrentContext();
    CGRect theRect = CGRectMake(touchLocation.x, touchLocation.y, eraserWidth, eraserWidth);
    CGContextAddRect(context, theRect);
    CGContextDrawImage(context, theRect, originalImage.CGImage);
    frontImageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    

    其中,
    originalImage
    conatin在所选图像中,橡皮擦宽度是工具宽度,FrontIMageVIew是将在其上绘制图像的UIImageVIEW。请检查此代码是否正确,因为我的应用程序崩溃。提前感谢。

    Rahul在应用程序崩溃时在此处添加错误?@dark。它显示程序收到的信号:“EXC\u坏访问”