author | mickeyl <mickeyl> | 2003-09-16 13:07:56 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-09-16 13:07:56 (UTC) |
commit | 9cd1a5708fa9f10e391bd18cbf1f5800cdc76851 (patch) (side-by-side diff) | |
tree | 65404702ea418b9270158a941b408870d981eca4 | |
parent | 81171716bb686e709f27fbbc0931740aa9d9462a (diff) | |
download | opie-9cd1a5708fa9f10e391bd18cbf1f5800cdc76851.zip opie-9cd1a5708fa9f10e391bd18cbf1f5800cdc76851.tar.gz opie-9cd1a5708fa9f10e391bd18cbf1f5800cdc76851.tar.bz2 |
remove unneccessary #include
-rw-r--r-- | libopie2/opieui/oimageeffect.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/libopie2/opieui/oimageeffect.cpp b/libopie2/opieui/oimageeffect.cpp index 2855da6..01e7c6f 100644 --- a/libopie2/opieui/oimageeffect.cpp +++ b/libopie2/opieui/oimageeffect.cpp @@ -1,804 +1,803 @@ /* This file is part of the KDE libraries Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@kde.org> (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> (C) 2000 Josef Weidendorfer <weidendo@in.tum.de> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // $Id$ #include <math.h> #include <qimage.h> #include <stdlib.h> -#include <iostream> #include "oimageeffect.h" #define MaxRGB 255L #define DegreesToRadians(x) ((x)*M_PI/180.0) using namespace std; inline unsigned int intensityValue(unsigned int color) { return((unsigned int)((0.299*qRed(color) + 0.587*qGreen(color) + 0.1140000000000001*qBlue(color)))); } //====================================================================== // // Gradient effects // //====================================================================== QImage OImageEffect::gradient(const QSize &size, const QColor &ca, const QColor &cb, GradientType eff, int ncols) { int rDiff, gDiff, bDiff; int rca, gca, bca, rcb, gcb, bcb; QImage image(size, 32); if (size.width() == 0 || size.height() == 0) { qDebug( "WARNING: OImageEffect::gradient: invalid image" ); return image; } register int x, y; rDiff = (rcb = cb.red()) - (rca = ca.red()); gDiff = (gcb = cb.green()) - (gca = ca.green()); bDiff = (bcb = cb.blue()) - (bca = ca.blue()); if( eff == VerticalGradient || eff == HorizontalGradient ){ uint *p; uint rgb; register int rl = rca << 16; register int gl = gca << 16; register int bl = bca << 16; if( eff == VerticalGradient ) { int rcdelta = ((1<<16) / size.height()) * rDiff; int gcdelta = ((1<<16) / size.height()) * gDiff; int bcdelta = ((1<<16) / size.height()) * bDiff; for ( y = 0; y < size.height(); y++ ) { p = (uint *) image.scanLine(y); rl += rcdelta; gl += gcdelta; bl += bcdelta; rgb = qRgb( (rl>>16), (gl>>16), (bl>>16) ); for( x = 0; x < size.width(); x++ ) { *p = rgb; p++; } } } else { // must be HorizontalGradient unsigned int *o_src = (unsigned int *)image.scanLine(0); unsigned int *src = o_src; int rcdelta = ((1<<16) / size.width()) * rDiff; int gcdelta = ((1<<16) / size.width()) * gDiff; int bcdelta = ((1<<16) / size.width()) * bDiff; for( x = 0; x < size.width(); x++) { rl += rcdelta; gl += gcdelta; bl += bcdelta; *src++ = qRgb( (rl>>16), (gl>>16), (bl>>16)); } src = o_src; // Believe it or not, manually copying in a for loop is faster // than calling memcpy for each scanline (on the order of ms...). // I think this is due to the function call overhead (mosfet). for (y = 1; y < size.height(); ++y) { p = (unsigned int *)image.scanLine(y); src = o_src; for(x=0; x < size.width(); ++x) *p++ = *src++; } } } else { float rfd, gfd, bfd; float rd = rca, gd = gca, bd = bca; unsigned char *xtable[3]; unsigned char *ytable[3]; unsigned int w = size.width(), h = size.height(); xtable[0] = new unsigned char[w]; xtable[1] = new unsigned char[w]; xtable[2] = new unsigned char[w]; ytable[0] = new unsigned char[h]; ytable[1] = new unsigned char[h]; ytable[2] = new unsigned char[h]; w*=2, h*=2; if ( eff == DiagonalGradient || eff == CrossDiagonalGradient) { // Diagonal dgradient code inspired by BlackBox (mosfet) // BlackBox dgradient is (C) Brad Hughes, <bhughes@tcac.net> and // Mike Cole <mike@mydot.com>. rfd = (float)rDiff/w; gfd = (float)gDiff/w; bfd = (float)bDiff/w; int dir; for (x = 0; x < size.width(); x++, rd+=rfd, gd+=gfd, bd+=bfd) { dir = eff == DiagonalGradient? x : size.width() - x - 1; xtable[0][dir] = (unsigned char) rd; xtable[1][dir] = (unsigned char) gd; xtable[2][dir] = (unsigned char) bd; } rfd = (float)rDiff/h; gfd = (float)gDiff/h; bfd = (float)bDiff/h; rd = gd = bd = 0; for (y = 0; y < size.height(); y++, rd+=rfd, gd+=gfd, bd+=bfd) { ytable[0][y] = (unsigned char) rd; ytable[1][y] = (unsigned char) gd; ytable[2][y] = (unsigned char) bd; } for (y = 0; y < size.height(); y++) { unsigned int *scanline = (unsigned int *)image.scanLine(y); for (x = 0; x < size.width(); x++) { scanline[x] = qRgb(xtable[0][x] + ytable[0][y], xtable[1][x] + ytable[1][y], xtable[2][x] + ytable[2][y]); } } } else if (eff == RectangleGradient || eff == PyramidGradient || eff == PipeCrossGradient || eff == EllipticGradient) { int rSign = rDiff>0? 1: -1; int gSign = gDiff>0? 1: -1; int bSign = bDiff>0? 1: -1; rfd = (float)rDiff / size.width(); gfd = (float)gDiff / size.width(); bfd = (float)bDiff / size.width(); rd = (float)rDiff/2; gd = (float)gDiff/2; bd = (float)bDiff/2; for (x = 0; x < size.width(); x++, rd-=rfd, gd-=gfd, bd-=bfd) { xtable[0][x] = (unsigned char) abs((int)rd); xtable[1][x] = (unsigned char) abs((int)gd); xtable[2][x] = (unsigned char) abs((int)bd); } rfd = (float)rDiff/size.height(); gfd = (float)gDiff/size.height(); bfd = (float)bDiff/size.height(); rd = (float)rDiff/2; gd = (float)gDiff/2; bd = (float)bDiff/2; for (y = 0; y < size.height(); y++, rd-=rfd, gd-=gfd, bd-=bfd) { ytable[0][y] = (unsigned char) abs((int)rd); ytable[1][y] = (unsigned char) abs((int)gd); ytable[2][y] = (unsigned char) abs((int)bd); } unsigned int rgb; int h = (size.height()+1)>>1; for (y = 0; y < h; y++) { unsigned int *sl1 = (unsigned int *)image.scanLine(y); unsigned int *sl2 = (unsigned int *)image.scanLine(QMAX(size.height()-y-1, y)); int w = (size.width()+1)>>1; int x2 = size.width()-1; for (x = 0; x < w; x++, x2--) { rgb = 0; if (eff == PyramidGradient) { rgb = qRgb(rcb-rSign*(xtable[0][x]+ytable[0][y]), gcb-gSign*(xtable[1][x]+ytable[1][y]), bcb-bSign*(xtable[2][x]+ytable[2][y])); } if (eff == RectangleGradient) { rgb = qRgb(rcb - rSign * QMAX(xtable[0][x], ytable[0][y]) * 2, gcb - gSign * QMAX(xtable[1][x], ytable[1][y]) * 2, bcb - bSign * QMAX(xtable[2][x], ytable[2][y]) * 2); } if (eff == PipeCrossGradient) { rgb = qRgb(rcb - rSign * QMIN(xtable[0][x], ytable[0][y]) * 2, gcb - gSign * QMIN(xtable[1][x], ytable[1][y]) * 2, bcb - bSign * QMIN(xtable[2][x], ytable[2][y]) * 2); } if (eff == EllipticGradient) { rgb = qRgb(rcb - rSign * (int)sqrt((xtable[0][x]*xtable[0][x] + ytable[0][y]*ytable[0][y])*2.0), gcb - gSign * (int)sqrt((xtable[1][x]*xtable[1][x] + ytable[1][y]*ytable[1][y])*2.0), bcb - bSign * (int)sqrt((xtable[2][x]*xtable[2][x] + ytable[2][y]*ytable[2][y])*2.0)); } sl1[x] = sl2[x] = rgb; sl1[x2] = sl2[x2] = rgb; } } } delete [] xtable[0]; delete [] xtable[1]; delete [] xtable[2]; delete [] ytable[0]; delete [] ytable[1]; delete [] ytable[2]; } // dither if necessary if (ncols && (QPixmap::defaultDepth() < 15 )) { if ( ncols < 2 || ncols > 256 ) ncols = 3; QColor *dPal = new QColor[ncols]; for (int i=0; i<ncols; i++) { dPal[i].setRgb ( rca + rDiff * i / ( ncols - 1 ), gca + gDiff * i / ( ncols - 1 ), bca + bDiff * i / ( ncols - 1 ) ); } dither(image, dPal, ncols); delete [] dPal; } return image; } // ----------------------------------------------------------------------------- //CT this was (before Dirk A. Mueller's speedup changes) // merely the same code as in the above method, but it's supposedly // way less performant since it introduces a lot of supplementary tests // and simple math operations for the calculus of the balance. // (surprizingly, it isn't less performant, in the contrary :-) // Yes, I could have merged them, but then the excellent performance of // the balanced code would suffer with no other gain than a mere // source code and byte code size economy. QImage OImageEffect::unbalancedGradient(const QSize &size, const QColor &ca, const QColor &cb, GradientType eff, int xfactor, int yfactor, int ncols) { int dir; // general parameter used for direction switches bool _xanti = false , _yanti = false; if (xfactor < 0) _xanti = true; // negative on X direction if (yfactor < 0) _yanti = true; // negative on Y direction xfactor = abs(xfactor); yfactor = abs(yfactor); if (!xfactor) xfactor = 1; if (!yfactor) yfactor = 1; if (xfactor > 200 ) xfactor = 200; if (yfactor > 200 ) yfactor = 200; // float xbal = xfactor/5000.; // float ybal = yfactor/5000.; float xbal = xfactor/30./size.width(); float ybal = yfactor/30./size.height(); float rat; int rDiff, gDiff, bDiff; int rca, gca, bca, rcb, gcb, bcb; QImage image(size, 32); if (size.width() == 0 || size.height() == 0) { qDebug( "WARNING: OImageEffect::unbalancedGradient : invalid image" ); return image; } register int x, y; unsigned int *scanline; rDiff = (rcb = cb.red()) - (rca = ca.red()); gDiff = (gcb = cb.green()) - (gca = ca.green()); bDiff = (bcb = cb.blue()) - (bca = ca.blue()); if( eff == VerticalGradient || eff == HorizontalGradient){ QColor cRow; uint *p; uint rgbRow; if( eff == VerticalGradient) { for ( y = 0; y < size.height(); y++ ) { dir = _yanti ? y : size.height() - 1 - y; p = (uint *) image.scanLine(dir); rat = 1 - exp( - (float)y * ybal ); cRow.setRgb( rcb - (int) ( rDiff * rat ), gcb - (int) ( gDiff * rat ), bcb - (int) ( bDiff * rat ) ); rgbRow = cRow.rgb(); for( x = 0; x < size.width(); x++ ) { *p = rgbRow; p++; } } } else { unsigned int *src = (unsigned int *)image.scanLine(0); for(x = 0; x < size.width(); x++ ) { dir = _xanti ? x : size.width() - 1 - x; rat = 1 - exp( - (float)x * xbal ); src[dir] = qRgb(rcb - (int) ( rDiff * rat ), gcb - (int) ( gDiff * rat ), bcb - (int) ( bDiff * rat )); } // Believe it or not, manually copying in a for loop is faster // than calling memcpy for each scanline (on the order of ms...). // I think this is due to the function call overhead (mosfet). for(y = 1; y < size.height(); ++y) { scanline = (unsigned int *)image.scanLine(y); for(x=0; x < size.width(); ++x) scanline[x] = src[x]; } } } else { int w=size.width(), h=size.height(); unsigned char *xtable[3]; unsigned char *ytable[3]; xtable[0] = new unsigned char[w]; xtable[1] = new unsigned char[w]; xtable[2] = new unsigned char[w]; ytable[0] = new unsigned char[h]; ytable[1] = new unsigned char[h]; ytable[2] = new unsigned char[h]; if ( eff == DiagonalGradient || eff == CrossDiagonalGradient) { for (x = 0; x < w; x++) { dir = _xanti ? x : w - 1 - x; rat = 1 - exp( - (float)x * xbal ); xtable[0][dir] = (unsigned char) ( rDiff/2 * rat ); xtable[1][dir] = (unsigned char) ( gDiff/2 * rat ); xtable[2][dir] = (unsigned char) ( bDiff/2 * rat ); } for (y = 0; y < h; y++) { dir = _yanti ? y : h - 1 - y; rat = 1 - exp( - (float)y * ybal ); ytable[0][dir] = (unsigned char) ( rDiff/2 * rat ); ytable[1][dir] = (unsigned char) ( gDiff/2 * rat ); ytable[2][dir] = (unsigned char) ( bDiff/2 * rat ); } for (y = 0; y < h; y++) { unsigned int *scanline = (unsigned int *)image.scanLine(y); for (x = 0; x < w; x++) { scanline[x] = qRgb(rcb - (xtable[0][x] + ytable[0][y]), gcb - (xtable[1][x] + ytable[1][y]), bcb - (xtable[2][x] + ytable[2][y])); } } } else if (eff == RectangleGradient || eff == PyramidGradient || eff == PipeCrossGradient || eff == EllipticGradient) { int rSign = rDiff>0? 1: -1; int gSign = gDiff>0? 1: -1; int bSign = bDiff>0? 1: -1; for (x = 0; x < w; x++) { dir = _xanti ? x : w - 1 - x; rat = 1 - exp( - (float)x * xbal ); xtable[0][dir] = (unsigned char) abs((int)(rDiff*(0.5-rat))); xtable[1][dir] = (unsigned char) abs((int)(gDiff*(0.5-rat))); xtable[2][dir] = (unsigned char) abs((int)(bDiff*(0.5-rat))); } for (y = 0; y < h; y++) { dir = _yanti ? y : h - 1 - y; rat = 1 - exp( - (float)y * ybal ); ytable[0][dir] = (unsigned char) abs((int)(rDiff*(0.5-rat))); ytable[1][dir] = (unsigned char) abs((int)(gDiff*(0.5-rat))); ytable[2][dir] = (unsigned char) abs((int)(bDiff*(0.5-rat))); } for (y = 0; y < h; y++) { unsigned int *scanline = (unsigned int *)image.scanLine(y); for (x = 0; x < w; x++) { if (eff == PyramidGradient) { scanline[x] = qRgb(rcb-rSign*(xtable[0][x]+ytable[0][y]), gcb-gSign*(xtable[1][x]+ytable[1][y]), bcb-bSign*(xtable[2][x]+ytable[2][y])); } if (eff == RectangleGradient) { scanline[x] = qRgb(rcb - rSign * QMAX(xtable[0][x], ytable[0][y]) * 2, gcb - gSign * QMAX(xtable[1][x], ytable[1][y]) * 2, bcb - bSign * QMAX(xtable[2][x], ytable[2][y]) * 2); } if (eff == PipeCrossGradient) { scanline[x] = qRgb(rcb - rSign * QMIN(xtable[0][x], ytable[0][y]) * 2, gcb - gSign * QMIN(xtable[1][x], ytable[1][y]) * 2, bcb - bSign * QMIN(xtable[2][x], ytable[2][y]) * 2); } if (eff == EllipticGradient) { scanline[x] = qRgb(rcb - rSign * (int)sqrt((xtable[0][x]*xtable[0][x] + ytable[0][y]*ytable[0][y])*2.0), gcb - gSign * (int)sqrt((xtable[1][x]*xtable[1][x] + ytable[1][y]*ytable[1][y])*2.0), bcb - bSign * (int)sqrt((xtable[2][x]*xtable[2][x] + ytable[2][y]*ytable[2][y])*2.0)); } } } } if (ncols && (QPixmap::defaultDepth() < 15 )) { if ( ncols < 2 || ncols > 256 ) ncols = 3; QColor *dPal = new QColor[ncols]; for (int i=0; i<ncols; i++) { dPal[i].setRgb ( rca + rDiff * i / ( ncols - 1 ), gca + gDiff * i / ( ncols - 1 ), bca + bDiff * i / ( ncols - 1 ) ); } dither(image, dPal, ncols); delete [] dPal; } delete [] xtable[0]; delete [] xtable[1]; delete [] xtable[2]; delete [] ytable[0]; delete [] ytable[1]; delete [] ytable[2]; } return image; } //====================================================================== // // Intensity effects // //====================================================================== /* This builds a 256 byte unsigned char lookup table with all * the possible percent values prior to applying the effect, then uses * integer math for the pixels. For any image larger than 9x9 this will be * less expensive than doing a float operation on the 3 color components of * each pixel. (mosfet) */ QImage& OImageEffect::intensity(QImage &image, float percent) { if (image.width() == 0 || image.height() == 0) { qDebug( "WARNING: OImageEffect::intensity : invalid image" ); return image; } int segColors = image.depth() > 8 ? 256 : image.numColors(); unsigned char *segTbl = new unsigned char[segColors]; int pixels = image.depth() > 8 ? image.width()*image.height() : image.numColors(); unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : (unsigned int *)image.colorTable(); bool brighten = (percent >= 0); if(percent < 0) percent = -percent; if(brighten){ // keep overflow check out of loops for(int i=0; i < segColors; ++i){ int tmp = (int)(i*percent); if(tmp > 255) tmp = 255; segTbl[i] = tmp; } } else{ for(int i=0; i < segColors; ++i){ int tmp = (int)(i*percent); if(tmp < 0) tmp = 0; segTbl[i] = tmp; } } if(brighten){ // same here for(int i=0; i < pixels; ++i){ int r = qRed(data[i]); int g = qGreen(data[i]); int b = qBlue(data[i]); int a = qAlpha(data[i]); r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; data[i] = qRgba(r, g, b,a); } } else{ for(int i=0; i < pixels; ++i){ int r = qRed(data[i]); int g = qGreen(data[i]); int b = qBlue(data[i]); int a = qAlpha(data[i]); r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; data[i] = qRgba(r, g, b, a); } } delete [] segTbl; return image; } QImage& OImageEffect::channelIntensity(QImage &image, float percent, RGBComponent channel) { if (image.width() == 0 || image.height() == 0) { qDebug( "WARNING: OImageEffect::channelIntensity : invalid image" ); return image; } int segColors = image.depth() > 8 ? 256 : image.numColors(); unsigned char *segTbl = new unsigned char[segColors]; int pixels = image.depth() > 8 ? image.width()*image.height() : image.numColors(); unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : (unsigned int *)image.colorTable(); bool brighten = (percent >= 0); if(percent < 0) percent = -percent; if(brighten){ // keep overflow check out of loops for(int i=0; i < segColors; ++i){ int tmp = (int)(i*percent); if(tmp > 255) tmp = 255; segTbl[i] = tmp; } } else{ for(int i=0; i < segColors; ++i){ int tmp = (int)(i*percent); if(tmp < 0) tmp = 0; segTbl[i] = tmp; } } if(brighten){ // same here if(channel == Red){ // and here ;-) for(int i=0; i < pixels; ++i){ int c = qRed(data[i]); c = c + segTbl[c] > 255 ? 255 : c + segTbl[c]; data[i] = qRgba(c, qGreen(data[i]), qBlue(data[i]), qAlpha(data[i])); } } if(channel == Green){ for(int i=0; i < pixels; ++i){ int c = qGreen(data[i]); c = c + segTbl[c] > 255 ? 255 : c + segTbl[c]; data[i] = qRgba(qRed(data[i]), c, qBlue(data[i]), qAlpha(data[i])); } } else{ for(int i=0; i < pixels; ++i){ int c = qBlue(data[i]); c = c + segTbl[c] > 255 ? 255 : c + segTbl[c]; data[i] = qRgba(qRed(data[i]), qGreen(data[i]), c, qAlpha(data[i])); } } } else{ if(channel == Red){ for(int i=0; i < pixels; ++i){ int c = qRed(data[i]); c = c - segTbl[c] < 0 ? 0 : c - segTbl[c]; data[i] = qRgba(c, qGreen(data[i]), qBlue(data[i]), qAlpha(data[i])); } } if(channel == Green){ for(int i=0; i < pixels; ++i){ int c = qGreen(data[i]); c = c - segTbl[c] < 0 ? 0 : c - segTbl[c]; data[i] = qRgba(qRed(data[i]), c, qBlue(data[i]), qAlpha(data[i])); } } else{ for(int i=0; i < pixels; ++i){ int c = qBlue(data[i]); c = c - segTbl[c] < 0 ? 0 : c - segTbl[c]; data[i] = qRgba(qRed(data[i]), qGreen(data[i]), c, qAlpha(data[i])); } } } delete [] segTbl; return image; } // Modulate an image with an RBG channel of another image // QImage& OImageEffect::modulate(QImage &image, QImage &modImage, bool reverse, ModulationType type, int factor, RGBComponent channel) { if (image.width() == 0 || image.height() == 0 || modImage.width() == 0 || modImage.height() == 0) { qDebug( "WARNING: OImageEffect::modulate : invalid image" ); return image; } int r, g, b, h, s, v, a; QColor clr; int mod=0; unsigned int x1, x2, y1, y2; register int x, y; // for image, we handle only depth 32 if (image.depth()<32) image = image.convertDepth(32); // for modImage, we handle depth 8 and 32 if (modImage.depth()<8) modImage = modImage.convertDepth(8); unsigned int *colorTable2 = (modImage.depth()==8) ? modImage.colorTable():0; unsigned int *data1, *data2; unsigned char *data2b; unsigned int color1, color2; x1 = image.width(); y1 = image.height(); x2 = modImage.width(); y2 = modImage.height(); for (y = 0; y < (int)y1; y++) { data1 = (unsigned int *) image.scanLine(y); data2 = (unsigned int *) modImage.scanLine( y%y2 ); data2b = (unsigned char *) modImage.scanLine( y%y2 ); x=0; while(x < (int)x1) { color2 = (colorTable2) ? colorTable2[*data2b] : *data2; if (reverse) { color1 = color2; color2 = *data1; } else color1 = *data1; if (type == Intensity || type == Contrast) { r = qRed(color1); g = qGreen(color1); b = qBlue(color1); if (channel != All) { mod = (channel == Red) ? qRed(color2) : (channel == Green) ? qGreen(color2) : (channel == Blue) ? qBlue(color2) : (channel == Gray) ? qGray(color2) : 0; mod = mod*factor/50; } if (type == Intensity) { if (channel == All) { r += r * factor/50 * qRed(color2)/256; g += g * factor/50 * qGreen(color2)/256; b += b * factor/50 * qBlue(color2)/256; } else { r += r * mod/256; g += g * mod/256; b += b * mod/256; } } else { // Contrast if (channel == All) { r += (r-128) * factor/50 * qRed(color2)/128; g += (g-128) * factor/50 * qGreen(color2)/128; b += (b-128) * factor/50 * qBlue(color2)/128; } else { r += (r-128) * mod/128; g += (g-128) * mod/128; b += (b-128) * mod/128; } } if (r<0) r=0; if (r>255) r=255; |