Diffstat (limited to 'libopie2/opieui/oimageeffect.cpp') (more/less context) (ignore 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 | |||
@@ -33,9 +33,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
33 | 33 | ||
34 | #include <qimage.h> | 34 | #include <qimage.h> |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | 36 | ||
37 | #include "oimageeffect.h" | 37 | #include <opie2/oimageeffect.h> |
38 | #include <opie2/odebug.h> | ||
38 | 39 | ||
39 | #define MaxRGB 255L | 40 | #define MaxRGB 255L |
40 | #define DegreesToRadians(x) ((x)*M_PI/180.0) | 41 | #define DegreesToRadians(x) ((x)*M_PI/180.0) |
41 | 42 | ||
@@ -62,9 +63,9 @@ QImage OImageEffect::gradient(const QSize &size, const QColor &ca, | |||
62 | 63 | ||
63 | QImage image(size, 32); | 64 | QImage image(size, 32); |
64 | 65 | ||
65 | if (size.width() == 0 || size.height() == 0) { | 66 | if (size.width() == 0 || size.height() == 0) { |
66 | qDebug( "WARNING: OImageEffect::gradient: invalid image" ); | 67 | odebug << "WARNING: OImageEffect::gradient: invalid image" << oendl; |
67 | return image; | 68 | return image; |
68 | } | 69 | } |
69 | 70 | ||
70 | register int x, y; | 71 | register int x, y; |
@@ -348,9 +349,9 @@ QImage OImageEffect::unbalancedGradient(const QSize &size, const QColor &ca, | |||
348 | 349 | ||
349 | QImage image(size, 32); | 350 | QImage image(size, 32); |
350 | 351 | ||
351 | if (size.width() == 0 || size.height() == 0) { | 352 | if (size.width() == 0 || size.height() == 0) { |
352 | qDebug( "WARNING: OImageEffect::unbalancedGradient : invalid image" ); | 353 | odebug << "WARNING: OImageEffect::unbalancedGradient : invalid image" << oendl; |
353 | return image; | 354 | return image; |
354 | } | 355 | } |
355 | 356 | ||
356 | register int x, y; | 357 | register int x, y; |
@@ -567,9 +568,9 @@ QImage OImageEffect::unbalancedGradient(const QSize &size, const QColor &ca, | |||
567 | 568 | ||
568 | QImage& OImageEffect::intensity(QImage &image, float percent) | 569 | QImage& OImageEffect::intensity(QImage &image, float percent) |
569 | { | 570 | { |
570 | if (image.width() == 0 || image.height() == 0) { | 571 | if (image.width() == 0 || image.height() == 0) { |
571 | qDebug( "WARNING: OImageEffect::intensity : invalid image" ); | 572 | odebug << "WARNING: OImageEffect::intensity : invalid image" << oendl; |
572 | return image; | 573 | return image; |
573 | } | 574 | } |
574 | 575 | ||
575 | int segColors = image.depth() > 8 ? 256 : image.numColors(); | 576 | int segColors = image.depth() > 8 ? 256 : image.numColors(); |
@@ -632,9 +633,9 @@ QImage& OImageEffect::intensity(QImage &image, float percent) | |||
632 | QImage& OImageEffect::channelIntensity(QImage &image, float percent, | 633 | QImage& OImageEffect::channelIntensity(QImage &image, float percent, |
633 | RGBComponent channel) | 634 | RGBComponent channel) |
634 | { | 635 | { |
635 | if (image.width() == 0 || image.height() == 0) { | 636 | if (image.width() == 0 || image.height() == 0) { |
636 | qDebug( "WARNING: OImageEffect::channelIntensity : invalid image" ); | 637 | odebug << "WARNING: OImageEffect::channelIntensity : invalid image" << oendl; |
637 | return image; | 638 | return image; |
638 | } | 639 | } |
639 | 640 | ||
640 | int segColors = image.depth() > 8 ? 256 : image.numColors(); | 641 | int segColors = image.depth() > 8 ? 256 : image.numColors(); |
@@ -722,9 +723,9 @@ QImage& OImageEffect::modulate(QImage &image, QImage &modImage, bool reverse, | |||
722 | ModulationType type, int factor, RGBComponent channel) | 723 | ModulationType type, int factor, RGBComponent channel) |
723 | { | 724 | { |
724 | if (image.width() == 0 || image.height() == 0 || | 725 | if (image.width() == 0 || image.height() == 0 || |
725 | modImage.width() == 0 || modImage.height() == 0) { | 726 | modImage.width() == 0 || modImage.height() == 0) { |
726 | qDebug( "WARNING: OImageEffect::modulate : invalid image" ); | 727 | odebug << "WARNING: OImageEffect::modulate : invalid image" << oendl; |
727 | return image; | 728 | return image; |
728 | } | 729 | } |
729 | 730 | ||
730 | int r, g, b, h, s, v, a; | 731 | int r, g, b, h, s, v, a; |
@@ -851,9 +852,9 @@ QImage& OImageEffect::blend(const QColor& clr, QImage& dst, float opacity) | |||
851 | if (dst.width() <= 0 || dst.height() <= 0) | 852 | if (dst.width() <= 0 || dst.height() <= 0) |
852 | return dst; | 853 | return dst; |
853 | 854 | ||
854 | if (opacity < 0.0 || opacity > 1.0) { | 855 | if (opacity < 0.0 || opacity > 1.0) { |
855 | qDebug( "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1] "); | 856 | odebug << "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1] " << oendl; |
856 | return dst; | 857 | return dst; |
857 | } | 858 | } |
858 | 859 | ||
859 | int depth = dst.depth(); | 860 | int depth = dst.depth(); |
@@ -894,14 +895,14 @@ QImage& OImageEffect::blend(QImage& src, QImage& dst, float opacity) | |||
894 | if (dst.width() <= 0 || dst.height() <= 0) | 895 | if (dst.width() <= 0 || dst.height() <= 0) |
895 | return dst; | 896 | return dst; |
896 | 897 | ||
897 | if (src.width() != dst.width() || src.height() != dst.height()) { | 898 | if (src.width() != dst.width() || src.height() != dst.height()) { |
898 | qDebug( "WARNING: OImageEffect::blend : src and destination images are not the same size" ); | 899 | odebug << "WARNING: OImageEffect::blend : src and destination images are not the same size" << oendl; |
899 | return dst; | 900 | return dst; |
900 | } | 901 | } |
901 | 902 | ||
902 | if (opacity < 0.0 || opacity > 1.0) { | 903 | if (opacity < 0.0 || opacity > 1.0) { |
903 | qDebug( "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1]" ); | 904 | odebug << "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1]" << oendl; |
904 | return dst; | 905 | return dst; |
905 | } | 906 | } |
906 | 907 | ||
907 | if (src.depth() != 32) src = src.convertDepth(32); | 908 | if (src.depth() != 32) src = src.convertDepth(32); |
@@ -939,9 +940,9 @@ QImage& OImageEffect::blend(QImage &image, float initial_intensity, | |||
939 | const QColor &bgnd, GradientType eff, | 940 | const QColor &bgnd, GradientType eff, |
940 | bool anti_dir) | 941 | bool anti_dir) |
941 | { | 942 | { |
942 | if (image.width() == 0 || image.height() == 0 || image.depth()!=32 ) { | 943 | if (image.width() == 0 || image.height() == 0 || image.depth()!=32 ) { |
943 | qDebug( "WARNING: OImageEffect::blend : invalid image" ); | 944 | odebug << "WARNING: OImageEffect::blend : invalid image" << oendl; |
944 | return image; | 945 | return image; |
945 | } | 946 | } |
946 | 947 | ||
947 | int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); | 948 | int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); |
@@ -1132,9 +1133,9 @@ QImage& OImageEffect::blend(QImage &image, float initial_intensity, | |||
1132 | data[ind] = qRgba(r, g, b, a); | 1133 | data[ind] = qRgba(r, g, b, a); |
1133 | } | 1134 | } |
1134 | } | 1135 | } |
1135 | } | 1136 | } |
1136 | else qDebug( "OImageEffect::blend effect not implemented" ); | 1137 | else odebug << "OImageEffect::blend effect not implemented" << oendl; |
1137 | return image; | 1138 | return image; |
1138 | } | 1139 | } |
1139 | 1140 | ||
1140 | // Not very efficient as we create a third big image... | 1141 | // Not very efficient as we create a third big image... |
@@ -1162,9 +1163,9 @@ QImage& OImageEffect::blend(QImage &image1, QImage &image2, | |||
1162 | { | 1163 | { |
1163 | if (image1.width() == 0 || image1.height() == 0 || | 1164 | if (image1.width() == 0 || image1.height() == 0 || |
1164 | image2.width() == 0 || image2.height() == 0 || | 1165 | image2.width() == 0 || image2.height() == 0 || |
1165 | blendImage.width() == 0 || blendImage.height() == 0) { | 1166 | blendImage.width() == 0 || blendImage.height() == 0) { |
1166 | qDebug( "OImageEffect::blend effect invalid image" ); | 1167 | odebug << "OImageEffect::blend effect invalid image" << oendl; |
1167 | return image1; | 1168 | return image1; |
1168 | } | 1169 | } |
1169 | 1170 | ||
1170 | int r, g, b; | 1171 | int r, g, b; |
@@ -1260,9 +1261,9 @@ unsigned int OImageEffect::uHash(unsigned int c) | |||
1260 | 1261 | ||
1261 | QImage& OImageEffect::hash(QImage &image, Lighting lite, unsigned int spacing) | 1262 | QImage& OImageEffect::hash(QImage &image, Lighting lite, unsigned int spacing) |
1262 | { | 1263 | { |
1263 | if (image.width() == 0 || image.height() == 0) { | 1264 | if (image.width() == 0 || image.height() == 0) { |
1264 | qDebug( "OImageEffect::hash effect invalid image" ); | 1265 | odebug << "OImageEffect::hash effect invalid image" << oendl; |
1265 | return image; | 1266 | return image; |
1266 | } | 1267 | } |
1267 | 1268 | ||
1268 | register int x, y; | 1269 | register int x, y; |
@@ -1768,9 +1769,9 @@ bool OImageEffect::blend( | |||
1768 | upper.depth() != 32 || | 1769 | upper.depth() != 32 || |
1769 | lower.depth() != 32 | 1770 | lower.depth() != 32 |
1770 | ) | 1771 | ) |
1771 | { | 1772 | { |
1772 | qDebug( "OImageEffect::blend : Sizes not correct" ); | 1773 | odebug << "OImageEffect::blend : Sizes not correct" << oendl; |
1773 | return false; | 1774 | return false; |
1774 | } | 1775 | } |
1775 | 1776 | ||
1776 | output = lower.copy(); | 1777 | output = lower.copy(); |
@@ -1985,9 +1986,9 @@ void OImageEffect::normalize(QImage &img) | |||
1985 | // allocate histogram and normalize map | 1986 | // allocate histogram and normalize map |
1986 | histogram = (int *)calloc(MaxRGB+1, sizeof(int)); | 1987 | histogram = (int *)calloc(MaxRGB+1, sizeof(int)); |
1987 | normalize_map = (unsigned int *)malloc((MaxRGB+1)*sizeof(unsigned int)); | 1988 | normalize_map = (unsigned int *)malloc((MaxRGB+1)*sizeof(unsigned int)); |
1988 | if(!normalize_map || !histogram){ | 1989 | if(!normalize_map || !histogram){ |
1989 | qWarning("Unable to allocate normalize histogram and map"); | 1990 | owarn << "Unable to allocate normalize histogram and map" << oendl; |
1990 | free(normalize_map); | 1991 | free(normalize_map); |
1991 | free(histogram); | 1992 | free(histogram); |
1992 | return; | 1993 | return; |
1993 | } | 1994 | } |
@@ -2101,9 +2102,9 @@ void OImageEffect::equalize(QImage &img) | |||
2101 | map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int)); | 2102 | map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int)); |
2102 | equalize_map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int)); | 2103 | equalize_map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int)); |
2103 | 2104 | ||
2104 | if(!histogram || !map || !equalize_map){ | 2105 | if(!histogram || !map || !equalize_map){ |
2105 | qWarning("Unable to allocate equalize histogram and maps"); | 2106 | owarn << "Unable to allocate equalize histogram and maps" << oendl; |
2106 | free(histogram); | 2107 | free(histogram); |
2107 | free(map); | 2108 | free(map); |
2108 | free(equalize_map); | 2109 | free(equalize_map); |
2109 | return; | 2110 | return; |
@@ -2186,9 +2187,9 @@ QImage OImageEffect::sample(QImage &src, int w, int h) | |||
2186 | 2187 | ||
2187 | x_offset = (double *)malloc(w*sizeof(double)); | 2188 | x_offset = (double *)malloc(w*sizeof(double)); |
2188 | y_offset = (double *)malloc(h*sizeof(double)); | 2189 | y_offset = (double *)malloc(h*sizeof(double)); |
2189 | if(!x_offset || !y_offset){ | 2190 | if(!x_offset || !y_offset){ |
2190 | qWarning("Unable to allocate pixels buffer"); | 2191 | owarn << "Unable to allocate pixels buffer" << oendl; |
2191 | free(x_offset); | 2192 | free(x_offset); |
2192 | free(y_offset); | 2193 | free(y_offset); |
2193 | return(src); | 2194 | return(src); |
2194 | } | 2195 | } |
@@ -2204,9 +2205,9 @@ QImage OImageEffect::sample(QImage &src, int w, int h) | |||
2204 | unsigned int *srcData, *destData; | 2205 | unsigned int *srcData, *destData; |
2205 | unsigned int *pixels; | 2206 | unsigned int *pixels; |
2206 | pixels = (unsigned int *)malloc(src.width()*sizeof(unsigned int)); | 2207 | pixels = (unsigned int *)malloc(src.width()*sizeof(unsigned int)); |
2207 | if(!pixels){ | 2208 | if(!pixels){ |
2208 | qWarning("Unable to allocate pixels buffer"); | 2209 | owarn << "Unable to allocate pixels buffer" << oendl; |
2209 | free(pixels); | 2210 | free(pixels); |
2210 | free(x_offset); | 2211 | free(x_offset); |
2211 | free(y_offset); | 2212 | free(y_offset); |
2212 | return(src); | 2213 | return(src); |
@@ -2232,9 +2233,9 @@ QImage OImageEffect::sample(QImage &src, int w, int h) | |||
2232 | unsigned char *srcData, *destData; | 2233 | unsigned char *srcData, *destData; |
2233 | unsigned char *pixels; | 2234 | unsigned char *pixels; |
2234 | pixels = (unsigned char *)malloc(src.width()*sizeof(unsigned char)); | 2235 | pixels = (unsigned char *)malloc(src.width()*sizeof(unsigned char)); |
2235 | if(!pixels){ | 2236 | if(!pixels){ |
2236 | qWarning("Unable to allocate pixels buffer"); | 2237 | owarn << "Unable to allocate pixels buffer" << oendl; |
2237 | free(pixels); | 2238 | free(pixels); |
2238 | free(x_offset); | 2239 | free(x_offset); |
2239 | free(y_offset); | 2240 | free(y_offset); |
2240 | return(src); | 2241 | return(src); |
@@ -3071,9 +3072,9 @@ QImage OImageEffect::wave(QImage &src, double amplitude, double wavelength, | |||
3071 | QImage OImageEffect::oilPaint(QImage &src, int radius) | 3072 | QImage OImageEffect::oilPaint(QImage &src, int radius) |
3072 | { | 3073 | { |
3073 | // TODO 8bpp src! | 3074 | // TODO 8bpp src! |
3074 | if(src.depth() < 32){ | 3075 | if(src.depth() < 32){ |
3075 | qWarning("Oil Paint source image < 32bpp. Convert before using!"); | 3076 | owarn << "Oil Paint source image < 32bpp. Convert before using!" << oendl; |
3076 | return(src); | 3077 | return(src); |
3077 | } | 3078 | } |
3078 | int j, k, i, x, y; | 3079 | int j, k, i, x, y; |
3079 | unsigned int *histogram; | 3080 | unsigned int *histogram; |