use dpi of the first cleanupped frame (#1391)

This commit is contained in:
shun-iwasawa 2017-08-10 18:35:45 +09:00 committed by masafumi-inoue
parent 7f20440e9d
commit e0fcf9792b
6 changed files with 47 additions and 28 deletions

View file

@ -57,7 +57,7 @@ public:
class DVAPI TCleanupper { class DVAPI TCleanupper {
CleanupParameters *m_parameters; CleanupParameters *m_parameters;
TPointD m_customDpi; TPointD m_sourceDpi;
private: private:
TCleanupper() TCleanupper()
@ -101,8 +101,8 @@ time, to unlock a possibly useful memory block.
TRasterImageP autocenterOnly(const TRasterImageP &image, bool isCameraTest, TRasterImageP autocenterOnly(const TRasterImageP &image, bool isCameraTest,
bool &autocentered); bool &autocentered);
TPointD getCustomDpi() const { return m_customDpi; } TPointD getSourceDpi() const { return m_sourceDpi; }
void setCustomDpi(const TPointD &dpi) { m_customDpi = dpi; } void setSourceDpi(const TPointD &dpi) { m_sourceDpi = dpi; }
private: private:
// process phase // process phase

View file

@ -439,10 +439,19 @@ static void cleanupLevel(TXshSimpleLevel *xl, std::set<TFrameId> fidsInXsheet,
updater.update(fid, ri); updater.update(fid, ri);
continue; continue;
} }
double dpix, dpiy; // Obtain the source dpi. Changed it to be done once at the first frame of
original->getDpi(dpix, dpiy); // each level in order to avoid the following problem:
cl->setCustomDpi((dpix == 0 && dpiy == 0) ? xl->getProperties()->getDpi() // If the original raster level has no dpi (such as TGA images), obtaining
: TPointD()); // 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; CleanupPreprocessedImage *cpi;
{ {

View file

@ -292,9 +292,9 @@ CleanupPopup::CleanupPopup()
, m_params(new CleanupParameters) , m_params(new CleanupParameters)
, m_updater(new LevelUpdater) , m_updater(new LevelUpdater)
, m_originalLevelPath() , m_originalLevelPath()
, m_originalPalette(0) { , m_originalPalette(0)
, m_firstLevelFrame(true) {
setWindowTitle(tr("Cleanup")); setWindowTitle(tr("Cleanup"));
// Progress Bar // Progress Bar
m_progressLabel = new QLabel(tr("Cleanup in progress")); m_progressLabel = new QLabel(tr("Cleanup in progress"));
m_progressBar = new QProgressBar; m_progressBar = new QProgressBar;
@ -1217,10 +1217,20 @@ void CleanupPopup::cleanupFrame() {
IconGenerator::instance()->invalidate(sl, fid); IconGenerator::instance()->invalidate(sl, fid);
} else { } else {
// Perform main processing // Perform main processing
double dpix, dpiy;
original->getDpi(dpix, dpiy); // Obtain the source dpi. Changed it to be done once at the first frame of
cl->setCustomDpi((dpix == 0 && dpiy == 0) ? sl->getProperties()->getDpi() // each level in order to avoid the following problem:
: TPointD()); // 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; CleanupPreprocessedImage *cpi;
{ {

View file

@ -420,10 +420,10 @@ void CleanupSettingsModel::processFrame(TXshSimpleLevel *sl, TFrameId fid) {
bool doCameraTest = (m_cameraTestsCount > 0); bool doCameraTest = (m_cameraTestsCount > 0);
// Retrieve new image dpi // Retrieve new image dpi
double dpix, dpiy; TPointD dpi;
imageToCleanup->getDpi(dpix, dpiy); imageToCleanup->getDpi(dpi.x, dpi.y);
cl->setCustomDpi((dpix == 0 && dpiy == 0) ? sl->getProperties()->getDpi() if (dpi.x == 0 && dpi.y == 0) dpi = sl->getProperties()->getDpi();
: TPointD()); cl->setSourceDpi(dpi);
// Perform primary cleanup processing // Perform primary cleanup processing
if (doProcessing) { if (doProcessing) {

View file

@ -1332,13 +1332,13 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference) {
if (yetToCleanupCell) // ORIENTATION: what's this? if (yetToCleanupCell) // ORIENTATION: what's this?
{ {
if (o->isVerticalTimeline()) if (o->isVerticalTimeline())
p.fillRect( p.fillRect(rect.adjusted(rect.width() / 2, 0, 0, 0),
rect.adjusted(rect.width() / 2, 0, 0, 0), (isSelected) ? m_viewer->getSelectedFullcolorColumnColor()
(isSelected) ? SelectedFullcolorColumnColor : FullcolorColumnColor); : m_viewer->getFullcolorColumnColor());
else else
p.fillRect( p.fillRect(rect.adjusted(0, rect.height() / 2, 0, 0),
rect.adjusted(0, rect.height() / 2, 0, 0), (isSelected) ? m_viewer->getSelectedFullcolorColumnColor()
(isSelected) ? SelectedFullcolorColumnColor : FullcolorColumnColor); : m_viewer->getFullcolorColumnColor());
} }
bool isLastRow = nextCell.isEmpty() || bool isLastRow = nextCell.isEmpty() ||

View file

@ -416,11 +416,11 @@ bool TCleanupper::getResampleValues(const TRasterImageP &image, TAffine &aff,
saveBox.getLy() > 0 && saveBox.getLy() < rasterLy)) saveBox.getLy() > 0 && saveBox.getLy() < rasterLy))
raster_is_savebox = false; raster_is_savebox = false;
image->getDpi(dpi.x, dpi.y); // Use the same source dpi throughout the level
if (dpi == TPointD()) { dpi = getSourceDpi();
dpi = getCustomDpi(); if (dpi == TPointD())
if (dpi == TPointD()) dpi.x = dpi.y = 65.0; // using 65.0 as default DPI dpi.x = dpi.y = 65.0; // using 65.0 as default DPI //??????WHY
} else if (!dpi.x) else if (!dpi.x)
dpi.x = dpi.y; dpi.x = dpi.y;
else if (!dpi.y) else if (!dpi.y)
dpi.y = dpi.x; dpi.y = dpi.x;