cocoa - How to get transparent image from OpenGL ES context on iPhone -


I have a problem with the OpenGL ES on iPhone.

I am working on a project, it draws something on the scene, and then saves the image. It also has a background image. I saw the image and added it to the background image.

I did not set the opaque property of the scene, but the image still comes from opaque view. So I could not combine both images together. I could only see the front image, the background image was not found anywhere.

  CAAgeLLair * EAGL-Layer = (CAAgeLLair *) self Layers; EAGLLayer.opaque = No;  

Get the image code like this:

  - (UIImage *) GetImage {CGFloat Width = self.frame.size.width; CGFloat height = self.frame.size.height; GLUBEET * TMPFire = (GLUBEET) * Molec (width * height * 4); GlReadPixels (0, 0, width, height, GL_RGBA, GL_ UNSIGNED_BYTE, TMPBuffer); GLubyte * Buffer = (GLUBE *) Molec (width * height * 4); {Buffer ((Ansaitijir) height - 1 - y) * (Ansaiattegr) width * 4 + for (Int y = 0; Y & lt; height; y ++) to {(Int x = 0; x and LT ; Width * 4; x ++) X] = TmpBuffer [y * 4 * (NSInteger) width + x]; }} CGTTepproProForFeedor = CGDAPproductCrateDataata (faucet, buffer, width * height * 4, zero); Int BitsPerComponent = 8; Int BitsPePell = 32; Int Bitespiro = 4 * 480; CGColorSpaceRef ColorSpaceRef = CGColorSpaceCreateDeviceRGB (); CGBitmapInfo bitmapinfo = KCGTMAPBET order default; CGColorRenderingIntent RenderingIntent = kCGRenderingIntentDefault; // Cigimage to CGImageRef ImageRef CGImageCreate = (480, 320, Bitskanpanent, Bitspeprsel, Baitperro, Rngspeshrf, Bitmapinfo, provider, no, no, Pratipadnpratima); Return [UIImage imageWithCGImage: ImageRef]; }  

or a mixture of such codes:

  - (minus) combine: (UIImage *) Back {UIGraphicsBeginImageContext (self.frame.size) ; CGContextRef aContext = UIGraphicsGetCurrentContext (); CGContextSaveGState (aContext); CGContextScaleCTM (aContext, 1.0, -1.0); CGContextTranslateCTM (aContext, 0, -self.frame.size.height); UIImage * front = [self-geared]; CGContextDrawImage (aContext, CGRectMake (0, 0, self.frame.size.width, self.frame.size.height), back. CGImage); CGContextDrawImage (aContext, CGRectMake (0, 0, self.frame.size.wightth, self.frame.size.height), front. CGImage); CGContextRestoreGState (aContext); UIImageWriteToSavedPhotosAlbum (UIGraphicsGetImageFromCurrentImageContext (), zero, zero, zero); UIGraphicsEndImageContext (); }  

What should I do? Any suggestions will be a delight. thank you in advanced.

I did it exactly.

I used the following CAEAGLLayer property:

  eaglLayer.opaque = NO; EaglLayer.drawableProperties = [Ansdisi dictionary with object Andkejh [Ansanmber number Vithbuls: Yes], Keaajielelablproprti Ritinebaking, Keaajielelaforatarjibia 8, Keaajielelablproprti Colrfarmet, Nile]; Instead of using  

and your - (UIImage *) GetImage method:

  CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast;  

If you Compile: The method can be adjusted to save two UIImage combined images:

  UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext ();  

Hope this helps :)


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -