【发布时间】:2013-10-26 17:25:40
【问题描述】:
我有一个绘图应用程序,我在其中使用 openGL 绘图代码来绘制笔触,但想在笔触完成后将其传输到另一个图像,然后清除 OpenGL 视图。为此,我正在使用 CoreGraphics。然而,我遇到了一个问题,在图像通过 CG 传输之前,OpenGL 视图被清除(即使我之后清除它)
(我希望它是另一种方式,即先绘制图像然后擦除绘画图像,以避免任何闪烁)
(paintingView是openGL视图)
代码如下:
// Save the previous line drawn to the "main image"
UIImage *paintingViewImage = [[UIImage alloc] init];
paintingViewImage = [_paintingView snapshot];
UIGraphicsBeginImageContext(self.mainImage.frame.size);
[self.mainImage.image drawInRect:CGRectMake(0, 0, self.mainImage.frame.size.width, self.mainImage.frame.size.height) blendMode:kCGBlendModeNormal alpha:1.0];
// Get the image from the painting view
[paintingViewImage drawInRect:CGRectMake(0, 0, self.mainImage.frame.size.width, self.mainImage.frame.size.height) blendMode:kCGBlendModeNormal alpha:1.0];
self.mainImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.paintingView erase];
所以在 mainImage.image 变量被设置为 CurrentImage 上下文之前,paintingView 被擦除了。
我只是这些方面的初学者,所以任何想法都有帮助。
谢谢
【问题讨论】:
标签: ios opengl-es uiimageview core-graphics