author | mickeyl <mickeyl> | 2003-12-20 17:47:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-12-20 17:47:08 (UTC) |
commit | d552ce3a94b53ae0fdb226411bd8f9e5bab6596a (patch) (side-by-side diff) | |
tree | ca9f1edd3ed945c98a6cd4587a5094fe9b2b3d36 /libopie2/opieui/oimageeffect.cpp | |
parent | 8e96eec63c67cfcd1fb202fe7346e5408a142f2e (diff) | |
download | opie-d552ce3a94b53ae0fdb226411bd8f9e5bab6596a.zip opie-d552ce3a94b53ae0fdb226411bd8f9e5bab6596a.tar.gz opie-d552ce3a94b53ae0fdb226411bd8f9e5bab6596a.tar.bz2 |
- start cleaning up (lot of stuff left)
- use odebug classes
Diffstat (limited to 'libopie2/opieui/oimageeffect.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opieui/oimageeffect.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/libopie2/opieui/oimageeffect.cpp b/libopie2/opieui/oimageeffect.cpp index 01e7c6f..9a58bb9 100644 --- a/libopie2/opieui/oimageeffect.cpp +++ b/libopie2/opieui/oimageeffect.cpp @@ -31,13 +31,14 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <math.h> #include <qimage.h> #include <stdlib.h> -#include "oimageeffect.h" +#include <opie2/oimageeffect.h> +#include <opie2/odebug.h> #define MaxRGB 255L #define DegreesToRadians(x) ((x)*M_PI/180.0) using namespace std; @@ -60,13 +61,13 @@ QImage OImageEffect::gradient(const QSize &size, const QColor &ca, 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" ); + odebug << "WARNING: OImageEffect::gradient: invalid image" << oendl; return image; } register int x, y; rDiff = (rcb = cb.red()) - (rca = ca.red()); @@ -346,13 +347,13 @@ QImage OImageEffect::unbalancedGradient(const QSize &size, const QColor &ca, 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" ); + odebug << "WARNING: OImageEffect::unbalancedGradient : invalid image" << oendl; return image; } register int x, y; unsigned int *scanline; @@ -565,13 +566,13 @@ QImage OImageEffect::unbalancedGradient(const QSize &size, const QColor &ca, * each pixel. (mosfet) */ QImage& OImageEffect::intensity(QImage &image, float percent) { if (image.width() == 0 || image.height() == 0) { - qDebug( "WARNING: OImageEffect::intensity : invalid image" ); + odebug << "WARNING: OImageEffect::intensity : invalid image" << oendl; 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() : @@ -630,13 +631,13 @@ QImage& OImageEffect::intensity(QImage &image, float percent) } QImage& OImageEffect::channelIntensity(QImage &image, float percent, RGBComponent channel) { if (image.width() == 0 || image.height() == 0) { - qDebug( "WARNING: OImageEffect::channelIntensity : invalid image" ); + odebug << "WARNING: OImageEffect::channelIntensity : invalid image" << oendl; 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() : @@ -720,13 +721,13 @@ QImage& OImageEffect::channelIntensity(QImage &image, float percent, // 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" ); + odebug << "WARNING: OImageEffect::modulate : invalid image" << oendl; return image; } int r, g, b, h, s, v, a; QColor clr; int mod=0; @@ -849,13 +850,13 @@ QImage& OImageEffect::modulate(QImage &image, QImage &modImage, bool reverse, QImage& OImageEffect::blend(const QColor& clr, QImage& dst, float opacity) { if (dst.width() <= 0 || dst.height() <= 0) return dst; if (opacity < 0.0 || opacity > 1.0) { - qDebug( "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1] "); + odebug << "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1] " << oendl; return dst; } int depth = dst.depth(); if (depth != 32) dst = dst.convertDepth(32); @@ -892,18 +893,18 @@ QImage& OImageEffect::blend(QImage& src, QImage& dst, float opacity) if (src.width() <= 0 || src.height() <= 0) return dst; if (dst.width() <= 0 || dst.height() <= 0) return dst; if (src.width() != dst.width() || src.height() != dst.height()) { - qDebug( "WARNING: OImageEffect::blend : src and destination images are not the same size" ); + odebug << "WARNING: OImageEffect::blend : src and destination images are not the same size" << oendl; return dst; } if (opacity < 0.0 || opacity > 1.0) { - qDebug( "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1]" ); + odebug << "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1]" << oendl; return dst; } if (src.depth() != 32) src = src.convertDepth(32); if (dst.depth() != 32) dst = dst.convertDepth(32); @@ -937,13 +938,13 @@ QImage& OImageEffect::blend(QImage& src, QImage& dst, float opacity) QImage& OImageEffect::blend(QImage &image, float initial_intensity, const QColor &bgnd, GradientType eff, bool anti_dir) { if (image.width() == 0 || image.height() == 0 || image.depth()!=32 ) { - qDebug( "WARNING: OImageEffect::blend : invalid image" ); + odebug << "WARNING: OImageEffect::blend : invalid image" << oendl; return image; } int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); int r, g, b; int ind; @@ -1130,13 +1131,13 @@ QImage& OImageEffect::blend(QImage &image, float initial_intensity, if (b > 255) b = 255; if (b < 0 ) b = 0; a = qAlpha(data[ind]); data[ind] = qRgba(r, g, b, a); } } } - else qDebug( "OImageEffect::blend effect not implemented" ); + else odebug << "OImageEffect::blend effect not implemented" << oendl; return image; } // Not very efficient as we create a third big image... // QImage& OImageEffect::blend(QImage &image1, QImage &image2, @@ -1160,13 +1161,13 @@ QImage& OImageEffect::blend(QImage &image1, QImage &image2, QImage& OImageEffect::blend(QImage &image1, QImage &image2, QImage &blendImage, RGBComponent channel) { if (image1.width() == 0 || image1.height() == 0 || image2.width() == 0 || image2.height() == 0 || blendImage.width() == 0 || blendImage.height() == 0) { - qDebug( "OImageEffect::blend effect invalid image" ); + odebug << "OImageEffect::blend effect invalid image" << oendl; return image1; } int r, g, b; int ind1, ind2, ind3; @@ -1258,13 +1259,13 @@ unsigned int OImageEffect::uHash(unsigned int c) // ----------------------------------------------------------------------------- QImage& OImageEffect::hash(QImage &image, Lighting lite, unsigned int spacing) { if (image.width() == 0 || image.height() == 0) { - qDebug( "OImageEffect::hash effect invalid image" ); + odebug << "OImageEffect::hash effect invalid image" << oendl; return image; } register int x, y; unsigned int *data = (unsigned int *)image.bits(); unsigned int ind; @@ -1766,13 +1767,13 @@ bool OImageEffect::blend( upper.width() > lower.width() || upper.height() > lower.height() || upper.depth() != 32 || lower.depth() != 32 ) { - qDebug( "OImageEffect::blend : Sizes not correct" ); + odebug << "OImageEffect::blend : Sizes not correct" << oendl; return false; } output = lower.copy(); register uchar *i, *o; @@ -1983,13 +1984,13 @@ void OImageEffect::normalize(QImage &img) unsigned int high, low; // allocate histogram and normalize map histogram = (int *)calloc(MaxRGB+1, sizeof(int)); normalize_map = (unsigned int *)malloc((MaxRGB+1)*sizeof(unsigned int)); if(!normalize_map || !histogram){ - qWarning("Unable to allocate normalize histogram and map"); + owarn << "Unable to allocate normalize histogram and map" << oendl; free(normalize_map); free(histogram); return; } // form histogram @@ -2099,13 +2100,13 @@ void OImageEffect::equalize(QImage &img) // allocate histogram and maps histogram = (int *)calloc(MaxRGB+1, sizeof(int)); map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int)); equalize_map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int)); if(!histogram || !map || !equalize_map){ - qWarning("Unable to allocate equalize histogram and maps"); + owarn << "Unable to allocate equalize histogram and maps" << oendl; free(histogram); free(map); free(equalize_map); return; } // form histogram @@ -2184,13 +2185,13 @@ QImage OImageEffect::sample(QImage &src, int w, int h) register int x; QImage dest(w, h, src.depth()); x_offset = (double *)malloc(w*sizeof(double)); y_offset = (double *)malloc(h*sizeof(double)); if(!x_offset || !y_offset){ - qWarning("Unable to allocate pixels buffer"); + owarn << "Unable to allocate pixels buffer" << oendl; free(x_offset); free(y_offset); return(src); } // init pixel offsets @@ -2202,13 +2203,13 @@ QImage OImageEffect::sample(QImage &src, int w, int h) // sample each row if(src.depth() > 8){ // DirectClass source image unsigned int *srcData, *destData; unsigned int *pixels; pixels = (unsigned int *)malloc(src.width()*sizeof(unsigned int)); if(!pixels){ - qWarning("Unable to allocate pixels buffer"); + owarn << "Unable to allocate pixels buffer" << oendl; free(pixels); free(x_offset); free(y_offset); return(src); } j = (-1); @@ -2230,13 +2231,13 @@ QImage OImageEffect::sample(QImage &src, int w, int h) } else{ // PsudeoClass source image unsigned char *srcData, *destData; unsigned char *pixels; pixels = (unsigned char *)malloc(src.width()*sizeof(unsigned char)); if(!pixels){ - qWarning("Unable to allocate pixels buffer"); + owarn << "Unable to allocate pixels buffer" << oendl; free(pixels); free(x_offset); free(y_offset); return(src); } // copy colortable @@ -3069,13 +3070,13 @@ QImage OImageEffect::wave(QImage &src, double amplitude, double wavelength, } QImage OImageEffect::oilPaint(QImage &src, int radius) { // TODO 8bpp src! if(src.depth() < 32){ - qWarning("Oil Paint source image < 32bpp. Convert before using!"); + owarn << "Oil Paint source image < 32bpp. Convert before using!" << oendl; return(src); } int j, k, i, x, y; unsigned int *histogram; unsigned int *s; unsigned int count; |