Hi.
I have a rather basic question and I'm hoping that someone more
experienced than I will be able to see what needs changing in this.
Objective: To display an image. I have the image in an array (type
char), and each pixel is as follows:
[MSB_red] [LSB_red] [MSB_green] [LSB_green] [MSB_blue] [LSB_blue]
and so on. MSB stands for Most Significant Byte, and LSB for Least.
What follows are the relevant segments of the program:
store = new char[3*width*height*bytes_per_pixel];
// store is loaded with the image, then
display = XOpenDisplay (NULL);
screen = DefaultScreen (display);
depth = DefaultDepth (display, screen);
window_attributes.border_pixel = BlackPixel (display, screen);
window_attributes.background_pixel = BlackPixel (display, screen);
window_attributes.override_redirect = 0;
window_mask = CWBackPixel | CWBorderPixel;
win = XCreateWindow (display, DefaultRootWindow (display), 0, 0,
width, height, 0, depth, InputOutput,
CopyFromParent, window_mask,
window_attributes);
x_image = XCreateImage (display, CopyFromParent, depth, ZPixmap, 0,
store, width,
height, 16, width * bytes_per_pixel * 3);
image_gc = XCreateGC (display, win, 0, 0);
XMapWindow (display, win);
XSelectInput(display, win, ExposureMask | KeyPressMask |
ButtonPressMask | StructureNotifyMask);
while (1)
{
XEvent x_event;
XNextEvent(display, x_event);
switch (x_event.type)
{
case Expose:
XPutImage (display, win, image_gc, x_image, 0, 0, 0,
0, width, height);
XFlush(display);
break;
case KeyPress:
if(XLookupKeysym(x_event.xkey, 0) == XK_q)
{
delete [] store;
image.close();
return 0;
exit(0);
}
break;
}
}
return 0;
}
The image that is displayed can be seen at
http://ket.dyndns.org/xtest1.png
The proper image can be seen at:
http://ket.dyndns.org/xtest2.png
I would appreciate any wise words of wisdom.
Thanks
Paul
___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel