Skip to content

Commit

Permalink
~ Fixed: mixed pixels after cropping at page layout stage.
Browse files Browse the repository at this point in the history
(relates to 226d5ff)
  • Loading branch information
4lex4 committed Apr 9, 2018
1 parent 08ab1e0 commit 822ba3f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
12 changes: 11 additions & 1 deletion filters/page_layout/CacheDrivenTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ void CacheDrivenTask::process(const PageInfo& page_info,
const QPolygonF page_rect_phys(Utils::calcPageRectPhys(xform, content_rect_phys, new_params,
m_ptrSettings->getAggregateHardSizeMM(),
m_ptrSettings->getAggregateContentRect()));

ImageTransformation new_xform(xform);
new_xform.setPostCropArea(xform.transform().map(page_rect_phys));
new_xform.setPostCropArea(shiftToRoundedOrigin(new_xform.transform().map(page_rect_phys)));

if (m_ptrNextTask) {
m_ptrNextTask->process(page_info, collector, new_xform, content_rect_phys);
Expand All @@ -80,4 +81,13 @@ void CacheDrivenTask::process(const PageInfo& page_info,
m_ptrSettings->deviationProvider().isDeviant(page_info.id(), deviationCoef, deviationThreshold))));
}
} // CacheDrivenTask::process

QPolygonF CacheDrivenTask::shiftToRoundedOrigin(const QPolygonF& poly) {
const double x = poly.boundingRect().left();
const double y = poly.boundingRect().top();
const double shift_value_x = -(x - std::round(x));
const double shift_value_y = -(y - std::round(y));

return poly.translated(shift_value_x, shift_value_y);
}
} // namespace page_layout
3 changes: 3 additions & 0 deletions filters/page_layout/CacheDrivenTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "NonCopyable.h"
#include "ref_countable.h"
#include "intrusive_ptr.h"
#include <QPolygonF>

class QRectF;
class PageInfo;
Expand Down Expand Up @@ -50,6 +51,8 @@ class CacheDrivenTask : public ref_countable {
const QRectF& content_rect);

private:
static QPolygonF shiftToRoundedOrigin(const QPolygonF& poly);

intrusive_ptr<output::CacheDrivenTask> m_ptrNextTask;
intrusive_ptr<Settings> m_ptrSettings;
};
Expand Down
13 changes: 11 additions & 2 deletions filters/page_layout/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,24 @@ FilterResultPtr Task::process(const TaskStatus& status,
m_ptrSettings->getAggregateContentRect()));

ImageTransformation new_xform(data.xform());
new_xform.setPostCropArea(new_xform.transform().map(page_rect_phys));
new_xform.setPostCropArea(shiftToRoundedOrigin(new_xform.transform().map(page_rect_phys)));

return m_ptrNextTask->process(status, FilterData(data, new_xform), content_rect_phys);
} else {
return make_intrusive<UiUpdater>(m_ptrFilter, m_ptrSettings, m_pageId, data.origImage(), data.xform(),
adapted_content_rect, agg_hard_size_before != agg_hard_size_after,
m_batchProcessing);
}
} // Task::process
}

QPolygonF Task::shiftToRoundedOrigin(const QPolygonF& poly) {
const double x = poly.boundingRect().left();
const double y = poly.boundingRect().top();
const double shift_value_x = -(x - std::round(x));
const double shift_value_y = -(y - std::round(y));

return poly.translated(shift_value_x, shift_value_y);
}

/*============================ Task::UiUpdater ==========================*/

Expand Down
3 changes: 3 additions & 0 deletions filters/page_layout/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ref_countable.h"
#include "FilterResult.h"
#include "PageId.h"
#include <QPolygonF>

class TaskStatus;
class FilterData;
Expand Down Expand Up @@ -59,6 +60,8 @@ class Task : public ref_countable {
private:
class UiUpdater;

static QPolygonF shiftToRoundedOrigin(const QPolygonF& poly);

intrusive_ptr<Filter> m_ptrFilter;
intrusive_ptr<output::Task> m_ptrNextTask;
intrusive_ptr<Settings> m_ptrSettings;
Expand Down

0 comments on commit 822ba3f

Please sign in to comment.