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

  • SEARCH
  • Home
  • 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 6923875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:35:31+00:00 2026-05-27T10:35:31+00:00

I’m having a strange issue with image captures from OpenGL on iOS. I have

  • 0

I’m having a strange issue with image captures from OpenGL on iOS. I have used Apple’s GLPaint sample code to create a view that allows a user to annotate an image. The resulting painting views are then added to various UITableViewCells as part of user input forms. On completion of the form, the user’s annotation is captured to a UIImage with the following sampling code (within my PaintingView).

- (UIImage*)getImage {

    // calculate buffer size
    NSInteger dataLength = backingWidth * backingHeight * 4;
    void *buffer = (GLubyte*)malloc(dataLength);
    GLubyte *data = (GLubyte*)malloc(dataLength * sizeof(GLubyte));

    // transfer image from frame buffer
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
    glPixelStorei(GL_PACK_ALIGNMENT, 4);
    glReadPixels(0, 0, backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);

    // capture image
    CGDataProviderRef ref = CGDataProviderCreateWithData(NULL, data, dataLength, NULL);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGImageRef imageRef = CGImageCreate(backingWidth, backingHeight, 8, 32, backingWidth * 4, colorSpace, kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast, ref, NULL, true, kCGRenderingIntentDefault);
    UIImage *image = [UIImage imageWithCGImage:imageRef scale:1.0f orientation:UIImageOrientationDownMirrored];

    // clean up
    CGImageRelease(imageRef);
    CGColorSpaceRelease(colorSpace);
    CGDataProviderRelease(ref);
    free(buffer);
    free(data);

    // capture image
    if( image == nil)
        NSLog(@"Save EAGLImage failed to bind data to a UIImage");

    return image;
}

Within my application, a user can switch between two forms that both contain a single PaintingView used for annotation. If a user submits the initial form, or switches to the secondary form, image capture works just fine. If a user submits the initial form then switches to the secondary from, however, artifacts from the original annotation appear on the second form.

Here, a user annotates and submits the initial form.
Initial Form Submission

Here, as soon as a user starts annotating the secondary form, artifacts from the initial form appear.
Secondary Form After Editing

The issue seems to be related to the sampling code since it only appears after sampling (I can switch between forms and annotate each without problem as long as I don’t sample first). Any ideas what’s going on here?

  • 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-27T10:35:32+00:00Added an answer on May 27, 2026 at 10:35 am

    I’m not sure exactly what the issue was here (it appears that the buffer memory was being corrupted, but I couldn’t locate where address spaces might be overlapping).

    The original Apple code was using layoutSubviews to dynamically resize the painting surface should the layout change–and was deleting and recreating the frame buffers on every call. Because I placed the painting view in a table view cell, layoutSubviews was called several times during scrolling causing the buffers to be created and deleted multiple times needlessly. It seems that somewhere through these multiple calls the buffer address space was begin corrupted.

    After moving buffer allocation to my initialization routine, so that it’s only performed once, everything works fine.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

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.