How to get UIImage from EAGLView?

后端 未结 6 471
悲&欢浪女
悲&欢浪女 2020-11-28 09:09

I am trying to get a UIImage from what is displayed in my EAGLView. Any suggestions on how to do this?

6条回答
  •  有刺的猬
    2020-11-28 09:30

    With this above code of Brad Larson, you have to edit your EAGLView.m

    - (id)initWithCoder:(NSCoder*)coder{
        self = [super initWithCoder:coder];
        if (self) {
            CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
            eaglLayer.opaque = TRUE;
            eaglLayer.drawableProperties = 
                [NSDictionary dictionaryWithObjectsAndKeys: 
                    [NSNumber numberWithBool:YES],  kEAGLDrawablePropertyRetainedBacking, 
                    kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
        }
        return self;
    }
    

    You have to change numberWithBool value YES

提交回复
热议问题