Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm using XCreateImage with a bitmap of depth of 24 bits, the bitmap is stored into an unsigned int array:
buffer = malloc(width*height*sizeof(unsigned int));
Then I create and XImage like this:
XImage* image = XCreateImage(display, DefaultVisual(display, 0), 24, ZPixmap, 0, buffer, width, height, 32, 0);
It's working, however I get this warning when compiling:
/usr/include/X11/Xlib.h:1441:16: note: expected ‘char *’ but argument is of type ‘unsigned int *’
extern XImage *XCreateImage(
Can I just cast the buffer to a char* without any problem?
According to XCreateImage(3)
the function definition is
XImage *XCreateImage(Display *display, Visual *visual, unsigned int depth, int for‐
mat, int offset, char *data, unsigned int width, unsigned int height, int bit‐
map_pad, int bytes_per_line);
buffer
is of type int *
so you should cast it to char *
like this
XImage* image = XCreateImage(display, DefaultVisual(display, 0), 24, ZPixmap, 0, (char *)buffer, width, height, 32, 0);
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.