/* colorTables for 8 Bit depth 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 "colorTable8Bit.h" ColorTable8Bit::ColorTable8Bit() { lum_values = new int[LUM_RANGE]; cr_values = new int[CR_RANGE]; cb_values = new int[CB_RANGE]; /* We can exploit cache by allocating contiguous blocks */ colortab = new TABTYPE[5*256]; Cr_r_tab = &colortab[0*256]; Cr_g_tab = &colortab[1*256]; Cb_g_tab = &colortab[2*256]; Cb_b_tab = &colortab[3*256]; L_tab = &colortab[4*256]; init8BitColor(); } ColorTable8Bit::~ColorTable8Bit() { delete lum_values; delete cr_values; delete cb_values; delete colortab; } void ColorTable8Bit::init8BitColor() { int i; for (i=0; i 255.0) fr = 255.0; if (fg < 0.0) fg = 0.0; else if (fg > 255.0) fg = 255.0; if (fb < 0.0) fb = 0.0; else if (fb > 255.0) fb = 255.0; *r = (unsigned char) fr; *g = (unsigned char) fg; *b = (unsigned char) fb; }