home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / windows / openloo / 4959 < prev    next >
Encoding:
Text File  |  1993-01-05  |  2.7 KB  |  68 lines

  1. Newsgroups: comp.windows.open-look
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!agate!linus!linus.mitre.org!mdw!tgimber
  3. From: tgimber@mdw.mitre.org (Tedd W Gimber)
  4. Subject: Re: OL RectButton labelImage byte ordering
  5. Message-ID: <1993Jan5.112923.2006@linus.mitre.org>
  6. Sender: news@linus.mitre.org (NONUSER)
  7. Nntp-Posting-Host: mdw.mitre.org
  8. Organization: Mitre Corporation, McLean, VA
  9. References: <1993Jan1.000817.15630@parc.xerox.com>
  10. Date: Tue, 5 Jan 1993 11:29:23 GMT
  11. Lines: 55
  12.  
  13. In article <1993Jan1.000817.15630@parc.xerox.com> coombs@ivan.uucp () writes:
  14. >I created bitmaps with the 'bitmap' program.  I then used XCreateImage
  15. >to generate the image for XtNlabelImage on rect buttons.  But the image
  16. >was wrong.  After an extended chase, I found that setting the images'
  17. >byte_order and bimap_bit_order to LSBFirst solved the problem.
  18. >
  19. >Setting the orders with ImageByteOrder and BitmapBitOrder did not solve
  20. >the problem.
  21. >
  22. >I ran all pieces on the same machine: 'bitmap', CC, and my
  23. >application.
  24. >
  25. >I tried 'iconedit', which generated the same output as 'bitmap'.
  26. >
  27. >I am not comfortable with hard coding the ordering.  Is there a better
  28. >solution?
  29. >
  30. >Thanks.  --Jim
  31.  
  32. I came across this exact problem last month.  The trick is to set the
  33. attributes bitmap_bit_order and byte_order in the XImage structure to LSBFirst.
  34.  
  35. Here's an extract of my code:
  36.  
  37. /*-------------------------------------------------------------------------*/
  38. IconButton::IconButton(WidgetRoot& parent, String iLabel, int iChoice, 
  39.                        const Color *fg, const Color *bg, char *bitmap, 
  40.                        unsigned int width, unsigned int height) 
  41.   : Button(iLabel, iChoice)
  42. {
  43.   image=XCreateImage(parent.getDisplay(),
  44.                      OlVisualOfObject(parent.getWidget()), 
  45.                      1, XYBitmap, 0, bitmap, width, height, 32,
  46.                      (width+7)/8);
  47.  
  48.   image->byte_order=LSBFirst;
  49.   image->bitmap_bit_order=LSBFirst;
  50.  
  51.   widget = XtVaCreateManagedWidget(label, oblongButtonWidgetClass, 
  52.                     parent.getWidget(),
  53.                     XtNlabelType,       (XtArgVal)OL_IMAGE,
  54.                     XtNlabelImage,      (XtArgVal)image,
  55.                     XtNforeground, (XtArgVal)fg->getColor().pixel,
  56.                     XtNbackground, (XtArgVal)bg->getColor().pixel,
  57.                     XtNinputFocusColor, (XtArgVal)bg->getColor().pixel,
  58.                     XtNfontColor, (XtArgVal)fg->getColor().pixel,
  59.                     NULL);
  60.  
  61. }
  62. /*-------------------------------------------------------------------------*/
  63.  
  64. The parameters bitmap, width, and height are from the included file
  65. produced by 'bitmap' or iconedit.  Hope this helps.
  66.  
  67. Tedd
  68.