0

In my application , I need to do brightness related operation on the image. I done with following things

  1. Getting image from photo library.
  2. Drawing that image using the Open GL.
  3. Changing the brightness of the image.

    -(void) DoBrightness:(float) aBrightness
    {
    [EAGLContext setCurrentContext:context];
    
        // Clear the buffer
    
        glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
        glClearColor(0.0, 0.0, 0.0, 0.0);
        glActiveTexture(GL_TEXTURE0);
        glVertexPointer(2, GL_FLOAT, 0, spriteVertices);
        glEnableClientState(GL_VERTEX_ARRAY);
        glTexCoordPointer(2, GL_SHORT, 0, spriteTexcoords);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
    
        if (aBrightness >= 1.0f) {
            glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD);
            glColor4f(aBrightness-1, aBrightness-1, aBrightness-1, aBrightness-1);
        } else {
            glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_SUBTRACT);
            glColor4f(1-aBrightness, 1-aBrightness, 1-aBrightness, 1-aBrightness);
        }
        glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
        glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR);
        glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
        glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE);
    
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    
        // Display the buffer
        glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
        [context presentRenderbuffer:GL_RENDERBUFFER_OES];
    }
    

Problem comes when I try to save image with brightness. Actually it is saving previous image i.e image w/o brightness

can any one help me , how to save image using rendered buffer?

thanks,

Sagar

genpfault
  • 51,148
  • 11
  • 85
  • 139
Sagar...
  • 1,062
  • 3
  • 15
  • 35

1 Answers1

0

You're only doing the work on the screen, so to speak. You're not actually reading the screen and saving that data to file. Basically you need to use glReadPixels to get the data from the screen buffer and then save that buffer as your modified image. There's more details in the following:

How do I grab an image from my EAGLLayer ?

Community
  • 1
  • 1
No one in particular
  • 2,682
  • 2
  • 17
  • 20
  • Thanks, it saved the rendered content. Actually I m newbie for OpenGL so going slowly. I am getting now "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES" error. – Sagar... Sep 10 '10 at 07:33