kbj@JUPITER.RISC.COM (Ken Johnson) (10/10/90)
Question: I am working with XView 2.0 and have had a lot of success so far. I am now at the point where I need to display 2D 8 bit images in windows. I need different sized images and sometimes I need several dozen small (40x40) images on the screen. I have the raw data in arrays of unsigned char image[][]; Do i use pixmaps or do I use XImages? How do I use them? I understand some of the differences but I'd like to know the pros and cons of both. It is my understanding that I use the low level Xlib functions to do the dirty work. I've managed to get bounding rectangles and such up but haven't had luck with the actual XImages. HELP. We thank you for your support. /* ------------------------------------------------------------------------- */ Ken Johnson Phone: 805-373-4487 Rockwell International Science Center Comnet: 273-4487 1049 Camino Dos Rios A-18 e-mail: kbj@risc.com Thousand Oaks, CA 91360 If enough data is collected, anything may be proven by statistical methods.... /* ------------------------------------------------------------------------- */
morten@modulex.dk (Morten Hastrup) (10/11/90)
kbj@JUPITER.RISC.COM (Ken Johnson) writes: >I am now at the point where I need to display 2D 8 bit images in windows. >I need different sized images and sometimes I need several dozen small >(40x40) images on the screen. I have the raw data in arrays of >unsigned char image[][]; >Do i use pixmaps or do I use XImages? As I see it, you want to display PIXMAPs in a window (or on a widget). >How do I use them? So what you do is first create a IMAGE. This is the way to tell X about the 'look' - this is depth, colors, etc. - of you image. Second you puts the image into a PIXMAP (you could clip the image, if needed, at this point), and use this pixmap on the window (or in a widget). >It is my understanding that I use the low level Xlib functions to do the >dirty work. I've managed to get bounding rectangles and such up but haven't >had luck with the actual XImages. Before you write the code for this, you should look at XPM format and functions - These are publicdomain from Bull. I'll hope this would help you. Mail me if you need further help. -- Morten Hastrup Email: <morten@modulex.dk> A/S MODULEX Phone: +45 44 53 30 11 Lyskaer 15 Telefax: +45 44 53 30 74 DK-2730 Herlev Denmark
mouse@LARRY.MCRCIM.MCGILL.EDU (10/12/90)
> Question: I am working with XView 2.0 and have had a lot of success > so far. I am now at the point where I need to display 2D 8 bit > images in windows. I need different sized images and sometimes I > need several dozen small (40x40) images on the screen. I have the > raw data in arrays of unsigned char image[][]; > Do i use pixmaps or do I use XImages? How do I use them? I > understand some of the differences but I'd like to know the pros and > cons of both. You almost certainly[%] want to use XImages at some point. Whether to use Pixmaps or not is a question of tradeoffs - typically, trading off server memory against redisplay speed. As an outline, you can either create an XImage and then XPutImage it to the window, or you can create an XImage, XPutImage it to a Pixmap, and then XCopyArea that pixmap to the window. The advantage of the latter is that you need do the XPutImage only once; after that you can copy from the Pixmap as often as you like, and it will happen very fast (compared to the XPutImage). This makes handling damage to the window easy: just have the Expose events trigger calls to XCopyArea. The disadvantage is that it costs server memory to store the Pixmap. If server memory is scarce (on an X terminal, for example), this may not be a good idea. [%] `"almost" certainly' because it *is* possible to draw a picture by breaking it up into primitives such as rectangles, lines, pixels, etc, and drawing them. For most pictures, this is much, much slower. (If the picture is geometrically simple, such as a few rectangles of uniform colors, this may not be true. In any case, trying to make the decision automatically at run-time is not simple without some sort of information about the picture's contents.) der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu