xforms-development
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XForms] FL_PACK Question.


From: Jens Thoms Toerring
Subject: Re: [XForms] FL_PACK Question.
Date: Sun, 20 Mar 2016 15:08:07 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Serge,

On Fri, Mar 18, 2016 at 05:28:58PM -0400, Serge Bromow wrote:
> I have used the FL_PACK macro for years to convert R,G,B values to
> unsigned long decimal for use with XSetWindowBackground.
> 
> All of a sudden it no longer works. Possibly as a result of moving
> to a 64bit OS. When I look at the definition in forms.h It appears
> the Red and Blue colour shift values are revered. i.e;
> 
> #define FL_RMASK           0x000000ff
> #define FL_RSHIFT          0
> #define FL_GMASK           0x0000ff00
> #define FL_GSHIFT          8
> #define FL_BMASK           0x00ff0000
> #define FL_BSHIFT          16
> 
> I believe it should be;
> 
> #define FL_RMASK           0x00ff0000
> #define FL_RSHIFT          16
> #define FL_GMASK           0x0000ff00
> #define FL_GSHIFT          8
> #define FL_BMASK           0x000000ff
> #define FL_BSHIFT          0
> 
> Am I missing something?
> 
> For the moment I am using;
> 
> |decimal_colour =(r <<16)+(g <<8)+(b);|

I must admit that I never looked at these macros and have no
good idea what they're meant to be used for. I've grepped
around a bit and found only one instance of their use in all
of XForms in image/image_xwd.c. That seems to deal with some
obscure image format I've never used (or seen used) - it seems
to be used by the xwd utility. So I can't comment on the ques-
tion if these defines are correct or not - I'd have to go
through image/image_xwd.c and try to figure  out what it does
and what this image format used by xwd looks like.

An alternative might be to use the XForms color system to
find out the color you can pass to to Xlib functions like
XSetWindowBackground() would be the use of 

  unsigned long fl_get_pixel(FL_COLOR color);

That, of course, requires that the color you want to know the
pixel value (as usable for Xlib calls) for is already a color
known to XForms, i.e. you can use it only with the already de-
fined XForms colors.

If that's not the case you can define a new XForms color with
an index col (i.e. a FL_COLOR value) from the unused slots,
using fl_mapcolor():

  unsigned long fl_mapcolor(FL_COLOR col, int red, int green, int blue);

using a not yet used color index (something between FL_FREE_COLOR1
and below FL_MAX_COLORS) to create a new color with the given rgb
color values (or the best approximation thatcan displyed). As far
as I can see it even returns the color value you can use for Xlib
functions, so there's no need for calling fl_get_color() after-
wards.

Note though that this is all just from looking around a bit
but I have done no actual testing!

                           Best regards, Jens
-- 
  \   Jens Thoms Toerring  ________      address@hidden
   \_______________________________      http://toerring.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]