Results 1 to 1 of 1
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Feb 2012
Loading Images/Pictures from Disk using XLIB
I am developing a project using Xlib with C++. What I am focused on doing now, after successfully implemented some basic operations, is to load a PNG image from disk into the window. I've been searching the web and I can't really find something that could explain how can i load an image from the disk into my window. I've seen how to load a .xbm file, but unfortunately, converting png to xbm loses A LOT of quality on image. The other option I've thought about, was to convert png to xpm (X Pixmap). However I don't know either how can I load a XPM from disk into my project window.
Does anyone have a clue on how to load a PNG or XPM image into the window?
I have tried using:
Pixmap pix = XCreatePixmap(display, RootWindow(display, screen), 800, 600, DefaultDepth(display, screen)); pix = XCreateBitmapFromData (display, RootWindow(display, screen), (char*)img_bits, 800, 600);
Major opcode of failed request: 62 (X_CopyArea)
Serial number of failed request: 19
Current serial number in output stream: 19
Then I decided to try:
Pixmap pix = XCreatePixmap(display, RootWindow(display, screen), 800, 600, DefaultDepth(display, screen)); Visual *visual; XImage* ximg = XCreateImage(display, visual, 24, XYBitmap, 0, (char*)img_bits, 800 , 600, 32, 32); XPutImage(display, window, DefaultGC(display, screen), ximg, 0, 0, 0, 0, 800, 600);
Thank you very much in advance.