SVN commit 623707 by cgilles:
digiKam from trunk : Image Editor : fix color managed view rendering in all pixels based correction plugins (like blur/sharepn tools). CCMAIL: [hidden email] M +30 -33 imageregionwidget.cpp M +6 -7 imageregionwidget.h --- trunk/extragear/graphics/digikam/libs/widgets/imageplugins/imageregionwidget.cpp #623706:623707 @@ -55,7 +55,6 @@ { iface = 0; movingInProgress = false; - pixmap = 0; pixmapRegion = 0; zoomFactor = 1.0; separateView = ImageRegionWidget::SeparateViewVertical; @@ -69,12 +68,12 @@ double zoomFactor; - QPixmap *pixmap; // Entire content widget pixmap. + QPixmap pixmap; // Entire content widget pixmap. QPixmap *pixmapRegion; // Pixmap of current region to render. QPointArray hightlightPoints; - QImage image; // Entire content image to render pixmap. + DImg image; // Entire content image to render pixmap. ImageIface *iface; }; @@ -100,7 +99,6 @@ ImageRegionWidget::~ImageRegionWidget() { if (d->iface) delete d->iface; - if (d->pixmap) delete d->pixmap; if (d->pixmapRegion) delete d->pixmapRegion; delete d; } @@ -110,14 +108,14 @@ QPoint currentPos((int)(contentsX() / d->zoomFactor), (int)(contentsY() / d->zoomFactor)); kapp->setOverrideCursor( KCursor::waitCursor() ); - d->image = d->iface->getOriginalImg()->copyQImage(); + d->image = d->iface->getOriginalImg()->copy(); d->zoomFactor = factor; if(d->zoomFactor != 1.0) { - QImage img = d->image.scale((uint)(d->image.width() * d->zoomFactor), - (uint)(d->image.height() * d->zoomFactor)); + DImg img = d->image.smoothScale((uint)(d->image.width() * d->zoomFactor), + (uint)(d->image.height() * d->zoomFactor)); d->image = img; } @@ -160,7 +158,7 @@ updatePixmap(d->image); } -void ImageRegionWidget::updatePixmap(const QImage& img) +void ImageRegionWidget::updatePixmap(DImg& img) { horizontalScrollBar()->setLineStep( 1 ); horizontalScrollBar()->setPageStep( 1 ); @@ -170,38 +168,31 @@ int w = img.width(); int h = img.height(); - if (d->pixmap) - { - delete d->pixmap; - d->pixmap = 0; - } - switch (d->separateView) { case SeparateViewVertical: case SeparateViewHorizontal: case SeparateViewNone: { - d->pixmap = new QPixmap(w, h); - d->pixmap->convertFromImage(img); + d->pixmap = d->iface->convertToPixmap(img); resizeContents(w, h); break; } case SeparateViewDuplicateVert: { - QPixmap pix(img); - d->pixmap = new QPixmap(w+visibleWidth()/2, h); - d->pixmap->fill(paletteBackgroundColor().rgb()); - copyBlt( d->pixmap, 0, 0, &pix, 0, 0, w, h ); + QPixmap pix = d->iface->convertToPixmap(img); + d->pixmap = QPixmap(w+visibleWidth()/2, h); + d->pixmap.fill(paletteBackgroundColor().rgb()); + copyBlt( &d->pixmap, 0, 0, &pix, 0, 0, w, h ); resizeContents(w+visibleWidth()/2, h); break; } case SeparateViewDuplicateHorz: { - QPixmap pix(img); - d->pixmap = new QPixmap(w, h+visibleHeight()/2); - d->pixmap->fill(paletteBackgroundColor().rgb()); - copyBlt( d->pixmap, 0, 0, &pix, 0, 0, w, h ); + QPixmap pix = d->iface->convertToPixmap(img); + d->pixmap = QPixmap(w, h+visibleHeight()/2); + d->pixmap.fill(paletteBackgroundColor().rgb()); + copyBlt( &d->pixmap, 0, 0, &pix, 0, 0, w, h ); resizeContents(w, h+visibleHeight()/2); break; } @@ -214,8 +205,7 @@ void ImageRegionWidget::drawContents(QPainter *p, int x, int y, int w, int h) { - if(!d->pixmap) return; - else p->drawPixmap(x, y, *d->pixmap, x, y, w, h); + p->drawPixmap(x, y, d->pixmap, x, y, w, h); if (!d->movingInProgress) { @@ -354,25 +344,32 @@ void ImageRegionWidget::backupPixmapRegion(void) { if (d->pixmapRegion) delete d->pixmapRegion; - QRect area = getLocalTargetImageRegion(); + QRect area = getLocalTargetImageRegion(); d->pixmapRegion = new QPixmap(area.size()); - copyBlt( d->pixmapRegion, 0, 0, d->pixmap, area.x(), area.y(), area.width(), area.height() ); + copyBlt( d->pixmapRegion, 0, 0, &d->pixmap, area.x(), area.y(), area.width(), area.height() ); } void ImageRegionWidget::restorePixmapRegion(void) { if (!d->pixmapRegion) return; QRect area = getLocalTargetImageRegion(); - copyBlt( d->pixmap, area.x(), area.y(), d->pixmapRegion, 0, 0, area.width(), area.height() ); + copyBlt( &d->pixmap, area.x(), area.y(), d->pixmapRegion, 0, 0, area.width(), area.height() ); } void ImageRegionWidget::updatePreviewImage(DImg *img) { - QImage image = img->copyQImage(); - QPixmap pix( image.scale((uint)(image.width() * d->zoomFactor), - (uint)(image.height() * d->zoomFactor))); + DImg image = img->copy(); + + // Because image plugins are tool witch only work on image data, the DImg container + // do not contain metadata from original image. About Color Managed View, we need to + // restore the embedded ICC color profile. + image.setICCProfil(d->image.getICCProfil()); + + image.resize((uint)(image.width() * d->zoomFactor), + (uint)(image.height() * d->zoomFactor)); + QPixmap pix = d->iface->convertToPixmap(image); QRect area = getLocalTargetImageRegion(); - copyBlt( d->pixmap, area.x(), area.y(), &pix, 0, 0, area.width(), area.height() ); + copyBlt( &d->pixmap, area.x(), area.y(), &pix, 0, 0, area.width(), area.height() ); } DImg ImageRegionWidget::getImageRegionImage(void) --- trunk/extragear/graphics/digikam/libs/widgets/imageplugins/imageregionwidget.h #623706:623707 @@ -25,7 +25,6 @@ #include <qscrollview.h> #include <qrect.h> -#include <qimage.h> // Local includes @@ -83,16 +82,16 @@ protected: - void viewportResizeEvent( QResizeEvent *e ); - void contentsMousePressEvent ( QMouseEvent * e ); - void contentsMouseReleaseEvent ( QMouseEvent * e ); - void contentsMouseMoveEvent( QMouseEvent * e ); - void contentsWheelEvent( QWheelEvent * e ){ e->accept(); }; + void viewportResizeEvent(QResizeEvent*); + void contentsMousePressEvent(QMouseEvent*); + void contentsMouseReleaseEvent(QMouseEvent*); + void contentsMouseMoveEvent(QMouseEvent*); + void contentsWheelEvent(QWheelEvent *e){ e->accept(); }; private: void drawContents(QPainter *p, int x, int y, int w, int h); - void updatePixmap(const QImage& img); + void updatePixmap(DImg& img); QRect getLocalTargetImageRegion(void); QRect getLocalImageRegionToRender(void); _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |