X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=render%2Fcolor.c;h=dfdd092c56062046206835eb53ce84bd46717c36;hb=452f3f8aae796f70a5bd479986aa29937070951c;hp=564fb7cf8edbfba6aad93a5060a09e7f98155a66;hpb=33ec08ea2253a1692cac221f49dadda339371f66;p=chaz%2Fopenbox diff --git a/render/color.c b/render/color.c index 564fb7cf..dfdd092c 100644 --- a/render/color.c +++ b/render/color.c @@ -4,9 +4,6 @@ #include "render.h" #include "color.h" -XColor *pseudo_colors; -int pseudo_bpc; - void RrColorAllocateGC(RrColor *in) { XGCValues gcv; @@ -78,14 +75,18 @@ void RrReduceDepth(const RrInstance *inst, RrPixel32 *data, XImage *im) if ((RrRedOffset(inst) != RrDefaultRedOffset) || (RrBlueOffset(inst) != RrDefaultBlueOffset) || (RrGreenOffset(inst) != RrDefaultGreenOffset)) { + g_message("CONVERSION %d->%d %d->%d %d->%d", + RrDefaultRedOffset, RrRedOffset(inst), + RrDefaultBlueOffset, RrGreenOffset(inst), + RrDefaultGreenOffset, RrBlueOffset(inst)); for (y = 0; y < im->height; y++) { for (x = 0; x < im->width; x++) { r = (data[x] >> RrDefaultRedOffset) & 0xFF; g = (data[x] >> RrDefaultGreenOffset) & 0xFF; b = (data[x] >> RrDefaultBlueOffset) & 0xFF; - p32[x] = (r << RrRedShift(inst)) - + (g << RrGreenShift(inst)) - + (b << RrBlueShift(inst)); + p32[x] = (r << RrRedOffset(inst)) + + (g << RrGreenOffset(inst)) + + (b << RrBlueOffset(inst)); } data += im->width; p32 += im->width; @@ -130,11 +131,11 @@ void RrReduceDepth(const RrInstance *inst, RrPixel32 *data, XImage *im) XColor *RrPickColor(const RrInstance *inst, gint r, gint g, gint b) { - r = (r & 0xff) >> (8-pseudo_bpc); - g = (g & 0xff) >> (8-pseudo_bpc); - b = (b & 0xff) >> (8-pseudo_bpc); - return &RrPseudoColors(inst)[(r << (2*pseudo_bpc)) + - (g << (1*pseudo_bpc)) + + r = (r & 0xff) >> (8-RrPseudoBPC(inst)); + g = (g & 0xff) >> (8-RrPseudoBPC(inst)); + b = (b & 0xff) >> (8-RrPseudoBPC(inst)); + return &RrPseudoColors(inst)[(r << (2*RrPseudoBPC(inst))) + + (g << (1*RrPseudoBPC(inst))) + b]; } @@ -241,3 +242,23 @@ void RrIncreaseDepth(const RrInstance *inst, RrPixel32 *data, XImage *im) g_message("this image bit depth is currently unhandled\n"); } } + +int RrColorRed(const RrColor *c) +{ + return c->r; +} + +int RrColorGreen(const RrColor *c) +{ + return c->g; +} + +int RrColorBlue(const RrColor *c) +{ + return c->b; +} + +gulong RrColorPixel(const RrColor *c) +{ + return c->pixel; +}