My problem is when I assign the image which was returned by the UIGraphicsGetImageFromCurrentImageContext() , to the UIImageView more than once, my app crashes. Here is my code: If omit the assignment line of UIImageView app will not crash.
UIImage * newImage3;
UIGraphicsBeginImageContext(duplicateImage.size);
[duplicateImage drawAtPoint:CGPointMake(0, 0)];
context2=UIGraphicsGetCurrentContext();
for(int k=0; k<kmtaGroup->TotalLines; k++)
{
lineObject=&kmtaGroup->Line_INFO_OBJ[k];
x0 = lineObject->x0;
y0= lineObject->y0;
x1= lineObject->x1;
y1= lineObject->y1;
color= lineObject->Color;
lineWidth= lineObject->LinkWidth;
lineColor=[self add_colorWithRGBAHexValue:color];
linearColor=lineColor;
// Brush width
CGContextSetLineWidth(context2, lineWidth);
// Line Color
CGContextSetStrokeColorWithColor(context2,[linearColor CGColor]);
CGContextMoveToPoint(context2, x0, y0);
CGContextAddLineToPoint(context2, x1, y1);
CGContextStrokePath(context2);
}
newImage3=UIGraphicsGetImageFromCurrentImageContext();
}
imageView.image=newImage3;
UIGraphicsEndImageContext();