Re: hildon_color_button custom colors issue

2008-04-18 Thread Aniello Del Sorbo
On Wed, Apr 16, 2008 at 12:40 PM, Aniello Del Sorbo [EMAIL PROTECTED]
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: 0x 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@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: hildon_color_button custom colors issue

2008-04-18 Thread Allen Brown
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 [EMAIL PROTECTED]
 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: 0x 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@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers



___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: hildon_color_button custom colors issue

2008-04-16 Thread Aniello Del Sorbo
Hi,

this may help other people when working with RGBA values.

I did indeed solved the problem.

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

Is that the correct explanation ?

--
anidel

On Tue, Apr 15, 2008 at 8:16 PM, Aniello Del Sorbo [EMAIL PROTECTED] wrote:

 I reply to myself.
 I was testing the app running it from a remote SSH (root) and not from the
 user's Menu.

 It works.
 Thanks anyway.

 Aniello


 On Tue, Apr 15, 2008 at 5:50 PM, Aniello Del Sorbo [EMAIL PROTECTED]
 wrote:

  Hi,
 
  while porting Xournal to Maemo I decided to give it as much
  hildonization is possible.
  Base xournal uses only a bunch of predefined colors (something like 9 or
  10 colors).
 
  I decided to use the hildon_color_button widget to give the user a much
  wide choice of colors.
  I get the GdkColor from the color button and have to convert it in RGBA
  because Xournal only works with those values
  (passing fill-color-rgba to the canvas items). It does this, I think,
  for being able to make a highlighter tool available in different colors
  (by making use of the alpha channel).
 
  anyway, I convert the GdkColor to RGBA using the macro:
 
  GdkColor *color; // read from the hildon_color widget
  guint alpha = 0xFF; // no transparency
 
  guint rgba = GNOME_CANVAS_COLOR_A  (color-red, color-green,
  color-blue, alpha)
 
  and then use it wherever it is needed.
 
  This works for the predefined colors in the color chooser dialog.
  But if I choose my own custom color it does not.
 
  If I use the GdkColor as is (thus passing fill-color-gdk to the canvas
  items), it works, but I can't use the alpha channel (can I ?).
  If I convert this custom color to RGBA with the given macro, it paints
  in a totally different color.
 
  Is this some issue with the colormap ?
  Is GNOME_CANVAS_COLOR_A not good for this ?
 
  Any other hints ?
 
  --
  anidel




 --
 anidel




-- 
anidel
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


hildon_color_button custom colors issue

2008-04-15 Thread Aniello Del Sorbo
Hi,

while porting Xournal to Maemo I decided to give it as much hildonization is
possible.
Base xournal uses only a bunch of predefined colors (something like 9 or 10
colors).

I decided to use the hildon_color_button widget to give the user a much wide
choice of colors.
I get the GdkColor from the color button and have to convert it in RGBA
because Xournal only works with those values
(passing fill-color-rgba to the canvas items). It does this, I think, for
being able to make a highlighter tool available in different colors
(by making use of the alpha channel).

anyway, I convert the GdkColor to RGBA using the macro:

GdkColor *color; // read from the hildon_color widget
guint alpha = 0xFF; // no transparency

guint rgba = GNOME_CANVAS_COLOR_A  (color-red, color-green, color-blue,
alpha)

and then use it wherever it is needed.

This works for the predefined colors in the color chooser dialog.
But if I choose my own custom color it does not.

If I use the GdkColor as is (thus passing fill-color-gdk to the canvas
items), it works, but I can't use the alpha channel (can I ?).
If I convert this custom color to RGBA with the given macro, it paints in a
totally different color.

Is this some issue with the colormap ?
Is GNOME_CANVAS_COLOR_A not good for this ?

Any other hints ?

-- 
anidel
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: hildon_color_button custom colors issue

2008-04-15 Thread Aniello Del Sorbo
I reply to myself.
I was testing the app running it from a remote SSH (root) and not from the
user's Menu.

It works.
Thanks anyway.

Aniello

On Tue, Apr 15, 2008 at 5:50 PM, Aniello Del Sorbo [EMAIL PROTECTED] wrote:

 Hi,

 while porting Xournal to Maemo I decided to give it as much hildonization
 is possible.
 Base xournal uses only a bunch of predefined colors (something like 9 or
 10 colors).

 I decided to use the hildon_color_button widget to give the user a much
 wide choice of colors.
 I get the GdkColor from the color button and have to convert it in RGBA
 because Xournal only works with those values
 (passing fill-color-rgba to the canvas items). It does this, I think,
 for being able to make a highlighter tool available in different colors
 (by making use of the alpha channel).

 anyway, I convert the GdkColor to RGBA using the macro:

 GdkColor *color; // read from the hildon_color widget
 guint alpha = 0xFF; // no transparency

 guint rgba = GNOME_CANVAS_COLOR_A  (color-red, color-green, color-blue,
 alpha)

 and then use it wherever it is needed.

 This works for the predefined colors in the color chooser dialog.
 But if I choose my own custom color it does not.

 If I use the GdkColor as is (thus passing fill-color-gdk to the canvas
 items), it works, but I can't use the alpha channel (can I ?).
 If I convert this custom color to RGBA with the given macro, it paints in
 a totally different color.

 Is this some issue with the colormap ?
 Is GNOME_CANVAS_COLOR_A not good for this ?

 Any other hints ?

 --
 anidel




-- 
anidel
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers