title: libpng, c code, how to convert RGB value to pixel value?
body: <p>I am using libpng for C, I am new to image processing.</p>
  
  <p>I use png_get_IHDR() to get the width, height, color_type and bit_depth, the values I got for an image are:</p>
  
  <pre><code>color_type = 6 (PNG_COLOR_TYPE_RGB_ALPHA)
  bit_depth = 8
  width = 1850
  height = 2048
  
  I use png_get_channels() to get the channels which is 4
  I use png_get_rowbytes() to get the bytes per row which is 7400 (1850*4)
  I use png_read_image() to get all the image data
  </code></pre>
  
  <p>My aim is to convert the RGB values to pixel value, that's all ! I know the R, G, B and Alpha values of each pixel are stored orderly in the image data buffer, seems the conversion methods are different for different bit_depth. Also can I ignore Alpha value, only use R, G, B values when doing the conversion? Anyone can help? Thanks! </p>