Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!aristotle!pjs From: pjs@aristotle.JPL.NASA.gov (Peter Scott) Newsgroups: comp.windows.x.motif Subject: Re: Loading pixmap in drawn button on color display? Message-ID: <1990Aug27.175009.29113@elroy.jpl.nasa.gov> Date: 27 Aug 90 17:50:09 GMT References: <1990Aug27.005946.5857@elroy.jpl.nasa.gov> <1990Aug27.132311.11381@sunrise.com> <141351@sun.Eng.Sun.COM> Sender: news@elroy.jpl.nasa.gov (Usenet) Reply-To: pjs@aristotle.jpl.nasa.gov Followup-To: comp.windows.x.motif Organization: Jet Propulsion Laboratory, NASA/Caltech Lines: 33 Nntp-Posting-Host: aristotle.jpl.nasa.gov In article <141351@sun.Eng.Sun.COM>, argv@turnpike.Eng.Sun.COM (Dan Heller) writes: > In article larry@sunrise.com (Larry Rogers) writes: > > You have to generate an image and then generate a pixmap from the > > image. An easier solution under Motif is to use XmGetPixmap. It > > automatically generates a pixmap of the correct depth for the > > display. It's also pretty quick becauuse it caches the pixmaps > > it creates. > > In this particular person's application, he is allowing the user > to select (at run time) a bitmap file. He's got to load the file > somehow, and the only way to do it is into a pixmap. Then, he > would have to extract an image (big operation here; performance > hazard warning if this is going to be done frequently), then call > XmGetPixmap from the image just to get a pixmap that's the correct > depth. Furthermore, this pixmap is _cached_ which means that if > he no longer needs it (it doesn't sound likely if the user is > browsing), the pixmap is saved anyway. But it seems that Larry is right. The Programmer's Reference for XmGetPixmap states "... If an image is not found, the image_name is used as a filename, and a search is made for an X10 or X11 bitmap file. If it is found, the file is read, converted to an image, and cached in the image cache. The image is then used to generate a pixmap, which is cached and returned." I just reprogrammed it this way and it works on both the B/W and color systems. And the code is a lot shorter! Thanks, Larry. -- This is news. This is your | Peter Scott, NASA/JPL/Caltech brain on news. Any questions? | (pjs@aristotle.jpl.nasa.gov)