Reading Pixel Data to Memory (cont)
  • The size of the data must also be specified

  •  
    void glReadPixels(GLint x, GLint y, GLsizei width, 
      GLsizei  height, GLenum format, GLenum type
      GLvoid *pixels);


     

  •  Notes:
    • Depending on the format between 1 and 4 elements are read or written (GL_RGBA + GL_INT = 16 bytes/pixel)
    • Color index values may by stored in GL_FLOAT
    • Integer values stored as floats are scaled. There is no effective gain in precision
    • Signed data values have 1-less bit of storage (upper bit is masked)
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Writing Pixel Data to the Frame Buffer
  • glRasterPosition() specifies the lower-left corner of the image data

  •  
    void glDrawPixels(GLsizei width, GLsizei height,
      GLenum format, GLenum type, const GLvoid *pixels);
     

     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Imaging Pipeline
  • Pixel data may be manipulated during pixel storage and pixel transfer operations
    • Level/gain adjustment
    • Zoom operations
     
     
  •  Data packing/unpacking occurs when reading or writing processor memory (not copying)
    • Applies to Texture Memory also
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Pixel Storage Modes
  • For efficiency pixel data can be packed into memory
  • An image has between 1 and 4 elements which may be encoded into memory
    • Stored as bytes/integers/floats
  • glPixelStore() controls the pixel storage 

  •  
    void glPixelStore{if}(GLenum pname, TYPEparam);
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Pixel Storage Modes (cont)
     
     
  • Note!  Also be aware of performance improvements by specifying GL_PACK_ALIGNMENT

  •  
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Pixel-Transfer Operations
  • As data is transferred to/from the framebuffer OpenGL can perform operations on it


  •  images from ttp://www.x20.org/thermal/LawEnforcement.htm and http://www.x20.org/nightvision/pvs7.htm
    void glPixelTransfer{if}(GLenum pname, TYPEparam);
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Pixel Mapping
  • Color values may be modified by a lookup table (LUT) with glPixelMap()

  • void glPixelMap{ui us f}v(GLenum map, GLint mapsize,
      const TYPE *values);


    Image from http://www.x20.org/thermal/pictures.htm

     
     
     

     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Magnifying, Reducing of Flipping an Image 
  • By default there is a 1-to-1 mapping of pixel data during pixel rasterization
  • glPixelZoom allows arbitrary re-sizing of pixel data 

  •  
    void glPixelZoom(GLfloat zoom x , GLfloat zoom y );
     
  •  Negative zoom values will "flip" the image

  •  
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Reading and Drawing Pixel Rectangles

     
  •  Note: 
    • All values are converted to FP for non-index pixels
    • Index values are the result for CI mode, otherwise RGBA
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Reading from Framebuffer
     
     
  •  Note:  Framebuffer is converted to FP

  •