File format support

Hi All,

Can anybody tell me, what all file formats are supported in Motif proramming. Currently we are displaying pictures on Drawing area using XPM, XBM, BM files. But we want to display pictures using other files like BMP, JPG, GIF etc. Is it possible to use JPG, BMP, GIF etc files to display pictures on Drawing Area? Please let me know what should I do for this.

Thanks

Nitin


dpeterc

dpeterc's picture

File format support

In OpenMotif 2.3, you have support for PNG and JPEG image types.
You can specify PNG of JPEG images in resource file, same way
as you did for XPM and XBM.
If you want to do it from C program, here is some code which I use:

<br />
void setTranspIcon(Widget w, char *iconName, int selectPix, int pixAndString)<br />
{<br />
  Pixmap pixmapPix=0;<br />
  Pixel fg = XmUNSPECIFIED_PIXEL;<br />
  Pixel bg = XmUNSPECIFIED_PIXEL;</p>
<p>  XtVaGetValues(w, XmNforeground, &fg, XmNbackground, &bg, NULL);<br />
  pixmapPix = XmGetPixmap(XtScreen(w), iconName, fg, bg);<br />
  if (pixmapPix != XmUNSPECIFIED_PIXMAP)<br />
   XtVaSetValues(w, XmNlabelType, pixAndString ? XmPIXMAP_AND_STRING : XmPIXMAP, selectPix ? XmNselectPixmap : XmNlabelPixmap, pixmapPix, NULL);<br />
  else<br />
   printf("Can't find icon %s!\n", filen);<br />
}<br />

Some more hints - with PNG, only 32 bits per pixel images work properly.
So you need to make proper RGBA image, with alpha channel transparency. You can use GIMP to do this.

Hope this helps.