How to detect image pixel format

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Posts: 1
Joined: 2014-03-17T01:07:33-07:00
Authentication code: 6789

How to detect image pixel format

Post 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?