diff --git a/toonz/sources/include/toonz/tcleanupper.h b/toonz/sources/include/toonz/tcleanupper.h index d6a1859f..3a2ac95a 100644 --- a/toonz/sources/include/toonz/tcleanupper.h +++ b/toonz/sources/include/toonz/tcleanupper.h @@ -57,7 +57,7 @@ public: class DVAPI TCleanupper { CleanupParameters *m_parameters; - TPointD m_customDpi; + TPointD m_sourceDpi; private: TCleanupper() @@ -101,8 +101,8 @@ time, to unlock a possibly useful memory block. TRasterImageP autocenterOnly(const TRasterImageP &image, bool isCameraTest, bool &autocentered); - TPointD getCustomDpi() const { return m_customDpi; } - void setCustomDpi(const TPointD &dpi) { m_customDpi = dpi; } + TPointD getSourceDpi() const { return m_sourceDpi; } + void setSourceDpi(const TPointD &dpi) { m_sourceDpi = dpi; } private: // process phase diff --git a/toonz/sources/tcleanupper/tcleanupper.cpp b/toonz/sources/tcleanupper/tcleanupper.cpp index b7503872..d22a1aa9 100644 --- a/toonz/sources/tcleanupper/tcleanupper.cpp +++ b/toonz/sources/tcleanupper/tcleanupper.cpp @@ -439,10 +439,19 @@ static void cleanupLevel(TXshSimpleLevel *xl, std::set fidsInXsheet, updater.update(fid, ri); continue; } - double dpix, dpiy; - original->getDpi(dpix, dpiy); - cl->setCustomDpi((dpix == 0 && dpiy == 0) ? xl->getProperties()->getDpi() - : TPointD()); + // 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 (firstImage) { + TPointD dpi; + original->getDpi(dpi.x, dpi.y); + if (dpi.x == 0 && dpi.y == 0) dpi = xl->getProperties()->getDpi(); + cl->setSourceDpi(dpi); + } CleanupPreprocessedImage *cpi; { diff --git a/toonz/sources/toonz/cleanuppopup.cpp b/toonz/sources/toonz/cleanuppopup.cpp index 252443d2..88604aae 100644 --- a/toonz/sources/toonz/cleanuppopup.cpp +++ b/toonz/sources/toonz/cleanuppopup.cpp @@ -292,9 +292,9 @@ CleanupPopup::CleanupPopup() , m_params(new CleanupParameters) , m_updater(new LevelUpdater) , m_originalLevelPath() - , m_originalPalette(0) { + , m_originalPalette(0) + , m_firstLevelFrame(true) { setWindowTitle(tr("Cleanup")); - // Progress Bar m_progressLabel = new QLabel(tr("Cleanup in progress")); m_progressBar = new QProgressBar; @@ -1217,10 +1217,20 @@ void CleanupPopup::cleanupFrame() { IconGenerator::instance()->invalidate(sl, fid); } else { // Perform main processing - double dpix, dpiy; - original->getDpi(dpix, dpiy); - cl->setCustomDpi((dpix == 0 && dpiy == 0) ? sl->getProperties()->getDpi() - : TPointD()); + + // 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; { diff --git a/toonz/sources/toonz/cleanupsettingsmodel.cpp b/toonz/sources/toonz/cleanupsettingsmodel.cpp index 559caea2..499570a3 100644 --- a/toonz/sources/toonz/cleanupsettingsmodel.cpp +++ b/toonz/sources/toonz/cleanupsettingsmodel.cpp @@ -420,10 +420,10 @@ void CleanupSettingsModel::processFrame(TXshSimpleLevel *sl, TFrameId fid) { bool doCameraTest = (m_cameraTestsCount > 0); // Retrieve new image dpi - double dpix, dpiy; - imageToCleanup->getDpi(dpix, dpiy); - cl->setCustomDpi((dpix == 0 && dpiy == 0) ? sl->getProperties()->getDpi() - : TPointD()); + TPointD dpi; + imageToCleanup->getDpi(dpi.x, dpi.y); + if (dpi.x == 0 && dpi.y == 0) dpi = sl->getProperties()->getDpi(); + cl->setSourceDpi(dpi); // Perform primary cleanup processing if (doProcessing) { diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp index c64c40cb..11d818a1 100644 --- a/toonz/sources/toonz/xshcellviewer.cpp +++ b/toonz/sources/toonz/xshcellviewer.cpp @@ -1332,13 +1332,13 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference) { if (yetToCleanupCell) // ORIENTATION: what's this? { if (o->isVerticalTimeline()) - p.fillRect( - rect.adjusted(rect.width() / 2, 0, 0, 0), - (isSelected) ? SelectedFullcolorColumnColor : FullcolorColumnColor); + p.fillRect(rect.adjusted(rect.width() / 2, 0, 0, 0), + (isSelected) ? m_viewer->getSelectedFullcolorColumnColor() + : m_viewer->getFullcolorColumnColor()); else - p.fillRect( - rect.adjusted(0, rect.height() / 2, 0, 0), - (isSelected) ? SelectedFullcolorColumnColor : FullcolorColumnColor); + p.fillRect(rect.adjusted(0, rect.height() / 2, 0, 0), + (isSelected) ? m_viewer->getSelectedFullcolorColumnColor() + : m_viewer->getFullcolorColumnColor()); } bool isLastRow = nextCell.isEmpty() || diff --git a/toonz/sources/toonzlib/tcleanupper.cpp b/toonz/sources/toonzlib/tcleanupper.cpp index 76475488..ab10c53c 100644 --- a/toonz/sources/toonzlib/tcleanupper.cpp +++ b/toonz/sources/toonzlib/tcleanupper.cpp @@ -416,11 +416,11 @@ bool TCleanupper::getResampleValues(const TRasterImageP &image, TAffine &aff, saveBox.getLy() > 0 && saveBox.getLy() < rasterLy)) raster_is_savebox = false; - image->getDpi(dpi.x, dpi.y); - if (dpi == TPointD()) { - dpi = getCustomDpi(); - if (dpi == TPointD()) dpi.x = dpi.y = 65.0; // using 65.0 as default DPI - } else if (!dpi.x) + // Use the same source dpi throughout the level + dpi = getSourceDpi(); + if (dpi == TPointD()) + dpi.x = dpi.y = 65.0; // using 65.0 as default DPI //??????WHY + else if (!dpi.x) dpi.x = dpi.y; else if (!dpi.y) dpi.y = dpi.x;