views:

79

answers:

1

Hello All,

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

A: 

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:

http://stackoverflow.com/questions/314254/how-do-i-grab-an-image-form-my-eagllayer

No one in particular
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 Mane