이 문제로 인해 지금 당분간 어려움을 겪고 있으며 지금까지 답변을 찾을 수 없습니다. 기본적으로, 내가하고 싶은 것은 내 EAGLview의 내용을 캡처 한 다음 다른 이미지와 병합하는 것입니다. 어쨌든, 주요 문제점은 포토 앨범에 저장하거나 UIImageView에 넣을 때 내 EAGLview의 모든 것이 투명하게 렌더링된다는 것입니다.iPhone에서 알파 채널을 사용하여 EAGLview 콘텐츠를 캡처하는 경우
이- (CGImageRef) glToUIImage {
unsigned char buffer[320*480*4];
glReadPixels(0,0,320,480,GL_RGBA,GL_UNSIGNED_BYTE,&buffer);
CGDataProviderRef ref = CGDataProviderCreateWithData(NULL, &buffer, 320*480*4, NULL);
CGImageRef iref = CGImageCreate(320,480,8,32,320*4,CGColorSpaceCreateDeviceRGB(),kCGBitmapByteOrderDefault,ref,NULL,true,kCGRenderingIntentDefault);
size_t width = CGImageGetWidth(iref);
size_t height = CGImageGetHeight(iref);
size_t length = width*height*4;
uint32_t *pixels = (uint32_t *)malloc(length);
CGContextRef context = CGBitmapContextCreate(pixels, width, height, 8, width*4, CGImageGetColorSpace(iref), kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGContextTranslateCTM(context, 0.0, height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextDrawImage(context, CGRectMake(0.0, 0.0, width, height), iref);
CGImageRef outputRef = CGBitmapContextCreateImage(context);
UIImage *outputImage = [UIImage imageWithCGImage:outputRef];
UIImageWriteToSavedPhotosAlbum(outputImage, nil, nil, nil);
return outputRef;
}
이미 언급 한 바와 같이, 이것은 완벽하게 내 EAGLview의 내용을 잡고 있지만, 나는 그것의 알파 값을 사용하여 이미지를 얻을 수 없습니다 : 내가 당신과 함께 몇 가지 코드를 공유 할 수, 나는 다른 곳에서 발견 .
도움을 주시면 감사하겠습니다. 감사!
안녕하세요, 동일한 문제가 있습니다. 이것을 알아낼 수 있었습니까? 고맙습니다 – Sharief