Motif 1.2 AIX 4.2.1 XmGetPixelByDepth

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

4 posts / 0 new
Last post
Motif 1.2 AIX 4.2.1 XmGetPixelByDepth

Submitted by Anonymous on Wed, 10/24/2001 - 12:03. Developers
I have a gif that I converted to XPM using XV. The width is 96, height 60, num_colors 247, chars_per_pixel is 2. I assume chars_per_pixel is the density with respect to the XmGetPixelByDepth invocation (?).

It gives me the XmUNSPECIFIED_PIXMAP after the XmGetPixelByDepth. Do I have to do an XmInstallImage(), or is it impossible for Motif 1.2 to display this graphic due to the number of colors? I`m trying to replace code that was doing a XmCreatePixmapFromBitmapData() that loaded a monochrome bitmap.

All I`m trying to do is

myPixmap = XmGetPixmapByDepth(XtScreen(myShell), "/mydir/my.xpm",
fg, bg, 8);
if (myPixmap == XmUNSPECIFIED_PIXMAP)
printf ("Couldn`t load myPixmap
" );
else
myLabel = XtVaCreateManagedWidget( "myLabel",
xmLabelWidgetClass, myFrame,
XmNsensitive, TRUE,
XmNalignment, XmALIGNMENT_CENTER,
XmNrecomputeSize, False,
XmNlabelType, XmPIXMAP,
XmNlabelPixmap, myPixmap,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
XmNmarginTop, 0,
XmNmarginBottom, 0,
XmNmarginLeft, 0,
XmNmarginRight, 0,
XmNheight, 60,
XmNwidth, 96,
NULL );

Thank you very much

--Jeff

ICS_support

I think the real problem is that Motif 1.2 doesn`t have an internal converter for XPM, so it can`t read the file. You can link with the XPM library and then have your application install the pixmap or simply use it as you do in the end of the code snippet above.

Anonymous

Could you expand on the comment "or simply use it as you do in the end of the code snippet above."? Are you indicating there`s a way for Motif 1.2 to read the XPM with out the XPM library? Is there a different format I could save the file other than XPM that Motif 1.2 could display? Thanks

Jeff Minch

ICS_support

The converters for Motif, which for 1.2 means the converters for Xt, are limited effectively to two-color pixmaps in XBM format. You can explicitly make calls to XPM. Once you have a pixmap, use it as you do "myPixmap" in your code snippet.

The code format really depends on the size of the image and what it might be used for. If small, XPM is appropriate. You have the option, too, of embedding the XPM directly in code; you can also hide it in application-specific directories, to be read at start-up. The situation that appears in your code implies that you want the end-user to be able to customize the label pixmap display in a significant way.