[Kst] branches/work/kst/portto4/kst/src/libkstmath
Mike Fenton
mike at staikos.net
Thu Dec 13 16:49:56 CET 2007
SVN commit 748093 by fenton:
Improve ColorMap drawing performance in Image by replacing setPixel with scanLine.
Fix output matrix creation of CSD.
M +1 -0 csd.cpp
M +9 -9 image.cpp
--- branches/work/kst/portto4/kst/src/libkstmath/csd.cpp #748092:748093
@@ -151,6 +151,7 @@
updateMatrixLabels();
_outMatrix->setDirty();
+ setDirty();
}
void CSD::commonConstructor(ObjectStore *store, VectorPtr in_V,
--- branches/work/kst/portto4/kst/src/libkstmath/image.cpp #748092:748093
@@ -634,29 +634,29 @@
}
// color map
+
QColor thisPixel;
if (image->hasColorMap()) {
int hXlXDiff = d2i(img_Hx_pix - img_Lx_pix);
int hYlYDiff = d2i(img_Hy_pix - img_Ly_pix - 1);
QImage tempImage(hXlXDiff, hYlYDiff, QImage::Format_RGB32);
- for (int i = 0; i < hXlXDiff; ++i) {
- for (int j = 0; j < hYlYDiff; ++j) {
+ for (int y = 0; y < tempImage.height(); ++y) {
+ QRgb *scanLine = (QRgb *)tempImage.scanLine(y);
+ for (int x = 0; x < tempImage.width(); ++x) {
double new_x, new_y;
if (xLog) {
- new_x = pow(xLogBase, (i + img_Lx_pix - b_X) / m_X);
+ new_x = pow(xLogBase, (x + img_Lx_pix - b_X) / m_X);
} else {
- new_x = (i + img_Lx_pix - b_X) / m_X;
+ new_x = (x + img_Lx_pix - b_X) / m_X;
}
if (yLog) {
- new_y = pow(yLogBase, (j + 1 + img_Ly_pix - b_Y) / m_Y);
+ new_y = pow(yLogBase, (y + 1 + img_Ly_pix - b_Y) / m_Y);
} else {
- new_y = (j + 1 + img_Ly_pix - b_Y) / m_Y;
+ new_y = (y + 1 + img_Ly_pix - b_Y) / m_Y;
}
thisPixel = image->getMappedColor(new_x, new_y);
if (thisPixel.isValid()) {
- tempImage.setPixel(i, j, thisPixel.rgb());
- } else {
- tempImage.setPixel(i, j, invalid.rgb());
+ scanLine[x] = thisPixel.rgb();
}
}
}
More information about the Kst
mailing list