diff --git a/lib/jkqtcommon/jkqtpbasicimagetools.cpp b/lib/jkqtcommon/jkqtpbasicimagetools.cpp index e2d60fe80c..7b5a47f257 100644 --- a/lib/jkqtcommon/jkqtpbasicimagetools.cpp +++ b/lib/jkqtcommon/jkqtpbasicimagetools.cpp @@ -2168,8 +2168,10 @@ QImage JKQTPImageTools::GetPaletteImage(int i, int width) QImage JKQTPImageTools::GetPaletteImage(int i, int width, int height) { QImage img; - QVector pic(width*height,0); - for (int j=0; j(jkqtp_bounded(0, width*height, std::numeric_limits::max())); + + QVector pic(NPixels,0); + for (int j=0; j(pic.data(), width, height, img, static_cast(i), Qt::black, Qt::black); diff --git a/lib/jkqtcommon/jkqtpbasicimagetools.h b/lib/jkqtcommon/jkqtpbasicimagetools.h index f73528e6fe..40ec3d60bd 100644 --- a/lib/jkqtcommon/jkqtpbasicimagetools.h +++ b/lib/jkqtcommon/jkqtpbasicimagetools.h @@ -30,6 +30,7 @@ #include #include #include +#include #include "jkqtcommon/jkqtcommon_imexport.h" #include "jkqtcommon/jkqtpmathtools.h" @@ -482,11 +483,12 @@ struct JKQTPImageTools { if (!dbl_in || width<=0 || height<=0) return; + const long NPixels= width*height; double min = *dbl_in; double max = *dbl_in; if (jkqtp_approximatelyEqual(minColor, maxColor, JKQTP_DOUBLE_EPSILON)) { bool first=true; - for (int i=1; i(v)) || std::isinf(static_cast(v)))) { @@ -511,8 +513,8 @@ struct JKQTPImageTools { QVector dbl1; if (logScale) { double logB=log10(logBase); - dbl1=QVector(width*height, 0); - for (int i=0; i(jkqtp_bounded(NPixels), 0); + for (int i=0; i(trueColor.red()*trueColor.alphaF()), jkqtp_roundTo(trueColor.green()*trueColor.alphaF()), jkqtp_roundTo(trueColor.blue()*trueColor.alphaF()), trueColor.alpha()); - QRgb fc=qRgba(jkqtp_roundTo(falseColor.red()*falseColor.alphaF()), jkqtp_roundTo(falseColor.green()*falseColor.alphaF()), jkqtp_roundTo(falseColor.blue()*falseColor.alphaF()), falseColor.alpha()); + const QRgb tc=qRgba(jkqtp_roundTo(trueColor.redF()*trueColor.alphaF()*255.0), jkqtp_roundTo(trueColor.greenF()*trueColor.alphaF()*255.0), jkqtp_roundTo(trueColor.blueF()*trueColor.alphaF()*255.0), trueColor.alpha()); + const QRgb fc=qRgba(jkqtp_roundTo(falseColor.redF()*falseColor.alphaF()*255.0), jkqtp_roundTo(falseColor.greenF()*falseColor.alphaF()*255.0), jkqtp_roundTo(falseColor.blueF()*falseColor.alphaF()*255.0), falseColor.alpha()); for (int32_t y=0; y pic(static_cast(width), 0.0); + std::vector pic(width, 0.0); for (size_t j=0; j(pic.data(), static_cast(width), 1, img, static_cast(i), 0, width-1); + JKQTPImageTools::array2image(pic.data(), jkqtp_bounded(width), 1, img, static_cast(i), 0, width-1); return img; } @@ -296,9 +296,10 @@ QImage JKQTPColorPaletteStyleAndToolsMixin::getPaletteKeyImage(int i, size_t wid const double w2x=double(width*width)/(8.0*8.0); const double w2y=double(height*height)/(8.0*8.0); - std::vector pic(width*height, 0.0); + const size_t NPixels=jkqtp_bounded(width*height); + std::vector pic(NPixels, 0.0); double mmax=0; - for (size_t j=0; j