UIGraphicsGetImageFromCurrentImageContext() crashes the app on iPad 3

ⅰ亾dé卋堺 提交于 2020-01-05 17:49:10

问题


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();

来源:https://stackoverflow.com/questions/28359164/uigraphicsgetimagefromcurrentimagecontext-crashes-the-app-on-ipad-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!