| Summary: | Resizing an image make appearing a transparent border | ||
|---|---|---|---|
| Product: | [Applications] krita | Reporter: | Cyrille Berger <cberger> |
| Component: | General | Assignee: | Camilla Boemann <cbo> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Compiled Sources | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Cyrille Berger
2007-03-15 22:38:32 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());
|