Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!newstop!sun!argv From: argv@turnpike.Eng.Sun.COM (Dan Heller) Newsgroups: comp.windows.x.motif Subject: Re: Loading pixmap in drawn button on color display? Message-ID: <141351@sun.Eng.Sun.COM> Date: 27 Aug 90 16:04:08 GMT References: <1990Aug27.005946.5857@elroy.jpl.nasa.gov> <1990Aug27.132311.11381@sunrise.com> Sender: news@sun.Eng.Sun.COM Organization: O'Reilly && Associates Lines: 38 In article larry@sunrise.com (Larry Rogers) writes: > In article pjs@aristotle.jpl.nasa.gov writes: > >displays? More to the point, why can't the drawnbutton figure > >it out for itself??? > 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. I would recommend using XmGetPixmap() under the following conditions: 1) Bitmaps used are compiled into the code (they are not read dynamically) This means that bitmaps are specified using #include or the short[]'s are precoded (probably based on the same files). 2) These pixmaps are to be used repeatedly throughout the life of the application, not just at UI initialization time. For "this" particular problem, I backup my recommendation that a second pixmap (of correct depth) is used and to use XCopyPlane() to render the bitmap into the pixmap. That is, until osf fixes this and the label widget/gadget to test for the depth themselves and use XCopyPlane() rather than XCopyArea() in the redisplay method (-very- simple fix). -- dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.