Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[XForms] FL_PACK Question.

0 views
Skip to first unread message

Serge Bromow

unread,
Mar 18, 2016, 5:29:16 PM3/18/16
to Development with and of XForms
Hello to All,

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);|


Thanks,

Serge
--
Signature

Serge Bromow

DineAmix Inc. <http://www.dineamix.ca> <se...@dineamix.ca> (613)
260-8629 888 411-6636 Ottawa, Canada.
Please Consider the Environment before Printing the E-Mail. IMPORTANT
NOTICE: This message is intended only for the use of the individual or
entity to which it is addressed. The message may contain information
that is privileged, confidential and exempt from disclosure under
applicable law. If the reader of this message is not the intended
recipient, or the employee or agent responsible for delivering the
message to the intended recipient, you are notified that any
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please
notify DineAmix Inc. immediately by email at postm...@dineamix.ca.
Thank you.

Jens Thoms Toerring

unread,
Mar 20, 2016, 10:09:51 AM3/20/16
to Development with and of XForms
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 ________ j...@toerring.de
\_______________________________ http://toerring.de

0 new messages