Re: GtkColorButton Deprecation



On 13-04-12 03:51 PM, Lanoxx wrote:
Hi,

i was migration some code from GtkColorButton to the GtkColorChooser
interface today. I was storing a color palette of 3x16 colors (R + G +
B) as 16bit integers before which looked something like this:

         "{"\
         0x2e2e, 0x3434, 0x3636,\
         0xcccc, 0x0000, 0x0000,\
         0x4e4e, 0x9a9a, 0x0606,\
         ...
         0xadad, 0x7f7f, 0xa8a8,\
         0x3434, 0xe2e2, 0xe2e2,\
         0xeeee, 0xeeee, 0xecec}"

However with the new ColorChooser interface I now have to store doubles
instead of ints. If I convert the values to doubles and then store them
in the same way, it doesnt' look like a very clean solution to me. So I
was wondering if there isn't any cleaner and easier solution for this?

         "{"\
         0.180392156863, 0.203921568627, 0.211764705882,\
         ...
         ...}"


Hi,

You could do something like this:

    #define RGB(r,g,b) { (r) / (gdouble)G_MAXUINT16, \
                         (g) / (gdouble)G_MAXUINT16, \
                         (b) / (gdouble)G_MAXUINT16, 1. }

    static GdkRGBA palette[] = {
      RGB(0x2e2e, 0x3434, 0x3636),
      RGB(0xcccc, 0x0000, 0x0000),
      // ...
    };

Cheers,
Matthew Brush



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