/* dither 8 bit depth yuv images Copyright (C) 2000 Martin Vogt This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation. For more information look at the file COPYRIGHT in this package */ #include "dither8Bit.h" Dither8Bit::Dither8Bit(unsigned char pixel[256]) { int i; for(i=0;i<256;i++) { this->pixel[i]=pixel[i]; } colorTable8Bit=new ColorTable8Bit(); lum_values = colorTable8Bit->getLumValues(); cr_values = colorTable8Bit->getCrValues(); cb_values = colorTable8Bit->getCbValues(); initOrderedDither(); } Dither8Bit::~Dither8Bit() { int i; for (i=0; i threshval) { *lmark++ = ((j+1) * (CR_RANGE * CB_RANGE)); } else { *lmark++ = (j * (CR_RANGE * CB_RANGE)); } } } for (j=lum_values[LUM_RANGE-1]; j<256; j++) { *lmark++ = (LUM_RANGE-1)*(CR_RANGE * CB_RANGE); } } for (i=0; i threshval) { *cmark++ = ((j+1) * CB_RANGE); } else { *cmark++ = (j * CB_RANGE); } } } for (j=cr_values[CR_RANGE-1]; j<256; j++) { *cmark++ = (CR_RANGE-1)*(CB_RANGE); } } for (i=0; i threshval) { *cmark++ = j+1; } else { *cmark++ = j; } } } for (j=cb_values[CB_RANGE-1]; j<256; j++) { *cmark++ = CB_RANGE-1; } } } /* *-------------------------------------------------------------- * * OrderedDitherImage -- * * Dithers an image using an ordered dither. * Assumptions made: * 1) The color space is allocated y:cr:cb = 8:4:4 * 2) The spatial resolution of y:cr:cb is 4:1:1 * The channels are dithered based on the standard * ordered dither pattern for a 4x4 area. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ void Dither8Bit::ditherImageOrdered (unsigned char* lum, unsigned char* cr, unsigned char* cb, unsigned char* out, int h, int w) { unsigned char *l, *r, *b, *o1, *o2; unsigned char *l2; unsigned char L, R, B; int i, j; l = lum; l2 = lum+w; r = cr; b = cb; o1 = out; o2 = out+w; for (i=0; i