Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

enable to cleanup with no line processing

shun-iwasawa76a03980a354
diff --git a/toonz/sources/include/toonz/cleanupparameters.h b/toonz/sources/include/toonz/cleanupparameters.h
index e70062c5e..897ee7645 100644
--- a/toonz/sources/include/toonz/cleanupparameters.h
+++ b/toonz/sources/include/toonz/cleanupparameters.h
@@ -160,6 +160,12 @@ public:
/*--- オフセットを軸ごとにロックする ---*/
bool m_offx_lock, m_offy_lock;
+ // hold brightness and contrast values for each line processing modes (grey
+ // and color).
+ double m_altBrightness, m_altContrast;
+ // exporting file format when Line Processing = None
+ std::string m_lpNoneFormat;
+
public:
CleanupParameters();
CleanupParameters(const CleanupParameters &p) { assign(&p); }
diff --git a/toonz/sources/include/toonz/tcleanupper.h b/toonz/sources/include/toonz/tcleanupper.h
index 3a2ac95ae..d8a1af86e 100644
--- a/toonz/sources/include/toonz/tcleanupper.h
+++ b/toonz/sources/include/toonz/tcleanupper.h
@@ -89,10 +89,11 @@ time, to unlock a possibly useful memory block.
*/
CleanupPreprocessedImage *process(TRasterImageP &image, bool first_image,
TRasterImageP &onlyResampledImage,
- bool isCameraTest = false,
- bool returnResampled = false,
- bool onlyForSwatch = false,
- TAffine *aff = 0);
+ bool isCameraTest = false,
+ bool returnResampled = false,
+ bool onlyForSwatch = false,
+ TAffine *aff = 0,
+ TRasterP templateForResampled = 0);
void finalize(const TRaster32P &dst, CleanupPreprocessedImage *src);
TToonzImageP finalize(CleanupPreprocessedImage *src,
diff --git a/toonz/sources/include/toonz/txshsimplelevel.h b/toonz/sources/include/toonz/txshsimplelevel.h
index 555099afb..0a2c2b9f5 100644
--- a/toonz/sources/include/toonz/txshsimplelevel.h
+++ b/toonz/sources/include/toonz/txshsimplelevel.h
@@ -202,7 +202,8 @@ table) it returns the proper insertion index
// load icon (and image) data of all frames into cache
void loadAllIconsAndPutInCache(bool cacheImagesAsWell);
- TRasterImageP getFrameToCleanup(const TFrameId &fid) const;
+ TRasterImageP getFrameToCleanup(const TFrameId &fid,
+ bool toBeLineProcessed) const;
std::string getImageId(const TFrameId &fid, int frameStatus = -1) const;
std::string getIconId(const TFrameId &fid, int frameStatus = -1) const;
diff --git a/toonz/sources/tcleanupper/tcleanupper.cpp b/toonz/sources/tcleanupper/tcleanupper.cpp
index 53567df16..925154782 100644
--- a/toonz/sources/tcleanupper/tcleanupper.cpp
+++ b/toonz/sources/tcleanupper/tcleanupper.cpp
@@ -411,7 +411,10 @@ static void cleanupLevel(TXshSimpleLevel *xl, std::set<TFrameId> fidsInXsheet,
QString::fromStdString(fid.expand()));
continue;
}
- TRasterImageP original = xl->getFrameToCleanup(fid);
+ CleanupParameters *params = scene->getProperties()->getCleanupParameters();
+ // if lines are not processed, obtain the original sampled image
+ bool toBeLineProcessed = params->m_lineProcessingMode != lpNone;
+ TRasterImageP original = xl->getFrameToCleanup(fid, toBeLineProcessed);
if (!original) {
string err = " *error* missed frame";
m_userLog.error(err);
@@ -419,11 +422,9 @@ static void cleanupLevel(TXshSimpleLevel *xl, std::set<TFrameId> fidsInXsheet,
continue;
}
- CleanupParameters *params = scene->getProperties()->getCleanupParameters();
-
if (params->m_lineProcessingMode == lpNone) {
- TRasterImageP ri;
- if (params->m_autocenterType == CleanupTypes::AUTOCENTER_NONE)
+ TRasterImageP ri(original);
+ /*if (params->m_autocenterType == CleanupTypes::AUTOCENTER_NONE)
ri = original;
else {
bool autocentered;
@@ -432,7 +433,9 @@ static void cleanupLevel(TXshSimpleLevel *xl, std::set<TFrameId> fidsInXsheet,
m_userLog.error("The autocentering failed on the current drawing.");
cout << "The autocentering failed on the current drawing." << endl;
}
- }
+ }*/
+ cl->process(original, false, ri, false, true, true, nullptr,
+ ri->getRaster());
updater.update(fid, ri);
continue;
}
diff --git a/toonz/sources/toonz/cleanuppopup.cpp b/toonz/sources/toonz/cleanuppopup.cpp
index 653a63bab..4a90bfb94 100644
--- a/toonz/sources/toonz/cleanuppopup.cpp
+++ b/toonz/sources/toonz/cleanuppopup.cpp
@@ -565,6 +565,8 @@ bool CleanupPopup::analyzeCleanupList() {
m_overwriteDialog->reset();
}
+ m_overwriteDialog->enableOptions(inputPath == outputPath);
+
// Prompt user for file conflict resolution
clt.m_resolution =
Resolution(m_overwriteDialog->execute(&clt.m_outputPath));
@@ -634,7 +636,7 @@ bool CleanupPopup::analyzeCleanupList() {
TPointD outDpi;
m_params->getOutputImageInfo(outRes, outDpi.x, outDpi.y);
- if (oldRes != outRes) {
+ if (oldRes != outRes && inputPath != outputPath) {
DVGui::warning(
tr("The resulting resolution of level \"%1\"\ndoes not match "
"with that of previously cleaned up level drawings.\n\nPlease "
@@ -789,7 +791,13 @@ TImageP CleanupPopup::currentImage() const {
if (!isValidPosition(m_idx)) return TImageP();
const CleanupLevel &cl = m_cleanupLevels[m_idx.first];
- return cl.m_sl->getFrameToCleanup(cl.m_frames[m_idx.second]);
+
+ // if lines are not processed, obtain the original sampled image
+ bool toBeLineProcessed =
+ TCleanupper::instance()->getParameters()->m_lineProcessingMode != lpNone;
+
+ return cl.m_sl->getFrameToCleanup(cl.m_frames[m_idx.second],
+ toBeLineProcessed);
}
//-----------------------------------------------------------------------------
@@ -1195,19 +1203,35 @@ void CleanupPopup::cleanupFrame() {
TCleanupper *cl = TCleanupper::instance();
const CleanupParameters *params = cl->getParameters();
+ // Obtain the source dpi. Changed it to be done once at the first frame of
+ // each level in order to avoid the following problem:
+ // If the original raster level has no dpi (such as TGA images), obtaining
+ // dpi in every frame causes dpi mismatch between the first frame and the
+ // following frames, since the value
+ // TXshSimpleLevel::m_properties->getDpi() will be changed to the
+ // dpi of cleanup camera (= TLV's dpi) after finishing the first frame.
+ if (m_firstLevelFrame) {
+ TPointD dpi;
+ original->getDpi(dpi.x, dpi.y);
+ if (dpi.x == 0 && dpi.y == 0) dpi = sl->getProperties()->getDpi();
+ cl->setSourceDpi(dpi);
+ }
+
if (params->m_lineProcessingMode == lpNone) {
// No line processing
TRasterImageP ri(original);
- if (params->m_autocenterType != CleanupTypes::AUTOCENTER_NONE) {
+ /*if (params->m_autocenterType != CleanupTypes::AUTOCENTER_NONE) {
bool autocentered;
ri = cl->autocenterOnly(original, false, autocentered);
if (!autocentered)
DVGui::warning(
QObject::tr("The autocentering failed on the current drawing."));
- }
+ }*/
+ cl->process(original, false, ri, false, true, true, nullptr,
+ ri->getRaster());
- sl->setFrame(fid, ri);
+ if (TRaster32P(ri->getRaster())) sl->setFrame(fid, ri);
// Update the associated file. In case the operation throws, oh well the
// image gets skipped.
@@ -1220,20 +1244,6 @@ void CleanupPopup::cleanupFrame() {
} else {
// Perform main processing
- // Obtain the source dpi. Changed it to be done once at the first frame of
- // each level in order to avoid the following problem:
- // If the original raster level has no dpi (such as TGA images), obtaining
- // dpi in every frame causes dpi mismatch between the first frame and the
- // following frames, since the value
- // TXshSimpleLevel::m_properties->getDpi() will be changed to the
- // dpi of cleanup camera (= TLV's dpi) after finishing the first frame.
- if (m_firstLevelFrame) {
- TPointD dpi;
- original->getDpi(dpi.x, dpi.y);
- if (dpi.x == 0 && dpi.y == 0) dpi = sl->getProperties()->getDpi();
- cl->setSourceDpi(dpi);
- }
-
CleanupPreprocessedImage *cpi;
{
TRasterImageP resampledRaster;
@@ -1503,6 +1513,14 @@ void CleanupPopup::OverwriteDialog::reset() {
//-----------------------------------------------------------------------------
+void CleanupPopup::OverwriteDialog::enableOptions(bool writingOnSource) {
+ if (writingOnSource && m_buttonGroup->button(REPLACE)->isChecked())
+ m_buttonGroup->button(OVERWRITE)->setChecked(true);
+ m_buttonGroup->button(REPLACE)->setDisabled(writingOnSource);
+}
+
+//-----------------------------------------------------------------------------
+
QString CleanupPopup::OverwriteDialog::acceptResolution(void *obj,
int resolution,
bool applyToAll) {
diff --git a/toonz/sources/toonz/cleanuppopup.h b/toonz/sources/toonz/cleanuppopup.h
index 2698b0a32..89fd58a29 100644
--- a/toonz/sources/toonz/cleanuppopup.h
+++ b/toonz/sources/toonz/cleanuppopup.h
@@ -144,6 +144,7 @@ public:
OverwriteDialog();
void reset() override;
+ void enableOptions(bool writingOnSource);
private:
DVGui::LineEdit *m_suffix;
diff --git a/toonz/sources/toonz/cleanupsettingsmodel.cpp b/toonz/sources/toonz/cleanupsettingsmodel.cpp
index 24752108d..81a7382ca 100644
--- a/toonz/sources/toonz/cleanupsettingsmodel.cpp
+++ b/toonz/sources/toonz/cleanupsettingsmodel.cpp
@@ -405,7 +405,7 @@ void CleanupSettingsModel::rebuildPreview() {
void CleanupSettingsModel::processFrame(TXshSimpleLevel *sl, TFrameId fid) {
assert(sl);
- TRasterImageP imageToCleanup = sl->getFrameToCleanup(fid);
+ TRasterImageP imageToCleanup = sl->getFrameToCleanup(fid, true);
if (!imageToCleanup) return;
// Store the original image
@@ -741,5 +741,6 @@ TFilePath CleanupSettingsModel::getOutputPath(TXshSimpleLevel *sl,
const TFilePath &outDir = params->getPath(scene);
return lineProcessing ? (outDir + inPath.getWideName()).withType("tlv")
- : (outDir + inPath.getLevelNameW()).withType("tif");
+ : (outDir + inPath.getLevelNameW())
+ .withType(params->m_lpNoneFormat);
}
diff --git a/toonz/sources/toonz/cleanupsettingspane.cpp b/toonz/sources/toonz/cleanupsettingspane.cpp
index ac8059867..c2a216ae2 100644
--- a/toonz/sources/toonz/cleanupsettingspane.cpp
+++ b/toonz/sources/toonz/cleanupsettingspane.cpp
@@ -7,6 +7,7 @@
#include "toonz/tscenehandle.h"
#include "toonz/toonzscene.h"
#include "toonz/toonzfolders.h"
+#include "toonz/cleanupcolorstyles.h"
// ToonzQt includes
#include "toonzqt/gutil.h"
@@ -101,6 +102,8 @@ CleanupSettingsPane::CleanupSettingsPane(QWidget *parent)
m_aaValueLabel = new QLabel(tr("MLAA Intensity:"));
m_aaValue = new IntField(this);
m_lineProcessing = new QComboBox(this);
+ m_lpNoneFormatLabel = new QLabel(tr("Format:"));
+ m_lpNoneFormat = new QComboBox(this);
m_paletteViewer = new CleanupPaletteViewer(this);
m_pathField = new CleanupSaveInField(this, QString(""));
@@ -143,6 +146,13 @@ CleanupSettingsPane::CleanupSettingsPane(QWidget *parent)
items << tr("None") << tr("Greyscale") << tr("Color");
m_lineProcessing->addItems(items);
+ items.clear();
+ items << "tif"
+ << "png"
+ << "jpg"
+ << "tga";
+ m_lpNoneFormat->addItems(items);
+
m_sharpness->setValues(90, 0, 100);
m_despeckling->setValues(2, 0, 20);
m_aaValue->setValues(70, 0, 100);
@@ -223,15 +233,15 @@ CleanupSettingsPane::CleanupSettingsPane(QWidget *parent)
lineProcLay->addWidget(m_aaValueLabel, 4, 0,
Qt::AlignRight | Qt::AlignVCenter);
lineProcLay->addWidget(m_aaValue, 4, 1);
+ lineProcLay->addWidget(m_lpNoneFormatLabel, 5, 0,
+ Qt::AlignRight | Qt::AlignVCenter);
+ lineProcLay->addWidget(m_lpNoneFormat, 5, 1,
+ Qt::AlignLeft | Qt::AlignVCenter);
- lineProcLay->addWidget(m_paletteViewer, 5, 0, 1, 2);
+ lineProcLay->addWidget(m_paletteViewer, 6, 0, 1, 2);
}
- lineProcLay->setRowStretch(0, 0);
- lineProcLay->setRowStretch(1, 0);
- lineProcLay->setRowStretch(2, 0);
- lineProcLay->setRowStretch(3, 0);
- lineProcLay->setRowStretch(4, 0);
- lineProcLay->setRowStretch(5, 1);
+ for (int r = 0; r <= 5; r++) lineProcLay->setRowStretch(r, 0);
+ lineProcLay->setRowStretch(6, 1);
lineProcLay->setColumnStretch(0, 0);
lineProcLay->setColumnStretch(1, 1);
@@ -286,6 +296,8 @@ CleanupSettingsPane::CleanupSettingsPane(QWidget *parent)
SLOT(onGenericSettingsChange()));
ret = ret && connect(m_lineProcessing, SIGNAL(activated(int)),
SLOT(onGenericSettingsChange()));
+ ret = ret && connect(m_lpNoneFormat, SIGNAL(activated(int)),
+ SLOT(onGenericSettingsChange()));
ret = ret && connect(m_despeckling, SIGNAL(valueChanged(bool)),
SLOT(onGenericSettingsChange()));
ret = ret && connect(m_aaValue, SIGNAL(valueChanged(bool)),
@@ -404,6 +416,8 @@ void CleanupSettingsPane::updateGui(CleanupParameters *params,
m_sharpness->setValue(params->m_sharpness);
m_despeckling->setValue(params->m_despeckling);
m_aaValue->setValue(params->m_aaValue);
+ m_lpNoneFormat->setCurrentText(
+ QString::fromStdString(params->m_lpNoneFormat));
updateVisibility();
@@ -462,6 +476,8 @@ void CleanupSettingsPane::updateVisibility() {
for (QWidget *w : m_lpWidgets) w->setVisible(lp);
m_aaValueLabel->setVisible(MLAA);
m_aaValue->setVisible(MLAA);
+ m_lpNoneFormatLabel->setVisible(!lp);
+ m_lpNoneFormat->setVisible(!lp);
m_paletteViewer->setMode(lpGrey);
m_paletteViewer->setContrastEnabled(m_antialias->currentIndex() == 0);
@@ -525,15 +541,30 @@ void CleanupSettingsPane::onGenericSettingsChange() {
params->m_flipy = m_flipY->isChecked();
//------
-
- params->m_lineProcessingMode = m_lineProcessing->currentIndex();
- params->m_noAntialias = (m_antialias->currentIndex() > 0);
- params->m_postAntialias = (m_antialias->currentIndex() == 2);
- params->m_despeckling = m_despeckling->getValue();
- params->m_aaValue = m_aaValue->getValue();
-
- if (params->m_lineProcessingMode == lpNone)
- params->m_transparencyCheckEnabled = false;
+ if (params->m_lineProcessingMode != m_lineProcessing->currentIndex()) {
+ int oldMode = params->m_lineProcessingMode;
+ params->m_lineProcessingMode = m_lineProcessing->currentIndex();
+ if (params->m_lineProcessingMode == lpNone) {
+ params->m_transparencyCheckEnabled = false;
+ }
+ // When switching from/to Greyscale processing, replace the brightness and
+ // contrast values by the registered ones.
+ if (oldMode == lpGrey || params->m_lineProcessingMode == lpGrey) {
+ TCleanupStyle *blackStyle =
+ dynamic_cast<TCleanupStyle *>(params->m_cleanupPalette->getStyle(1));
+ double b = params->m_altBrightness;
+ double c = params->m_altContrast;
+ params->m_altBrightness = blackStyle->getBrightness();
+ params->m_altContrast = blackStyle->getContrast();
+ blackStyle->setBrightness(b);
+ blackStyle->setContrast(c);
+ }
+ }
+ params->m_noAntialias = (m_antialias->currentIndex() > 0);
+ params->m_postAntialias = (m_antialias->currentIndex() == 2);
+ params->m_despeckling = m_despeckling->getValue();
+ params->m_aaValue = m_aaValue->getValue();
+ params->m_lpNoneFormat = m_lpNoneFormat->currentText().toStdString();
//------
m_cameraWidget->getFields(model->getCurrentParameters());
diff --git a/toonz/sources/toonz/cleanupsettingspane.h b/toonz/sources/toonz/cleanupsettingspane.h
index d27e60e0a..7d8a10f11 100644
--- a/toonz/sources/toonz/cleanupsettingspane.h
+++ b/toonz/sources/toonz/cleanupsettingspane.h
@@ -62,6 +62,8 @@ private:
QLabel *m_aaValueLabel;
DVGui::IntField *m_aaValue;
QComboBox *m_lineProcessing;
+ QLabel *m_lpNoneFormatLabel;
+ QComboBox *m_lpNoneFormat;
//----Cleanup Palette
CleanupPaletteViewer *m_paletteViewer;
//----Bottom Parts
diff --git a/toonz/sources/toonzlib/cleanupparameters.cpp b/toonz/sources/toonzlib/cleanupparameters.cpp
index b5bf9e7d5..ca83821bb 100644
--- a/toonz/sources/toonzlib/cleanupparameters.cpp
+++ b/toonz/sources/toonzlib/cleanupparameters.cpp
@@ -6,6 +6,7 @@
#include "toonz/toonzscene.h"
#include "toonz/sceneproperties.h"
#include "toonz/txshleveltypes.h"
+#include "toonz/cleanupcolorstyles.h"
#include "tsystem.h"
#include "tenv.h"
#include "tconvert.h"
@@ -193,7 +194,10 @@ CleanupParameters::CleanupParameters()
, m_dirtyFlag(false)
//, m_resName("")
, m_offx_lock(false)
- , m_offy_lock(false) {}
+ , m_offy_lock(false)
+ , m_altBrightness(0)
+ , m_altContrast(50)
+ , m_lpNoneFormat("tif") {}
//---------------------------------------------------------
@@ -300,8 +304,11 @@ void CleanupParameters::assign(const CleanupParameters *param,
if (clonePalette && param->m_cleanupPalette)
m_cleanupPalette = param->m_cleanupPalette->clone();
- m_offx_lock = param->m_offx_lock;
- m_offy_lock = param->m_offy_lock;
+ m_offx_lock = param->m_offx_lock;
+ m_offy_lock = param->m_offy_lock;
+ m_altBrightness = param->m_altBrightness;
+ m_altContrast = param->m_altContrast;
+ m_lpNoneFormat = param->m_lpNoneFormat;
}
//---------------------------------------------------------
@@ -330,10 +337,10 @@ void CleanupParameters::saveData(TOStream &os) const {
attr.clear();
std::string flip =
std::string(m_flipx ? "x" : "") + std::string(m_flipy ? "y" : "");
- if (flip != "") attr["flip"] = flip;
+ if (flip != "") attr["flip"] = flip;
if (m_rotate != 0) attr["rotate"] = std::to_string(m_rotate);
- if (m_offx != 0.0) attr["xoff"] = std::to_string(m_offx);
- if (m_offy != 0.0) attr["yoff"] = std::to_string(m_offy);
+ if (m_offx != 0.0) attr["xoff"] = std::to_string(m_offx);
+ if (m_offy != 0.0) attr["yoff"] = std::to_string(m_offy);
os.openCloseChild("transform", attr);
}
@@ -366,6 +373,8 @@ void CleanupParameters::saveData(TOStream &os) const {
os.openCloseChild("fdg", attr);
attr.clear();
if (m_path != TFilePath()) os.child("path") << m_path;
+ os.child("altBrightnessContrast") << m_altBrightness << m_altContrast;
+ os.child("lpNoneFormat") << m_lpNoneFormat;
}
//---------------------------------------------------------
@@ -380,6 +389,9 @@ void CleanupParameters::loadData(TIStream &is, bool globalParams) {
m_lineProcessingMode = lpNone;
m_noAntialias = false;
m_postAntialias = false;
+ // hold brightness and contrast values of another processing mode
+ m_altBrightness = -1.0;
+ m_altContrast = -1.0;
while (is.matchTag(tagName)) {
if (tagName == "cleanupPalette") {
@@ -390,42 +402,42 @@ void CleanupParameters::loadData(TIStream &is, bool globalParams) {
m_camera.loadData(is);
is.closeChild();
} else if (tagName == "autoCenter") {
- m_autocenterType = AUTOCENTER_FDG;
- std::string s = is.getTagAttribute("type");
+ m_autocenterType = AUTOCENTER_FDG;
+ std::string s = is.getTagAttribute("type");
if (s != "" && isInt(s)) m_autocenterType = (AUTOCENTER_TYPE)std::stoi(s);
- s = is.getTagAttribute("pegHoles");
+ s = is.getTagAttribute("pegHoles");
if (s != "" && isInt(s)) m_pegSide = (PEGS_SIDE)std::stoi(s);
} else if (tagName == "transform") {
- std::string s = is.getTagAttribute("flip");
- m_flipx = (s.find("x") != std::string::npos);
- m_flipy = (s.find("y") != std::string::npos);
- s = is.getTagAttribute("rotate");
- if (s != "" && isInt(s)) m_rotate = std::stoi(s);
- s = is.getTagAttribute("xoff");
+ std::string s = is.getTagAttribute("flip");
+ m_flipx = (s.find("x") != std::string::npos);
+ m_flipy = (s.find("y") != std::string::npos);
+ s = is.getTagAttribute("rotate");
+ if (s != "" && isInt(s)) m_rotate = std::stoi(s);
+ s = is.getTagAttribute("xoff");
if (s != "" && isDouble(s)) m_offx = std::stod(s);
- s = is.getTagAttribute("yoff");
+ s = is.getTagAttribute("yoff");
if (s != "" && isDouble(s)) m_offy = std::stod(s);
} else if (tagName == "lineProcessing") {
- m_lineProcessingMode = lpGrey;
- std::string s = is.getTagAttribute("sharpness");
+ m_lineProcessingMode = lpGrey;
+ std::string s = is.getTagAttribute("sharpness");
if (s != "" && isDouble(s)) m_sharpness = std::stod(s);
s = is.getTagAttribute("autoAdjust");
if (s != "" && isDouble(s))
m_autoAdjustMode = (CleanupTypes::AUTO_ADJ_MODE)std::stoi(s);
- s = is.getTagAttribute("mode");
+ s = is.getTagAttribute("mode");
if (s != "" && s == "color") m_lineProcessingMode = lpColor;
} else if (tagName == "despeckling") {
- std::string s = is.getTagAttribute("value");
+ std::string s = is.getTagAttribute("value");
if (s != "" && isInt(s)) m_despeckling = std::stoi(s);
} else if (tagName == "aaValue") {
- std::string s = is.getTagAttribute("value");
+ std::string s = is.getTagAttribute("value");
if (s != "" && isInt(s)) m_aaValue = std::stoi(s);
} else if (tagName == "noAntialias")
m_noAntialias = true;
else if (tagName == "MLAA")
m_postAntialias = true;
else if (tagName == "closestField") {
- std::string s = is.getTagAttribute("value");
+ std::string s = is.getTagAttribute("value");
if (s != "" && isDouble(s)) m_closestField = std::stod(s);
} else if (tagName == "fdg") {
std::string s = is.getTagAttribute("name");
@@ -433,10 +445,26 @@ void CleanupParameters::loadData(TIStream &is, bool globalParams) {
} else if (tagName == "path") {
is >> m_path;
is.closeChild();
+ } else if (tagName == "altBrightnessContrast") {
+ is >> m_altBrightness >> m_altContrast;
+ is.closeChild();
+ } else if (tagName == "lpNoneFormat") {
+ is >> m_lpNoneFormat;
+ is.closeChild();
} else
is.skipCurrentTag();
}
+ if ((m_altBrightness < 0.0 || m_altContrast < 0.0) && m_cleanupPalette &&
+ m_cleanupPalette->getStyleCount() >= 2) {
+ TCleanupStyle *blackStyle =
+ dynamic_cast<TCleanupStyle *>(m_cleanupPalette->getStyle(1));
+ if (blackStyle) {
+ m_altBrightness = blackStyle->getBrightness();
+ m_altContrast = blackStyle->getContrast();
+ }
+ }
+
CleanupParameters::LastSavedParameters.assign(this);
if (globalParams) CleanupParameters::GlobalParameters.assign(this);
}
diff --git a/toonz/sources/toonzlib/tcleanupper.cpp b/toonz/sources/toonzlib/tcleanupper.cpp
index 3c69ba8ba..3b66ef97b 100644
--- a/toonz/sources/toonzlib/tcleanupper.cpp
+++ b/toonz/sources/toonzlib/tcleanupper.cpp
@@ -160,7 +160,7 @@ HSVColor HSVColor::fromRGB(double r, double g, double b) {
h = 2.0 + (b - r) / delta;
else if (b == max)
h = 4.0 + (r - g) / delta;
- h = h * 60.0;
+ h = h * 60.0;
if (h < 0) h += 360.0;
}
@@ -569,7 +569,7 @@ TRasterP TCleanupper::processColors(const TRasterP &rin) {
CleanupPreprocessedImage *TCleanupper::process(
TRasterImageP &image, bool first_image, TRasterImageP &onlyResampledImage,
bool isCameraTest, bool returnResampled, bool onlyForSwatch,
- TAffine *resampleAff) {
+ TAffine *resampleAff, TRasterP templateForResampled) {
TAffine aff;
double blur;
TDimension outDim(0, 0);
@@ -682,7 +682,9 @@ CleanupPreprocessedImage *TCleanupper::process(
TRasterP tmp_ras;
if (returnResampled || (fromGr8 && toGr8)) {
- if (fromGr8 && toGr8)
+ if (templateForResampled)
+ tmp_ras = templateForResampled->create(outDim.lx, outDim.ly);
+ else if (fromGr8 && toGr8)
tmp_ras = TRasterGR8P(outDim);
else
tmp_ras = TRaster32P(outDim);
@@ -709,7 +711,7 @@ CleanupPreprocessedImage *TCleanupper::process(
flt_type = TRop::Hann2;
TRop::resample(tmp_ras, image->getRaster(), aff, flt_type, blur);
- if ((TRaster32P)tmp_ras)
+ if ((TRaster32P)tmp_ras && !templateForResampled)
// Add white background to deal with semitransparent pixels
TRop::addBackground(tmp_ras, TPixel32::White);
diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp
index 380fc5bd5..b867a91fe 100644
--- a/toonz/sources/toonzlib/txshsimplelevel.cpp
+++ b/toonz/sources/toonzlib/txshsimplelevel.cpp
@@ -642,7 +642,8 @@ void TXshSimpleLevel::loadAllIconsAndPutInCache(bool cacheImagesAsWell) {
//-----------------------------------------------------------------------------
-TRasterImageP TXshSimpleLevel::getFrameToCleanup(const TFrameId &fid) const {
+TRasterImageP TXshSimpleLevel::getFrameToCleanup(const TFrameId &fid,
+ bool toBeLineProcessed) const {
assert(m_type != UNKNOWN_XSHLEVEL);
FramesSet::const_iterator ft = m_frames.find(fid);
@@ -652,8 +653,12 @@ TRasterImageP TXshSimpleLevel::getFrameToCleanup(const TFrameId &fid) const {
std::string imageId = getImageId(fid, flag ? Scanned : 0);
ImageLoader::BuildExtData extData(this, fid, 1);
- TRasterImageP img = ImageManager::instance()->getImage(
- imageId, ImageManager::dontPutInCache, &extData);
+
+ UCHAR imFlags = ImageManager::dontPutInCache;
+ // if lines are not processed, obtain the original sampled image
+ if (!toBeLineProcessed) imFlags |= ImageManager::is64bitEnabled;
+ TRasterImageP img =
+ ImageManager::instance()->getImage(imageId, imFlags, &extData);
if (!img) return img;
double x_dpi, y_dpi;