Changeset 4697


Ignore:
Timestamp:
Oct 17, 2010, 4:33:57 PM (8 years ago)
Author:
Sam Hocevar
Message:

Add functions to convert from RGB to YUV and back.

Location:
libpipi/trunk/pipi
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/Makefile.am

    r4696 r4697  
    8282        filter/median.c \
    8383        filter/dilate.c \
    84         filter/wave.c
     84        filter/wave.c \
     85        filter/yuv.c
    8586
    8687quantize_sources = \
  • libpipi/trunk/pipi/context.c

    r4696 r4697  
    9595        { "sine", 1 },
    9696        { "wave", 1 },
     97        { "rgb2yuv", 0 },
     98        { "yuv2rgb", 0 },
    9799
    98100        /* End marker */
     
    709711        ctx->images[ctx->nimages - 1] = dst;
    710712    }
     713    else if(!strcmp(cmd, "rgb2yuv") || !strcmp(cmd, "yuv2rgb"))
     714    {
     715        pipi_image_t *src, *dst = NULL;
     716        if(ctx->nimages < 1)
     717            return -1;
     718        src = ctx->images[ctx->nimages - 1];
     719        switch (cmd[0])
     720        {
     721            case 'r': dst = pipi_rgb2yuv(src); break;
     722            case 'y': dst = pipi_yuv2rgb(src); break;
     723        }
     724        if(dst == NULL)
     725            return -1;
     726        pipi_free(src);
     727        ctx->images[ctx->nimages - 1] = dst;
     728    }
    711729    else
    712730    {
  • libpipi/trunk/pipi/pipi.h

    r4696 r4697  
    210210__extern pipi_image_t *pipi_wave(pipi_image_t *, double, double,
    211211                                 double, double);
     212__extern pipi_image_t *pipi_rgb2yuv(pipi_image_t *);
     213__extern pipi_image_t *pipi_yuv2rgb(pipi_image_t *);
    212214
    213215__extern pipi_image_t *pipi_order(pipi_image_t *);
Note: See TracChangeset for help on using the changeset viewer.