Exemplo n.º 1
0
void Flcc_ValueBox::generate()
{
    int X = 0, Y = 0, W = w(), H = h();
    box()->inset(X,Y,W,H);

    Fl_Image *im = new Fl_Image(W, H, 32);

    uint32 *dst = (uint32*)im->data();
    uint32 rgb;
    int skip = (im->pitch() - W * im->bytespp()) >> 2;

    for(int y = 0; y < H; y++) {

        float Yf = 255*(1.0-float(y)/H);
        fl_rgb888_from_rgb(rgb, uchar(tr*Yf+.5f), uchar(tg*Yf+.5f), uchar(tb*Yf+.5f));

        for(int x = 0; x < W; x++) {
            *dst++ = rgb;
        }

        dst += skip;
    }
    if(bg) delete bg;
    bg = im;
}
Exemplo n.º 2
0
void Flcc_HueBox::generate()
{
    int X = 0, Y = 0, W = w(), H = h();
    box()->inset(X,Y,W,H);

#ifdef UPDATE_HUE_BOX
    const float V = ((Fl_Color_Chooser*)(parent()))->v();
#else
    const float V = 1.0f;
#endif

    Fl_Image *im = new Fl_Image(W, H, 32);

    uint32 *dst = (uint32 *)im->data();
    int skip = (im->pitch() - W * im->bytespp()) >> 2;
    register float r,g,b;

    for(int y = 0; y < H; y++) {

        float Yf = (float)y / H;

        for (int x = 0; x < W; x++)
        {
            float Xf = (float)x / W;
            float H,S; tohs(Xf, Yf, H, S);
            Fl_Color_Chooser::hsv2rgb(H,S,V,r,g,b);
            fl_rgb888_from_rgb(*dst++, uchar(255*r+.5f), uchar(255*g+.5f), uchar(255*b+.5f));
        }
        dst += skip;
    }

    if(bg) delete bg;
    bg = im;
}
Exemplo n.º 3
0
uint8 *render_box(int w, int h, int bitspp, uint color, Fl_Colormap *pal, uint8 *buffer=0)
{
    int bpp = (bitspp+7)/8;
    int pitch = Fl_Renderer::calc_pitch(bpp, w);
    uint8 *ret = buffer;
    if(!buffer) ret = new uchar[pitch*h];

    uint8 r=0,g=0,b=0;
    fl_get_color(color, r, g, b);
    uint32 fill_color=0;
    switch(bitspp) {
    case 32: fl_rgb888_from_rgb(fill_color ,r,g,b); break;
    case 16: fl_rgb565_from_rgb((uint16&)fill_color ,r,g,b); break;
    case 15: fl_rgb555_from_rgb((uint16&)fill_color ,r,g,b); break;
    case 8:  fill_color = pal->find_color(r,g,b); break;
    default: break;
    }

    // Fill box, using fast duffs looping
    uint8 *ptr = ret;
    int skip = pitch - w * bpp;
    int height = h; int width = w;
    while ( height-- ) {
        DUFFS_LOOP(
        {
            switch(bitspp)
            {
            case 32: (uint32&)(*ptr) = fill_color; break;
            case 24: ptr[0] = r; ptr[1] = g; ptr[2] = b; break;
            case 16: (uint16&)(*ptr) = (uint16&)fill_color; break;
            case 15: (uint16&)(*ptr) = (uint16&)fill_color; break;
            case 8:  (uint8&)(*ptr) = (uint8&)fill_color; break;
            default: break;
            }
            ptr += bpp;
        }, width);
        ptr += skip;
    }