Esempio n. 1
0
/*
    Calculate a RGB palette out of VIC/VIC-II/TED colors (in ycbcr format),
    apply saturation, brightness, contrast, tint and gamma settings.

    this palette will be used for screenshots and by renderers if CRT emulation
    is disabled.
*/
static palette_t *video_calc_palette(struct video_canvas_s *canvas, const video_ycbcr_palette_t *p)
{
    palette_t *prgb;
    unsigned int i;
    float sat, bri, con, gam, tin;
    video_resources_t *video_resources = &(canvas->videoconfig->video_resources);

    DBG(("video_calc_palette"));

    sat = ((float)(video_resources->color_saturation)) / 1000.0f;
    bri = ((float)(video_resources->color_brightness - 1000)) * (128.0f / 1000.0f);
    con = ((float)(video_resources->color_contrast)) / 1000.0f;
    gam = video_get_gamma(video_resources);
    tin = (((float)(video_resources->color_tint)) / (2000.0f / 50.0f)) - 25.0f;

    /* create RGB palette with the base colors of the video chip */
    prgb = palette_create(p->num_entries, NULL);
    if (prgb == NULL) {
        return NULL;
    }

    for (i = 0; i < p->num_entries; i++) {
        video_convert_ycbcr_to_rgb(&p->entries[i], sat, bri, con, gam, tin,
                                   &prgb->entries[i]);
    }

    return prgb;
}
Esempio n. 2
0
/* conversion of YCbCr to RGB
   used by video_calc_palette (internal palette) (not used by CRT emu)
 */
static void video_convert_renderer_to_rgb_gamma(video_ycbcr_color_t *src, float sat,
                                       float bri, float con, float gam, float tin,
                                       palette_entry_t *dst, int video)
{
    float rf, bf, gf;
    double factor;
    int r, g, b;
    video_ycbcr_color_t tmp;

    /* DBG(("video_convert_renderer_to_rgb_gamma")); */

    tmp.cb = src->cb;
    tmp.cr = src->cr;
    tmp.y = src->y;

    if (video) {
        tmp.cr += tin; /* apply tint */
        /* apply saturation */
        tmp.cb *= sat;
        tmp.cr *= sat;

        video_convert_ycbcr_to_rgb(&tmp, &r, &g, &b);
    } else {
        /* FIXME: tint for ntsc */
        tmp.cr += tin; /* apply tint */
        /* apply saturation */
        tmp.cb *= sat;
        tmp.cr *= sat;

        video_convert_yiq_to_rgb(&tmp, &r, &g, &b);
    }

    /* do gamma correction */
    factor = pow(255.0f, 1.0f - gam);
    rf = video_gamma((float)r, factor, gam, bri, con);
    gf = video_gamma((float)g, factor, gam, bri, con);
    bf = video_gamma((float)b, factor, gam, bri, con);

    /* convert to int and clip to 8 bit boundaries */

    r = (int)rf;
    g = (int)gf;
    b = (int)bf;

    dst->dither = 0;
    dst->red = (BYTE)RMAX(r,255);
    dst->green = (BYTE)RMAX(g,255);
    dst->blue = (BYTE)RMAX(b,255);
    dst->name = NULL;
}
Esempio n. 3
0
static void video_convert_renderer_to_rgb(video_ycbcr_color_t *src,
                                       palette_entry_t *dst, int video)
{
    int r, g, b;

    /* DBG(("video_convert_renderer_to_rgb")); */

    if (video) {
        /* PAL */
        video_convert_ycbcr_to_rgb(src, &r, &g, &b);
    } else {
        /* NTSC */
        video_convert_yiq_to_rgb(src, &r, &g, &b);
    }

    dst->dither = 0;
    dst->red = (BYTE)r;
    dst->green = (BYTE)g;
    dst->blue = (BYTE)b;
    dst->name = NULL;
}