Bug 143029 - Resizing an image make appearing a transparent border
Summary: Resizing an image make appearing a transparent border
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Camilla Boemann
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-15 22:38 UTC by Cyrille Berger
Modified: 2007-05-25 16:06 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cyrille Berger 2007-03-15 22:38:32 UTC
Version:           svn branch 1.6 and trunk (using KDE Devel)
Installed from:    Compiled sources

Open a picture, resize it, and then there is a transparent border.
Expected behaviour: no transparent pixel should appears
Comment 1 Camilla Boemann 2007-05-25 16:06:22 UTC
SVN commit 668216 by boemann:

Fix scale of image so it leaves no transparent borders.

BUG:143029


 M  +9 -4      core/kis_transform_worker.cc  
 M  +3 -2      core/kis_transform_worker.h  
 M  +1 -1      plugins/viewplugins/imagesize/imagesize.cc  


--- branches/koffice/1.6/koffice/krita/core/kis_transform_worker.cc #668215:668216
@@ -299,7 +299,7 @@
     ~FilterValues() {delete [] weight;}
 };
 
-template <class T> void KisTransformWorker::transformPass(KisPaintDevice *src, KisPaintDevice *dst, double floatscale, double shear, Q_INT32 dx, KisFilterStrategy *filterStrategy)
+template <class T> void KisTransformWorker::transformPass(KisPaintDevice *src, KisPaintDevice *dst, double floatscale, double shear, Q_INT32 dx, KisFilterStrategy *filterStrategy, bool fixBorderAlpha)
 {
     Q_INT32 lineNum,srcStart,firstLine,srcLen,numLines;
     Q_INT32 center, begin, end;    /* filter calculation variables */
@@ -484,6 +484,11 @@
                 }
                 data = dstIt.rawData();
                 cs->mixColors(colors, filterWeights[center&255].weight, filterWeights[center&255].numWeights, data);
+
+                //possibly fix the alpha of the border if user wants it
+                if(fixBorderAlpha && (i==0 || i==dstLen-1))
+                    cs->setAlpha(data, cs->alpha(&tmpLine[(center>>8)*pixelSize]), 1);
+
                 data = dstSelIt.rawData();
                 *data = selectedness;
             }
@@ -630,7 +635,7 @@
         return false;
     }
 
-    transformPass <KisHLineIteratorPixel>(srcdev, tmpdev2, xscale, yscale*xshear, 0, m_filter);
+    transformPass <KisHLineIteratorPixel>(srcdev, tmpdev2, xscale, yscale*xshear, 0, m_filter, m_fixBorderAlpha);
     if(m_dev->hasSelection())
         m_dev->selection()->clear();
 
@@ -640,7 +645,7 @@
     }
 
     // Now do the second pass
-    transformPass <KisVLineIteratorPixel>(tmpdev2.data(), tmpdev3.data(), yscale, yshear, ytranslate, m_filter);
+    transformPass <KisVLineIteratorPixel>(tmpdev2.data(), tmpdev3.data(), yscale, yshear, ytranslate, m_filter, m_fixBorderAlpha);
 
     if(m_dev->hasSelection())
         m_dev->selection()->clear();
@@ -651,7 +656,7 @@
     }
 
     if (xshear != 0.0)
-        transformPass <KisHLineIteratorPixel>(tmpdev3, m_dev, 1.0, xshear, xtranslate, m_filter);
+        transformPass <KisHLineIteratorPixel>(tmpdev3, m_dev, 1.0, xshear, xtranslate, m_filter, m_fixBorderAlpha);
     else
     {
         // No need to filter again when we are only scaling
--- branches/koffice/1.6/koffice/krita/core/kis_transform_worker.h #668215:668216
@@ -36,7 +36,7 @@
     KisTransformWorker(KisPaintDeviceSP dev, double  xscale, double  yscale,
         double  xshear, double  yshear, double rotation,
         Q_INT32  xtranslate, Q_INT32  ytranslate,
-        KisProgressDisplayInterface *progress, KisFilterStrategy *filter);
+        KisProgressDisplayInterface *progress, KisFilterStrategy *filter, bool fixBorderAlpha=false);
     ~KisTransformWorker();
 
 public:
@@ -46,7 +46,7 @@
 
 private:    
     // XXX (BSAR): Why didn't we use the shared-pointer versions of the paint device classes?
-    template <class T> void transformPass(KisPaintDevice *src, KisPaintDevice *dst, double xscale, double  shear, Q_INT32 dx,   KisFilterStrategy *filterStrategy);
+    template <class T> void transformPass(KisPaintDevice *src, KisPaintDevice *dst, double xscale, double  shear, Q_INT32 dx,   KisFilterStrategy *filterStrategy, bool fixBorderAlpha);
     
 public:    
     void rotateNone(KisPaintDeviceSP src, KisPaintDeviceSP dst);
@@ -68,6 +68,7 @@
     Q_INT32 m_progressStep;
     Q_INT32 m_progressScaler;
     Q_INT32 m_lastProgressReport;
+    bool m_fixBorderAlpha;
 };
 
 
--- branches/koffice/1.6/koffice/krita/plugins/viewplugins/imagesize/imagesize.cc #668215:668216
@@ -106,7 +106,7 @@
         if (dlgImageSize->scale()) {
             m_view->scaleCurrentImage((double)w / ((double)(image->width())),
                             (double)h / ((double)(image->height())),
-                            dlgImageSize->filterType());
+                            dlgImageSize->filterType(), true);
         }
         else {
             m_view->resizeCurrentImage(w, h, dlgImageSize->cropLayers());