r23806 by jghali - #16109: when modifying or replacing colors, reload pictures only when necessary, ie when image use some color effects
scribus-commit
scribus-commit at lists.scribus.net
Wed May 13 22:37:33 UTC 2020
Author: jghali
Date: Wed May 13 22:37:33 2020
New Revision: 23806
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23806
Log:
#16109: when modifying or replacing colors, reload pictures only when necessary, ie when image use some color effects
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pdflib_core.cpp
trunk/Scribus/scribus/plugins/import/emf/importemf.cpp
trunk/Scribus/scribus/plugins/import/emf/importemf.h
trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp
trunk/Scribus/scribus/plugins/import/svm/importsvm.cpp
trunk/Scribus/scribus/plugins/import/svm/importsvm.h
trunk/Scribus/scribus/plugins/scripter/api_imageitem.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmani.cpp
trunk/Scribus/scribus/scimage.cpp
trunk/Scribus/scribus/scimage.h
trunk/Scribus/scribus/scimagestructs.h
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/scribusdoc.h
trunk/Scribus/scribus/ui/effectsdialog.cpp
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Wed May 13 22:37:33 2020
@@ -7741,7 +7741,7 @@
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
switch (effectsInUse.at(a).effectCode)
{
- case ScImage::EF_QUADTONE:
+ case ImageEffect::EF_QUADTONE:
col1 = fp.readLine();
col2 = fp.readLine();
col3 = fp.readLine();
@@ -7788,7 +7788,7 @@
tmpstr2 += col4 + "\n";
tmpstr2 += fp.readAll();
break;
- case ScImage::EF_TRITONE:
+ case ImageEffect::EF_TRITONE:
col1 = fp.readLine();
col2 = fp.readLine();
col3 = fp.readLine();
@@ -7824,7 +7824,7 @@
tmpstr2 += col3 + "\n";
tmpstr2 += fp.readAll();
break;
- case ScImage::EF_DUOTONE:
+ case ImageEffect::EF_DUOTONE:
col1 = fp.readLine();
col2 = fp.readLine();
it = newNames.colors().find(col1);
@@ -7849,7 +7849,7 @@
tmpstr2 += col2 + "\n";
tmpstr2 += fp.readAll();
break;
- case ScImage::EF_COLORIZE:
+ case ImageEffect::EF_COLORIZE:
col1 = fp.readLine();
it = newNames.colors().find(col1);
if (it != newNames.colors().end())
@@ -8596,13 +8596,13 @@
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
switch (effectsInUse.at(a).effectCode)
{
- case ScImage::EF_QUADTONE:
+ case ImageEffect::EF_QUADTONE:
lists.collectColor(fp.readLine());
- case ScImage::EF_TRITONE:
+ case ImageEffect::EF_TRITONE:
lists.collectColor(fp.readLine());
- case ScImage::EF_DUOTONE:
+ case ImageEffect::EF_DUOTONE:
lists.collectColor(fp.readLine());
- case ScImage::EF_COLORIZE:
+ case ImageEffect::EF_COLORIZE:
lists.collectColor(fp.readLine());
break;
default:
@@ -9482,7 +9482,7 @@
{
if (!m_Doc->PageColors.contains(pixm.imgInfo.duotoneColors[cc].Name))
m_Doc->PageColors.insert(pixm.imgInfo.duotoneColors[cc].Name, pixm.imgInfo.duotoneColors[cc].Color);
- efVal += pixm.imgInfo.duotoneColors[cc].Name+"\n";
+ efVal += pixm.imgInfo.duotoneColors[cc].Name + "\n";
}
m_Doc->scMW()->propertiesPalette->updateColorList();
m_Doc->scMW()->contentPalette->updateColorList();
@@ -9490,7 +9490,7 @@
if (pixm.imgInfo.duotoneColors.count() == 1)
{
efVal += "100";
- ef.effectCode = ScImage::EF_COLORIZE;
+ ef.effectCode = ImageEffect::EF_COLORIZE;
ef.effectParameters = efVal;
}
else if (pixm.imgInfo.duotoneColors.count() == 2)
@@ -9515,7 +9515,7 @@
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
}
efVal += " 0";
- ef.effectCode = ScImage::EF_DUOTONE;
+ ef.effectCode = ImageEffect::EF_DUOTONE;
ef.effectParameters = efVal;
}
else if (pixm.imgInfo.duotoneColors.count() == 3)
@@ -9549,7 +9549,7 @@
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
}
efVal += " 0";
- ef.effectCode = ScImage::EF_TRITONE;
+ ef.effectCode = ImageEffect::EF_TRITONE;
ef.effectParameters = efVal;
}
else if (pixm.imgInfo.duotoneColors.count() == 4)
@@ -9592,7 +9592,7 @@
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
}
efVal += " 0";
- ef.effectCode = ScImage::EF_QUADTONE;
+ ef.effectCode = ImageEffect::EF_QUADTONE;
ef.effectParameters = efVal;
}
effectsInUse.append(ef);
Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Wed May 13 22:37:33 2020
@@ -10483,21 +10483,7 @@
}
ImInfo.reso = 1;
}
- bool hasColorEffect = false;
- if (c->effectsInUse.count() != 0)
- {
- for (int a = 0; a < c->effectsInUse.count(); ++a)
- {
- if (c->effectsInUse.at(a).effectCode == ScImage::EF_COLORIZE)
- hasColorEffect = true;
- if (c->effectsInUse.at(a).effectCode == ScImage::EF_DUOTONE)
- hasColorEffect = true;
- if (c->effectsInUse.at(a).effectCode == ScImage::EF_TRITONE)
- hasColorEffect = true;
- if (c->effectsInUse.at(a).effectCode == ScImage::EF_QUADTONE)
- hasColorEffect = true;
- }
- }
+ bool hasColorEffect = c->effectsInUse.useColorEffect();
if ((doc.HasCMS) && (Options.UseProfiles2))
{
if (!ICCProfiles.contains(Profil))
Modified: trunk/Scribus/scribus/plugins/import/emf/importemf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/plugins/import/emf/importemf.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/emf/importemf.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/emf/importemf.cpp Wed May 13 22:37:33 2020
@@ -5187,7 +5187,7 @@
float edge;
ds >> edge;
ImageEffect ef;
- ef.effectCode = ScImage::EF_BLUR;
+ ef.effectCode = ImageEffect::EF_BLUR;
ef.effectParameters = QString("%1 1.0").arg(edge / 255.0 * 30.0);
m_Effects.append(ef);
}
@@ -5199,14 +5199,14 @@
if (brightness != 0)
{
ImageEffect ef;
- ef.effectCode = ScImage::EF_BRIGHTNESS;
+ ef.effectCode = ImageEffect::EF_BRIGHTNESS;
ef.effectParameters = QString("%1").arg(brightness);
m_Effects.append(ef);
}
if (contrast != 0)
{
ImageEffect ef;
- ef.effectCode = ScImage::EF_CONTRAST;
+ ef.effectCode = ImageEffect::EF_CONTRAST;
ef.effectParameters = QString("%1").arg(qMin(qMax(qRound(contrast * 1.27), -127), 127));
m_Effects.append(ef);
}
@@ -5233,7 +5233,7 @@
double amo = amount;
double rad = radius;
ImageEffect ef;
- ef.effectCode = ScImage::EF_SHARPEN;
+ ef.effectCode = ImageEffect::EF_SHARPEN;
ef.effectParameters = QString("%1 %2").arg(qMin(rad, 10.0)).arg(qMin(amo / 100.0 * 5.0, 5.0));
m_Effects.append(ef);
}
Modified: trunk/Scribus/scribus/plugins/import/emf/importemf.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/plugins/import/emf/importemf.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/emf/importemf.h (original)
+++ trunk/Scribus/scribus/plugins/import/emf/importemf.h Wed May 13 22:37:33 2020
@@ -327,7 +327,7 @@
bool emfMixed;
float emfPlusScale;
bool SerializableObject_Valid;
- QList<ImageEffect> m_Effects;
+ ScImageEffectList m_Effects;
quint32 m_ObjSize;
quint32 m_currObjSize;
quint16 m_objID;
Modified: trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/revenge/rawpainter.cpp Wed May 13 22:37:33 2020
@@ -2146,7 +2146,7 @@
efVal += "\n";
struct ImageEffect ef;
efVal += "100";
- ef.effectCode = ScImage::EF_COLORIZE;
+ ef.effectCode = ImageEffect::EF_COLORIZE;
ef.effectParameters = efVal;
ite->effectsInUse.append(ef);
}
@@ -3361,7 +3361,7 @@
efVal += "\n";
struct ImageEffect ef;
efVal += "100";
- ef.effectCode = ScImage::EF_COLORIZE;
+ ef.effectCode = ImageEffect::EF_COLORIZE;
ef.effectParameters = efVal;
ite->effectsInUse.append(ef);
}
@@ -3539,7 +3539,7 @@
efVal += "\n";
struct ImageEffect ef;
efVal += "100";
- ef.effectCode = ScImage::EF_COLORIZE;
+ ef.effectCode = ImageEffect::EF_COLORIZE;
ef.effectParameters = efVal;
ite->effectsInUse.append(ef);
}
@@ -3547,7 +3547,7 @@
{
double per = m_style["draw:luminance"]->getDouble();
struct ImageEffect ef;
- ef.effectCode = ScImage::EF_BRIGHTNESS;
+ ef.effectCode = ImageEffect::EF_BRIGHTNESS;
ef.effectParameters = QString("%1").arg(qRound((per - 0.5) * 255));
ite->effectsInUse.append(ef);
}
Modified: trunk/Scribus/scribus/plugins/import/svm/importsvm.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/plugins/import/svm/importsvm.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svm/importsvm.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/svm/importsvm.cpp Wed May 13 22:37:33 2020
@@ -4070,7 +4070,7 @@
float edge;
ds >> edge;
ImageEffect ef;
- ef.effectCode = ScImage::EF_BLUR;
+ ef.effectCode = ImageEffect::EF_BLUR;
ef.effectParameters = QString("%1 1.0").arg(edge / 255.0 * 30.0);
m_Effects.append(ef);
}
@@ -4082,14 +4082,14 @@
if (brightness != 0)
{
ImageEffect ef;
- ef.effectCode = ScImage::EF_BRIGHTNESS;
+ ef.effectCode = ImageEffect::EF_BRIGHTNESS;
ef.effectParameters = QString("%1").arg(brightness);
m_Effects.append(ef);
}
if (contrast != 0)
{
ImageEffect ef;
- ef.effectCode = ScImage::EF_CONTRAST;
+ ef.effectCode = ImageEffect::EF_CONTRAST;
ef.effectParameters = QString("%1").arg(qMin(qMax(qRound(contrast * 1.27), -127), 127));
m_Effects.append(ef);
}
@@ -4116,7 +4116,7 @@
double amo = amount;
double rad = radius;
ImageEffect ef;
- ef.effectCode = ScImage::EF_SHARPEN;
+ ef.effectCode = ImageEffect::EF_SHARPEN;
ef.effectParameters = QString("%1 %2").arg(qMin(rad, 10.0)).arg(qMin(amo / 100.0 * 5.0, 5.0));
m_Effects.append(ef);
}
Modified: trunk/Scribus/scribus/plugins/import/svm/importsvm.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/plugins/import/svm/importsvm.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svm/importsvm.h (original)
+++ trunk/Scribus/scribus/plugins/import/svm/importsvm.h Wed May 13 22:37:33 2020
@@ -515,7 +515,7 @@
bool emfPlusDual;
float emfPlusScale;
bool SerializableObject_Valid;
- QList<ImageEffect> m_Effects;
+ ScImageEffectList m_Effects;
quint32 m_ObjSize;
quint32 m_currObjSize;
quint16 m_objID;
Modified: trunk/Scribus/scribus/plugins/scripter/api_imageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/plugins/scripter/api_imageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_imageitem.cpp (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_imageitem.cpp Wed May 13 22:37:33 2020
@@ -76,7 +76,7 @@
}
ImageEffect ef;
- ef.effectCode = ScImage::EF_GRAYSCALE;
+ ef.effectCode = ImageEffect::EF_GRAYSCALE;
item->effectsInUse.append(ef);
item->pixm.applyEffect(item->effectsInUse, ScCore->primaryMainWindow()->doc->PageColors, false);
@@ -174,7 +174,7 @@
}
ImageEffect ef;
- ef.effectCode = ScImage::EF_BRIGHTNESS;
+ ef.effectCode = ImageEffect::EF_BRIGHTNESS;
ScTextStream fp(&ef.effectParameters, QIODevice::WriteOnly);
fp << n;
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp Wed May 13 22:37:33 2020
@@ -182,7 +182,7 @@
}
ImageEffect ef;
- ef.effectCode = ScImage::EF_BRIGHTNESS;
+ ef.effectCode = ImageEffect::EF_BRIGHTNESS;
ScTextStream fp(&ef.effectParameters, QIODevice::WriteOnly);
fp << n;
@@ -210,7 +210,7 @@
}
ImageEffect ef;
- ef.effectCode = ScImage::EF_GRAYSCALE;
+ ef.effectCode = ImageEffect::EF_GRAYSCALE;
item->effectsInUse.append(ef);
item->pixm.applyEffect(item->effectsInUse, ScCore->primaryMainWindow()->doc->PageColors, false);
Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmani.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmani.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmani.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdmani.cpp Wed May 13 22:37:33 2020
@@ -183,7 +183,7 @@
}
ImageEffect ef;
- ef.effectCode = ScImage::EF_BRIGHTNESS;
+ ef.effectCode = ImageEffect::EF_BRIGHTNESS;
ScTextStream fp(&ef.effectParameters, QIODevice::WriteOnly);
fp << n;
@@ -211,7 +211,7 @@
}
ImageEffect ef;
- ef.effectCode = ScImage::EF_GRAYSCALE;
+ ef.effectCode = ImageEffect::EF_GRAYSCALE;
item->effectsInUse.append(ef);
item->pixm.applyEffect(item->effectsInUse, ScCore->primaryMainWindow()->doc->PageColors, false);
Modified: trunk/Scribus/scribus/scimage.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/scimage.cpp
==============================================================================
--- trunk/Scribus/scribus/scimage.cpp (original)
+++ trunk/Scribus/scribus/scimage.cpp Wed May 13 22:37:33 2020
@@ -132,15 +132,16 @@
return;
ScribusDoc* doc = colors.document();
- for (int a = 0; a < effectsList.count(); ++a)
- {
- if (effectsList.at(a).effectCode == EF_INVERT)
+ for (int i = 0; i < effectsList.count(); ++i)
+ {
+ const ImageEffect& effect = effectsList.at(i);
+ if (effect.effectCode == ImageEffect::EF_INVERT)
invert(cmyk);
- if (effectsList.at(a).effectCode == EF_GRAYSCALE)
+ if (effect.effectCode == ImageEffect::EF_GRAYSCALE)
toGrayscale(cmyk);
- if (effectsList.at(a).effectCode == EF_COLORIZE)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_COLORIZE)
+ {
+ QString tmpstr = effect.effectParameters;
QString col = CommonStrings::None;
int shading = 100;
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
@@ -149,51 +150,51 @@
fp >> shading;
colorize(doc, colors[col], shading, cmyk);
}
- if (effectsList.at(a).effectCode == EF_BRIGHTNESS)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_BRIGHTNESS)
+ {
+ QString tmpstr = effect.effectParameters;
int brightnessValue = 0;
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
fp >> brightnessValue;
brightness(brightnessValue, cmyk);
}
- if (effectsList.at(a).effectCode == EF_CONTRAST)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_CONTRAST)
+ {
+ QString tmpstr = effect.effectParameters;
int contrastValue = 0;
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
fp >> contrastValue;
contrast(contrastValue, cmyk);
}
- if (effectsList.at(a).effectCode == EF_SHARPEN)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_SHARPEN)
+ {
+ QString tmpstr = effect.effectParameters;
double radius, sigma;
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
fp >> radius;
fp >> sigma;
sharpen(radius, sigma);
}
- if (effectsList.at(a).effectCode == EF_BLUR)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_BLUR)
+ {
+ QString tmpstr = effect.effectParameters;
double radius, sigma;
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
fp >> radius;
fp >> sigma;
blur(static_cast<int>(radius));
}
- if (effectsList.at(a).effectCode == EF_SOLARIZE)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_SOLARIZE)
+ {
+ QString tmpstr = effect.effectParameters;
double sigma;
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
fp >> sigma;
solarize(sigma, cmyk);
}
- if (effectsList.at(a).effectCode == EF_DUOTONE)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_DUOTONE)
+ {
+ QString tmpstr = effect.effectParameters;
QString col1 = CommonStrings::None;
int shading1 = 100;
QString col2 = CommonStrings::None;
@@ -229,9 +230,9 @@
fp >> lin2;
duotone(doc, colors[col1], shading1, curve1, lin1, colors[col2], shading2, curve2, lin2, cmyk);
}
- if (effectsList.at(a).effectCode == EF_TRITONE)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_TRITONE)
+ {
+ QString tmpstr = effect.effectParameters;
QString col1 = CommonStrings::None;
QString col2 = CommonStrings::None;
QString col3 = CommonStrings::None;
@@ -282,9 +283,9 @@
fp >> lin3;
tritone(doc, colors[col1], shading1, curve1, lin1, colors[col2], shading2, curve2, lin2, colors[col3], shading3, curve3, lin3, cmyk);
}
- if (effectsList.at(a).effectCode == EF_QUADTONE)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_QUADTONE)
+ {
+ QString tmpstr = effect.effectParameters;
QString col1 = CommonStrings::None;
QString col2 = CommonStrings::None;
QString col3 = CommonStrings::None;
@@ -350,9 +351,9 @@
fp >> lin4;
quadtone(doc, colors[col1], shading1, curve1, lin1, colors[col2], shading2, curve2, lin2, colors[col3], shading3, curve3, lin3, colors[col4], shading4, curve4, lin4, cmyk);
}
- if (effectsList.at(a).effectCode == EF_GRADUATE)
- {
- QString tmpstr = effectsList.at(a).effectParameters;
+ if (effect.effectCode == ImageEffect::EF_GRADUATE)
+ {
+ QString tmpstr = effect.effectParameters;
int numVals;
double xval, yval;
FPointArray curve;
Modified: trunk/Scribus/scribus/scimage.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/scimage.h
==============================================================================
--- trunk/Scribus/scribus/scimage.h (original)
+++ trunk/Scribus/scribus/scimage.h Wed May 13 22:37:33 2020
@@ -49,22 +49,6 @@
RawData = 2,
OutputProfile = 3,
Thumbnail = 4,
- };
-
- enum ImageEffectCode
- {
- EF_INVERT = 0,
- EF_GRAYSCALE = 1,
- EF_COLORIZE = 2,
- EF_BRIGHTNESS = 3,
- EF_CONTRAST = 4,
- EF_SHARPEN = 5,
- EF_BLUR = 6,
- EF_SOLARIZE = 7,
- EF_DUOTONE = 8,
- EF_TRITONE = 9,
- EF_QUADTONE = 10,
- EF_GRADUATE = 11
};
void initialize();
Modified: trunk/Scribus/scribus/scimagestructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/scimagestructs.h
==============================================================================
--- trunk/Scribus/scribus/scimagestructs.h (original)
+++ trunk/Scribus/scribus/scimagestructs.h Wed May 13 22:37:33 2020
@@ -31,10 +31,50 @@
struct ImageEffect
{
+ enum EffectCode
+ {
+ EF_INVERT = 0,
+ EF_GRAYSCALE = 1,
+ EF_COLORIZE = 2,
+ EF_BRIGHTNESS = 3,
+ EF_CONTRAST = 4,
+ EF_SHARPEN = 5,
+ EF_BLUR = 6,
+ EF_SOLARIZE = 7,
+ EF_DUOTONE = 8,
+ EF_TRITONE = 9,
+ EF_QUADTONE = 10,
+ EF_GRADUATE = 11
+ };
+
int effectCode;
QString effectParameters;
};
-typedef QList<ImageEffect> ScImageEffectList;
+
+class ScImageEffectList : public QList<ImageEffect>
+{
+public:
+ bool useColorEffect() const
+ {
+ int effectCount = this->count();
+ if (effectCount <= 0)
+ return false;
+
+ for (int i = 0; i < effectCount; ++i)
+ {
+ const auto& effect = at(i);
+ if (effect.effectCode == ImageEffect::EF_COLORIZE)
+ return true;
+ if (effect.effectCode == ImageEffect::EF_DUOTONE)
+ return true;
+ if (effect.effectCode == ImageEffect::EF_TRITONE)
+ return true;
+ if (effect.effectCode == ImageEffect::EF_QUADTONE)
+ return true;
+ }
+ return false;
+ }
+};
struct PSDHeader
{
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Wed May 13 22:37:33 2020
@@ -6849,7 +6849,7 @@
mainWindowProgressBar->reset();
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
qApp->processEvents();
- doc->recalcPicturesRes(true);
+ doc->recalcPicturesRes(ScribusDoc::RecalcPicRes_ApplyNewRes);
qApp->restoreOverrideCursor();
setStatusBarInfoText("");
mainWindowProgressBar->reset();
@@ -9366,7 +9366,8 @@
doc->replaceLineStyleColors(dia->replaceColorMap);
}
doc->recalculateColors();
- doc->recalcPicturesRes();
+ if (doc->useImageColorEffects())
+ doc->recalcPicturesRes(ScribusDoc::RecalcPicRes_ImageWithColorEffectsOnly);
doc->setGradients(dia->dialogGradients);
if (!dia->replaceMap.isEmpty())
{
@@ -9438,7 +9439,8 @@
doc->replaceNamedResources(colorrsc);
doc->replaceLineStyleColors(dia2->replaceMap);
doc->recalculateColors();
- doc->recalcPicturesRes();
+ if (doc->useImageColorEffects())
+ doc->recalcPicturesRes(ScribusDoc::RecalcPicRes_ImageWithColorEffectsOnly);
requestUpdate(reqColorsUpdate | reqLineStylesUpdate);
m_styleManager->updateColorList();
if (!doc->m_Selection->isEmpty())
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Wed May 13 22:37:33 2020
@@ -4624,6 +4624,152 @@
return false;
}
+bool ScribusDoc::useImageEffects() const
+{
+ QList<PageItem*> allItems;
+ const QList<PageItem*>* itemLists[] = { &MasterItems, &DocItems };
+
+ for (int i = 0; i < 2; ++i)
+ {
+ const auto& itemList = *(itemLists[i]);
+ for (int j = 0; j < itemList.count(); ++j)
+ {
+ PageItem *currItem = itemList.at(j);
+ if (currItem->isGroup())
+ allItems = currItem->getAllChildren();
+ else
+ allItems.append(currItem);
+ for (int k = 0; k < allItems.count(); k++)
+ {
+ currItem = allItems.at(k);
+ if (!currItem->isImageFrame() || !currItem->imageIsAvailable)
+ continue;
+ if (currItem->effectsInUse.count() > 0)
+ return true;
+ }
+ allItems.clear();
+ }
+ }
+
+ for (auto it = FrameItems.begin(); it != FrameItems.end(); ++it)
+ {
+ PageItem *currItem = it.value();
+ if (currItem->isGroup())
+ allItems = currItem->getAllChildren();
+ else
+ allItems.append(currItem);
+ for (int ii = 0; ii < allItems.count(); ii++)
+ {
+ currItem = allItems.at(ii);
+ if (!currItem->isImageFrame() || !currItem->imageIsAvailable)
+ continue;
+ if (currItem->effectsInUse.count() > 0)
+ return true;
+ }
+ allItems.clear();
+ }
+
+ QStringList patterns = docPatterns.keys();
+ for (int i = 0; i < patterns.count(); ++i)
+ {
+ ScPattern pa = docPatterns[patterns[i]];
+ for (int j = 0; j < pa.items.count(); j++)
+ {
+ PageItem *currItem = pa.items.at(j);
+ if (currItem->isGroup())
+ allItems = currItem->getAllChildren();
+ else
+ allItems.append(currItem);
+
+ for (int k = 0; k < allItems.count(); k++)
+ {
+ currItem = allItems.at(k);
+ if (!currItem->isImageFrame() || !currItem->imageIsAvailable)
+ continue;
+ if (currItem->effectsInUse.count() > 0)
+ return true;
+ }
+ allItems.clear();
+ }
+ }
+
+ return false;
+}
+
+bool ScribusDoc::useImageColorEffects() const
+{
+ QList<PageItem*> allItems;
+ const QList<PageItem*>* itemLists[] = { &MasterItems, &DocItems };
+
+ for (int i = 0; i < 2; ++i)
+ {
+ const auto& itemList = *(itemLists[i]);
+ for (int j = 0; j < itemList.count(); ++j)
+ {
+ PageItem *currItem = itemList.at(j);
+ if (currItem->isGroup())
+ allItems = currItem->getAllChildren();
+ else
+ allItems.append(currItem);
+
+ for (int k = 0; k < allItems.count(); k++)
+ {
+ currItem = allItems.at(k);
+ if (!currItem->isImageFrame() || !currItem->imageIsAvailable)
+ continue;
+ if (currItem->effectsInUse.useColorEffect())
+ return true;
+ }
+ allItems.clear();
+ }
+ }
+
+ for (auto it = FrameItems.begin(); it != FrameItems.end(); ++it)
+ {
+ PageItem *currItem = it.value();
+ if (currItem->isGroup())
+ allItems = currItem->getAllChildren();
+ else
+ allItems.append(currItem);
+
+ for (int j = 0; j < allItems.count(); j++)
+ {
+ currItem = allItems.at(j);
+ if (!currItem->isImageFrame() || !currItem->imageIsAvailable)
+ continue;
+ if (currItem->effectsInUse.useColorEffect())
+ return true;
+ }
+ allItems.clear();
+ }
+
+ QStringList patterns = docPatterns.keys();
+ for (int i = 0; i < patterns.count(); ++i)
+ {
+ ScPattern pa = docPatterns[patterns[i]];
+ for (int j = 0; j < pa.items.count(); j++)
+ {
+ PageItem *currItem = pa.items.at(j);
+ if (currItem->isGroup())
+ allItems = currItem->getAllChildren();
+ else
+ allItems.append(currItem);
+
+ for (int k = 0; k < allItems.count(); k++)
+ {
+ currItem = allItems.at(k);
+ if (!currItem->isImageFrame() || !currItem->imageIsAvailable)
+ continue;
+ if (currItem->effectsInUse.useColorEffect())
+ return true;
+ }
+ allItems.clear();
+ }
+ }
+
+ return false;
+}
+
void ScribusDoc::setUnitIndex(int newIndex)
{
m_docPrefsData.docSetupPrefs.docUnitIndex=newIndex;
@@ -10092,7 +10238,7 @@
}
//CB Same as updatePict apart from the name checking, this should be able to be removed
-void ScribusDoc::recalcPicturesRes(bool applyNewRes)
+void ScribusDoc::recalcPicturesRes(int recalcFlags)
{
int ca = 0;
ScGuardedPtr<ScribusDoc> docPtr = guardedPtr();
@@ -10164,7 +10310,9 @@
allItems.clear();
}
}
+
m_ScMW->mainWindowProgressBar->setMaximum((cc > 0) ? cc : 1);
+
for (int a = 0; a < DocItems.count(); ++a)
{
PageItem *currItem = DocItems.at(a);
@@ -10177,11 +10325,21 @@
currItem = allItems.at(ii);
if (!currItem->imageIsAvailable)
continue;
+ if (recalcFlags & (RecalcPicRes_ImageWithEffectsOnly | RecalcPicRes_ImageWithColorEffectsOnly))
+ {
+ if (currItem->effectsInUse.count() <= 0)
+ continue;
+ }
+ if (recalcFlags & RecalcPicRes_ImageWithColorEffectsOnly)
+ {
+ if (!currItem->effectsInUse.useColorEffect())
+ continue;
+ }
bool fho = currItem->imageFlippedH();
bool fvo = currItem->imageFlippedV();
double imgX = currItem->imageXOffset();
double imgY = currItem->imageYOffset();
- if (applyNewRes)
+ if (recalcFlags & RecalcPicRes_ApplyNewRes)
currItem->pixm.imgInfo.lowResType = m_docPrefsData.itemToolPrefs.imageLowResType;
if (currItem->isLatexFrame())
currItem->asLatexFrame()->rerunApplication(false);
@@ -10199,6 +10357,7 @@
}
allItems.clear();
}
+
for (int a = 0; a < MasterItems.count(); ++a)
{
PageItem *currItem = MasterItems.at(a);
@@ -10211,11 +10370,21 @@
currItem = allItems.at(ii);
if (!currItem->imageIsAvailable)
continue;
+ if (recalcFlags & (RecalcPicRes_ImageWithEffectsOnly | RecalcPicRes_ImageWithColorEffectsOnly))
+ {
+ if (currItem->effectsInUse.count() <= 0)
+ continue;
+ }
+ if (recalcFlags & RecalcPicRes_ImageWithColorEffectsOnly)
+ {
+ if (!currItem->effectsInUse.useColorEffect())
+ continue;
+ }
bool fho = currItem->imageFlippedH();
bool fvo = currItem->imageFlippedV();
double imgX = currItem->imageXOffset();
double imgY = currItem->imageYOffset();
- if (applyNewRes)
+ if (recalcFlags & RecalcPicRes_ApplyNewRes)
currItem->pixm.imgInfo.lowResType = m_docPrefsData.itemToolPrefs.imageLowResType;
if (currItem->isLatexFrame())
currItem->asLatexFrame()->rerunApplication(false);
@@ -10246,11 +10415,21 @@
currItem = allItems.at(ii);
if (!currItem->imageIsAvailable)
continue;
+ if (recalcFlags & (RecalcPicRes_ImageWithEffectsOnly | RecalcPicRes_ImageWithColorEffectsOnly))
+ {
+ if (currItem->effectsInUse.count() <= 0)
+ continue;
+ }
+ if (recalcFlags & RecalcPicRes_ImageWithColorEffectsOnly)
+ {
+ if (!currItem->effectsInUse.useColorEffect())
+ continue;
+ }
bool fho = currItem->imageFlippedH();
bool fvo = currItem->imageFlippedV();
double imgX = currItem->imageXOffset();
double imgY = currItem->imageYOffset();
- if (applyNewRes)
+ if (recalcFlags & RecalcPicRes_ApplyNewRes)
currItem->pixm.imgInfo.lowResType = m_docPrefsData.itemToolPrefs.imageLowResType;
if (currItem->isLatexFrame())
currItem->asLatexFrame()->rerunApplication(false);
@@ -10285,11 +10464,21 @@
currItem = allItems.at(ii);
if (!currItem->imageIsAvailable)
continue;
+ if (recalcFlags & (RecalcPicRes_ImageWithEffectsOnly | RecalcPicRes_ImageWithColorEffectsOnly))
+ {
+ if (currItem->effectsInUse.count() <= 0)
+ continue;
+ }
+ if (recalcFlags & RecalcPicRes_ImageWithColorEffectsOnly)
+ {
+ if (!currItem->effectsInUse.useColorEffect())
+ continue;
+ }
bool fho = currItem->imageFlippedH();
bool fvo = currItem->imageFlippedV();
double imgX = currItem->imageXOffset();
double imgY = currItem->imageYOffset();
- if (applyNewRes)
+ if (recalcFlags & RecalcPicRes_ApplyNewRes)
currItem->pixm.imgInfo.lowResType = m_docPrefsData.itemToolPrefs.imageLowResType;
if (currItem->isLatexFrame())
currItem->asLatexFrame()->rerunApplication(false);
Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Wed May 13 22:37:33 2020
@@ -733,6 +733,16 @@
*/
bool useAnnotations() const;
+ /*!
+ * @brief Check if document use effects on images
+ */
+ bool useImageEffects() const;
+
+ /*!
+ * @brief Check if document use effects on images
+ */
+ bool useImageColorEffects() const;
+
/**
* @brief Set and get the document's unit index
*/
@@ -1164,7 +1174,15 @@
bool m_applyNewRes;
int m_lowResType;
};
- void recalcPicturesRes(bool applyNewRes = false);
+
+ enum RecalcPictureResFlags
+ {
+ RecalcPicRes_ApplyNewRes = 1,
+ RecalcPicRes_ImageWithEffectsOnly = 2,
+ RecalcPicRes_ImageWithColorEffectsOnly = 4,
+ };
+ void recalcPicturesRes(int recalcFlags = 0);
+
int previewQuality();
void connectDocSignals();
void disconnectDocSignals();
Modified: trunk/Scribus/scribus/ui/effectsdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23806&path=/trunk/Scribus/scribus/ui/effectsdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/effectsdialog.cpp (original)
+++ trunk/Scribus/scribus/ui/effectsdialog.cpp Wed May 13 22:37:33 2020
@@ -518,17 +518,17 @@
m_effectValMap.clear();
for (int i = 0; i < effectsList.count(); ++i)
{
- if (effectsList.at(i).effectCode == ScImage::EF_INVERT)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_INVERT)
{
usedEffects->addItem( tr("Invert"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), "");
}
- if (effectsList.at(i).effectCode == ScImage::EF_GRAYSCALE)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_GRAYSCALE)
{
usedEffects->addItem( tr("Grayscale"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), "");
}
- if (effectsList.at(i).effectCode == ScImage::EF_COLORIZE)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_COLORIZE)
{
usedEffects->addItem( tr("Colorize"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), effectsList.at(i).effectParameters);
@@ -537,22 +537,22 @@
setItemSelectable(availableEffects, 4, false);
setItemSelectable(availableEffects, 5, false);
}
- if (effectsList.at(i).effectCode == ScImage::EF_BRIGHTNESS)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_BRIGHTNESS)
{
usedEffects->addItem( tr("Brightness"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), effectsList.at(i).effectParameters);
}
- if (effectsList.at(i).effectCode == ScImage::EF_CONTRAST)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_CONTRAST)
{
usedEffects->addItem( tr("Contrast"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), effectsList.at(i).effectParameters);
}
- if (effectsList.at(i).effectCode == ScImage::EF_SHARPEN)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_SHARPEN)
{
usedEffects->addItem( tr("Sharpen"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), effectsList.at(i).effectParameters);
}
- if (effectsList.at(i).effectCode == ScImage::EF_BLUR)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_BLUR)
{
usedEffects->addItem( tr("Blur"));
QString tmpstr = effectsList.at(i).effectParameters;
@@ -562,12 +562,12 @@
blRadius->setValue(radius / m_imageScale);
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), QString("%1 1.0").arg(radius / m_imageScale));
}
- if (effectsList.at(i).effectCode == ScImage::EF_SOLARIZE)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_SOLARIZE)
{
usedEffects->addItem( tr("Posterize"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), effectsList.at(i).effectParameters);
}
- if (effectsList.at(i).effectCode == ScImage::EF_DUOTONE)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_DUOTONE)
{
usedEffects->addItem( tr("Duotone"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), effectsList.at(i).effectParameters);
@@ -576,7 +576,7 @@
setItemSelectable(availableEffects, 4, false);
setItemSelectable(availableEffects, 5, false);
}
- if (effectsList.at(i).effectCode == ScImage::EF_TRITONE)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_TRITONE)
{
usedEffects->addItem( tr("Tritone"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), effectsList.at(i).effectParameters);
@@ -585,7 +585,7 @@
setItemSelectable(availableEffects, 4, false);
setItemSelectable(availableEffects, 5, false);
}
- if (effectsList.at(i).effectCode == ScImage::EF_QUADTONE)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_QUADTONE)
{
usedEffects->addItem( tr("Quadtone"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), effectsList.at(i).effectParameters);
@@ -594,7 +594,7 @@
setItemSelectable(availableEffects, 4, false);
setItemSelectable(availableEffects, 5, false);
}
- if (effectsList.at(i).effectCode == ScImage::EF_GRADUATE)
+ if (effectsList.at(i).effectCode == ImageEffect::EF_GRADUATE)
{
usedEffects->addItem( tr("Curves"));
m_effectValMap.insert(usedEffects->item(usedEffects->count()-1), effectsList.at(i).effectParameters);
@@ -775,37 +775,37 @@
{
if (usedEffects->item(e)->text() == tr("Invert"))
{
- ef.effectCode = ScImage::EF_INVERT;
+ ef.effectCode = ImageEffect::EF_INVERT;
ef.effectParameters = "";
}
if (usedEffects->item(e)->text() == tr("Grayscale"))
{
- ef.effectCode = ScImage::EF_GRAYSCALE;
+ ef.effectCode = ImageEffect::EF_GRAYSCALE;
ef.effectParameters = "";
}
if (usedEffects->item(e)->text() == tr("Colorize"))
{
- ef.effectCode = ScImage::EF_COLORIZE;
+ ef.effectCode = ImageEffect::EF_COLORIZE;
ef.effectParameters = m_effectValMap[usedEffects->item(e)];
}
if (usedEffects->item(e)->text() == tr("Brightness"))
{
- ef.effectCode = ScImage::EF_BRIGHTNESS;
+ ef.effectCode = ImageEffect::EF_BRIGHTNESS;
ef.effectParameters = m_effectValMap[usedEffects->item(e)];
}
if (usedEffects->item(e)->text() == tr("Contrast"))
{
- ef.effectCode = ScImage::EF_CONTRAST;
+ ef.effectCode = ImageEffect::EF_CONTRAST;
ef.effectParameters = m_effectValMap[usedEffects->item(e)];
}
if (usedEffects->item(e)->text() == tr("Sharpen"))
{
- ef.effectCode = ScImage::EF_SHARPEN;
+ ef.effectCode = ImageEffect::EF_SHARPEN;
ef.effectParameters = m_effectValMap[usedEffects->item(e)];
}
if (usedEffects->item(e)->text() == tr("Blur"))
{
- ef.effectCode = ScImage::EF_BLUR;
+ ef.effectCode = ImageEffect::EF_BLUR;
if (final)
ef.effectParameters = QString("%1 1.0").arg(blRadius->value() * m_imageScale);
else
@@ -813,27 +813,27 @@
}
if (usedEffects->item(e)->text() == tr("Posterize"))
{
- ef.effectCode = ScImage::EF_SOLARIZE;
+ ef.effectCode = ImageEffect::EF_SOLARIZE;
ef.effectParameters = m_effectValMap[usedEffects->item(e)];
}
if (usedEffects->item(e)->text() == tr("Duotone"))
{
- ef.effectCode = ScImage::EF_DUOTONE;
+ ef.effectCode = ImageEffect::EF_DUOTONE;
ef.effectParameters = m_effectValMap[usedEffects->item(e)];
}
if (usedEffects->item(e)->text() == tr("Tritone"))
{
- ef.effectCode = ScImage::EF_TRITONE;
+ ef.effectCode = ImageEffect::EF_TRITONE;
ef.effectParameters = m_effectValMap[usedEffects->item(e)];
}
if (usedEffects->item(e)->text() == tr("Quadtone"))
{
- ef.effectCode = ScImage::EF_QUADTONE;
+ ef.effectCode = ImageEffect::EF_QUADTONE;
ef.effectParameters = m_effectValMap[usedEffects->item(e)];
}
if (usedEffects->item(e)->text() == tr("Curves"))
{
- ef.effectCode = ScImage::EF_GRADUATE;
+ ef.effectCode = ImageEffect::EF_GRADUATE;
ef.effectParameters = m_effectValMap[usedEffects->item(e)];
}
effectsList.append(ef);
More information about the scribus-commit
mailing list