Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6004519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:16:28+00:00 2026-05-23T01:16:28+00:00

When I try to use this method to convert a OpenGL view to UIImage,

  • 0

When I try to use this method to convert a OpenGL view to UIImage, only the view’s background is returned, but not the GLView content. How can I convert OpenGL’s context into a UIImage?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:16:29+00:00Added an answer on May 23, 2026 at 1:16 am

    Use the below code to convert your opengl view in UIImage .

    GLubyte *buffer = (GLubyte *) malloc(backingWidth * backingHeight * 4);
     GLubyte *buffer2 = (GLubyte *) malloc(backingWidth * backingHeight * 4);
     GLvoid *pixel_data = nil;
     glReadPixels(0, 0, backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE,
             (GLvoid *)buffer);
    for (int y=0; y<backingHeight; y++) {
         for (int x=0; x<backingWidth*4; x++) {
             buffer2[y * 4 * backingWidth + x] =
         buffer[(backingHeight - y - 1) * backingWidth * 4 + x];
         }
     }
     CGDataProviderRef provider;
     provider = CGDataProviderCreateWithData(NULL, buffer2,
                                              backingWidth * backingHeight * 4,
                                              freeImageData);
     // set up for CGImage creation
     int bitsPerComponent = 8;
     int bitsPerPixel = 32;
     int bytesPerRow = 4 * backingWidth;
     CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
     CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
     // Use this to retain alpha
     //CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast;
     CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
     CGImageRef imageRef = CGImageCreate(backingWidth, backingHeight,
                                     bitsPerComponent, bitsPerPixel,
                                     bytesPerRow, colorSpaceRef,
                                     bitmapInfo, provider,
                                     NULL, NO,
                                     renderingIntent);
     // this contains our final image.
     UIImage *newUIImage = [UIImage imageWithCGImage:imageRef];
    

    Taken from

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now we just use something like this stopWatch.Start(); try { method(); } finally
I try to use this code for toggling text on the link: var showText=<span>Open</span>
I try to use this mapping : @Entity @Table(name=ecc.\RATE\) @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name=DISCRIMINATOR, discriminatorType= DiscriminatorType.STRING) public
I get this error when I try to use time_ago_in_words : Comparison of String
This article on MSDN states that you can use as many try catch blocks
I try to use doctest from example from http://docs.python.org/library/doctest.html But when I run python
I use an extension method to convert float arrays into byte arrays: public static
Related to this question: Use with XMLVM to convert android app to iphone app
Have you ever tried to use the Convert.ChangeType() method to convert a value to
I try to use the domainpeople.com API and to do I need to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.