Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!stanford.edu!lucid.com!campeau!jwz From: jwz@lucid.com (Jamie Zawinski) Newsgroups: comp.windows.x Subject: XImage help Message-ID: Date: 7 Apr 91 10:07:28 GMT Sender: usenet@lucid.com Organization: Lucid, Inc., Menlo Park, CA Lines: 28 Say I've got an XImage structure that I've read from a file. What's the best way to display that in a window, when the current display doesn't necessarily have the same depth as the XImage does? Let's assume the display is at least as deep as the image. I am under the (hopefully mistaken!) impression that I have to do a pixel-by-pixel iteration, copying one image into another, in order to do do this. But I can't get that to work either; this code corrupts the image (slants it, lines too long...) new_image = XCreateImage(dpy, DefaultVisual(dpy, scr), DefaultDepth(dpy, scr), ZPixmap, old_image->xoffset, XtMalloc(old_image->bytes_per_line * old_image->height * old_image->depth), old_image->width, old_image->height, old_image->bitmap_pad, old_image->bytes_per_line); for (r = 0; r < old_image->height; ++r) for (s = 0; s < old_image->width; ++s) XPutPixel (new_image, s, r, XGetPixel(old_image, s, r)); I tried XYPixmap as well, same effect. What am I doing wrong? -- Jamie