Page 1 of 1

How to detect image pixel format

Posted: 2014-03-17T01:17:55-07:00
by Plutonium
Hi all,

I am trying to use Magick++ with OpenGL textures, right now I am using

Code: Select all

 glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* data)
function call with to past image data to the OpenGL texture. It would work just fine if I know what kind of image I am using and pass those in the 7th and 8th parameters in this function.

I have been looking for a way to determine the pixel format(for the 7th parameter GL_RGB or GL_RGBA etc. and for the 8th parameter GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT or GL_UNSIGNED_SHORT_5_6_5 for RGB565 etc. ) , however, I was not able to find a solution, I know there is a depth() function and channelDepth() function in Image class, but is that how I should determine those image properties? What should I do if I use a graylevel image?