koe@kivax.UUCP (Diana Koehler) (04/17/91)
Hello, I have several bitmaps (created with a scanner) and I want to display them within a Motif-Application. How does the bitmap have to be formatted, that it can be interpreted by Motif-applications. (f.e Some times ago I have seen the picture of a mandrill. I think that the bitmap is NOT created with the bitmap editor "bitmap".) Does there exist an other tool for creating bitmaps? Any help would be apreciate. Thanks in advance Diana ------------------------------------------------------------------------ Diana Koehler Tel.: +49 7721 867034 Digital Kienzle Computersysteme Abt. 011.2 e-mail: koe@kivax.UUCP Postfach 1640 ..!mcsun!unido!kivax!koe D-7730 VS-Villingen ..!uunet!unido!kivax!koe
hsd@raybed2.msd.ray.com (HERBERT DASILVA) (04/22/91)
In article <31@kivax.UUCP> koe@kivax.UUCP (Diana Koehler) writes: >Hello, >I have several bitmaps (created with a scanner) and I want to display >them within a Motif-Application. I'll explain this last... >How does the bitmap have to be formatted, that it can be interpreted >by Motif-applications. The bitmap should be in 'xbm' format. This is the format output by the standard X11 tool 'bitmap'. >(f.e Some times ago I have seen the picture of a mandrill. I think > that the bitmap is NOT created with the bitmap editor "bitmap".) The mandrill is NOT a bitmap, it is a PIXMAP. A bitmap is just that, a two dimensional 'map' (read array) of bits (1s and 0s, on and off). A pixmap has color data encoded at each pixel location in the 'map'. >Does there exist an other tool for creating bitmaps? Probably, but I don't know of any off hand. >Any help would be apreciate. >Thanks in advance >Diana To display a bitmap in a Motif application is pretty easy, you display it in an XmLabel (or XmLabelGadget) like this: Since bitmaps contain no color, you must choose two colors, a foreground and a background color. You do this by allocating the colors: Display *display; XColor *bgColor; /* Actual color values for the color requested */ XColor *fgColor; XColor *bgScreenColor; /* Closest color the display can actually produce */ XColor *fgScreenColor; bgColor = (XColor *)malloc( sizeof( XColor ) ); fgColor = (XColor *)malloc( sizeof( XColor ) ); bgScreenColor = (XColor *)malloc( sizeof( XColor ) ); fgScreenColor = (XColor *)malloc( sizeof( XColor ) ); display = XtDisplay( widget ); sts = XLookupColor( display, DefaultColormap( display, DefaultScreen(display) ), "black", bgColor, bgScreenColor ); sts = XLookupColor( display, DefaultColormap( display, DefaultScreen(display) ), "white", fgColor, fgScreenColor ); free( bgColor ); free( fgColor ); Then create a pixmap from the 'xbm' bitmap file: Pixmap pixmap; pixmap = XmGetPixmap( XtScreen(widget), "/usr/your/path/bitmap.xbm", fgScreenColor->pixel, bgScreenColor->pixel ); free( fgScreenColor ); free( bgScreenColor ); Then create the label with the pixmap in it: ac = 0; XtSetArg( args[ac], XmNlabelType, XmPIXMAP ); ac++; XtSetArg( args[ac], XmNlabelPixmap, pixmap ); ac++; pixWidget = XmCreateLabel( parent, "LabelPixmap", args, ac ); XtManageChild( pixWidget ); Ta Da! Instant bitmap. A Truly Impressive addition to any program. Any questions or problems, don't hesitate to ask. Herb DaSilva
krs0@gte.com (Rod Stephens) (04/23/91)
>>Does there exist an other tool for creating bitmaps? > > Probably, but I don't know of any off hand. One tool which does this is dxpaint. If you select the "Save as..." option from the "File" menu and specify "X11" format, it produces a file with the standard bitmap format. You can even edit the image using the "bitmap" program (thought this is hard since dxpaint produces very large bitmaps). +---------------------------------------------------------------+ | Rod Stephens | "Haven't I told you not to play | | GTE Laboratories, Inc | with my super-weapons? You might | | (617)466-4182 | devastate yourself!" | | krs0@gte.com | | +---------------------------------------------------------------+
JIW2@psuvm.psu.edu (04/24/91)
Rod Stevens writes: >You can even edit the image using the "bitmap" program >(though this is hard since dxpaint produces very large >bitmaps). Not quite true, Rod. Although the default window that Digital's dxpaint gives you is 600 X 750 pixels, you can use the "picture size" option of the "customize" menu bar choice to make the image any size you prefer. When I create Motif icon bitmaps, I use 52 X 52 pixel image size, and then use the "zoom on" edit option to expand the image for pixel-by-pixel editing. Works like a charm. John Wagner Pennsylvania State University