I am working on refactoring some code in a project that requires me to read a PNG image and draw it into an X11 window. I have been able successfully read the image file using libpng, but I am not able to figure out how to convert these raw bytes into a Pixmap, so that the rest of the code can use the Pixmap.
The png image is RGB888 format, I tried using XCreatePixmapFromBitmapData as follows
Pixmap theLogo = XCreatePixmapFromBitmapData(
display,
rootWindow,
reinterpret_cast<char*>(png_image_data) ,
png_width,
png_height,
BlackPixel,
WhitePixel,
DefaultDepth(display, screen)
);
The resultant Pixmap seems to be a garbage image. It is probably because the screen depth is 16 and my png image is 24bit RGB.
Could anyone please suggest what is the best way to create a Pixmap out of raw bytes of an image.
Thanks, Abhinay