[maemo-developers] hildon_color_button & custom colors issue

From: Allen Brown abrown at peak.org
Date: Fri Apr 18 21:26:09 EEST 2008
I think that is still incorrect.  You should divide by 256.  That
is exactly equivalent to shifting the bits to the right by 8.
That moves the bits you want into the byte you need.
-- 
Allen Brown
http://brown.armoredpenguin.com/~abrown

> On Wed, Apr 16, 2008 at 12:40 PM, Aniello Del Sorbo <anidel at gmail.com>
> wrote:
>
>>
>> Anyway.. the first issue below happened because I was running Xournal
>> from
>> root in an SSH remote shell.
>> Thus, probably, colormaps  were wrong.
>> Running it the usual way (from the Menu) fixed a bit things.
>> The GdkColor returned by the hildon color chooser was, when drawn on the
>> canvas, slightly different from the one showed in the button itself.
>> I think it looked darker.
>>
>> After digging a bit I figured out that the GdkColor RGB values where
>> RGB16
>> (guint16) while I needed the RGB8 format (for the "fill-color-rgba"
>> property).
>> Thus, I had to first divide red, green and blue by 255 before putting
>> them
>> into a single guint value (RGBA) in the form of 0xRRGGBBAA.
>>
>> guint rgba = GNOME_CANVAS_COLOR_A  (color->red / 255.0, color->green /
>> 255.0, color->blue / 255.0, alpha)
>>
>
> Further corrected, the divisor should not be 255 but 257 (0x101) instead.
> Otherwise the reduction from RGB16 to RGB8 does not work.
> RGB16 is in the form: 0xRRRRGGGGBBBB i.e. values range from 0 to 65535
> RGB8 is in the form 0xRRGGBB i.e. values range from 0 to 255.
>
> Sorry if this is stuff people already know, but I am new to it and
> couldn't
> find much about it.
>
> --
> anidel
> _______________________________________________
> maemo-developers mailing list
> maemo-developers at maemo.org
> https://lists.maemo.org/mailman/listinfo/maemo-developers
>



More information about the maemo-developers mailing list