Show shape/opacity channel

This commit is contained in:
Jakub Melka 2021-04-05 19:21:45 +02:00
parent 9aba0608c3
commit 08f7b9480f
3 changed files with 76 additions and 2 deletions

View File

@ -50,6 +50,8 @@ OutputPreviewDialog::OutputPreviewDialog(const pdf::PDFDocument* document, pdf::
ui->displayModeComboBox->addItem(tr("Color Warnings | Ink Coverage"), OutputPreviewWidget::ColorWarningInkCoverage);
ui->displayModeComboBox->addItem(tr("Color Warnings | Rich Black"), OutputPreviewWidget::ColorWarningRichBlack);
ui->displayModeComboBox->addItem(tr("Ink Coverage"), OutputPreviewWidget::InkCoverage);
ui->displayModeComboBox->addItem(tr("Shape Channel"), OutputPreviewWidget::ShapeChannel);
ui->displayModeComboBox->addItem(tr("Opacity Channel"), OutputPreviewWidget::OpacityChannel);
ui->displayModeComboBox->setCurrentIndex(0);
ui->imageWidget->setInkMapper(&m_inkMapper);

View File

@ -58,6 +58,8 @@ void OutputPreviewWidget::clear()
m_alarmCoverageImage.dirty();
m_alarmRichBlackImage.dirty();
m_inkCoverageImage.dirty();
m_shapeMask.dirty();
m_opacityMask.dirty();
update();
}
@ -80,6 +82,8 @@ void OutputPreviewWidget::setPageImage(QImage image, pdf::PDFFloatBitmapWithColo
m_alarmCoverageImage.dirty();
m_alarmRichBlackImage.dirty();
m_inkCoverageImage.dirty();
m_shapeMask.dirty();
m_opacityMask.dirty();
buildInfoBoxItems();
update();
@ -147,6 +151,28 @@ void OutputPreviewWidget::paintEvent(QPaintEvent* event)
break;
}
case ShapeChannel:
{
const QImage& image = getShapeImage();
if (!image.isNull())
{
painter.translate(0, (pageImageRect.height() - image.height()) / 2);
painter.drawImage(pageImageRect.topLeft(), image);
}
break;
}
case OpacityChannel:
{
const QImage& image = getOpacityImage();
if (!image.isNull())
{
painter.translate(0, (pageImageRect.height() - image.height()) / 2);
painter.drawImage(pageImageRect.topLeft(), image);
}
break;
}
default:
Q_ASSERT(false);
}
@ -398,6 +424,7 @@ void OutputPreviewWidget::buildInfoBoxItems()
case Separations:
case ColorWarningInkCoverage:
case ColorWarningRichBlack:
case InkCoverage:
{
if (m_originalProcessBitmap.getWidth() > 0 && m_originalProcessBitmap.getHeight() > 0)
{
@ -502,7 +529,8 @@ void OutputPreviewWidget::buildInfoBoxItems()
break;
}
case InkCoverage:
case ShapeChannel:
case OpacityChannel:
break;
default:
@ -559,6 +587,12 @@ void OutputPreviewWidget::buildInfoBoxItems()
}
}
if (m_displayMode == ShapeChannel || m_displayMode == OpacityChannel)
{
addInfoBoxSeparator();
addInfoBoxHeader(tr("Shape/Opacity"));
}
if (sampleColor.isValid())
{
addInfoBoxSeparator();
@ -610,6 +644,16 @@ const OutputPreviewWidget::InkCoverageInfo& OutputPreviewWidget::getInkCoverageI
return m_inkCoverageImage.get(this, &OutputPreviewWidget::getInkCoverageInfoImpl);
}
const QImage& OutputPreviewWidget::getShapeImage() const
{
return m_shapeMask.get(this, &OutputPreviewWidget::getShapeImageImpl);
}
const QImage& OutputPreviewWidget::getOpacityImage() const
{
return m_opacityMask.get(this, &OutputPreviewWidget::getOpacityImageImpl);
}
std::vector<pdf::PDFColorComponent> OutputPreviewWidget::getInkCoverageImpl() const
{
std::vector<pdf::PDFColorComponent> result;
@ -772,6 +816,26 @@ OutputPreviewWidget::InkCoverageInfo OutputPreviewWidget::getInkCoverageInfoImpl
return coverageInfo;
}
QImage OutputPreviewWidget::getShapeImageImpl() const
{
if (!m_originalProcessBitmap.getPixelFormat().hasShapeChannel())
{
return QImage();
}
return m_originalProcessBitmap.getChannelImage(m_originalProcessBitmap.getPixelFormat().getShapeChannelIndex());
}
QImage OutputPreviewWidget::getOpacityImageImpl() const
{
if (!m_originalProcessBitmap.getPixelFormat().hasOpacityChannel())
{
return QImage();
}
return m_originalProcessBitmap.getChannelImage(m_originalProcessBitmap.getPixelFormat().getOpacityChannelIndex());
}
pdf::PDFColorComponent OutputPreviewWidget::getRichBlackLimit() const
{
return m_richBlackLimit;

View File

@ -40,7 +40,9 @@ public:
Separations,
ColorWarningInkCoverage,
ColorWarningRichBlack,
InkCoverage
InkCoverage,
ShapeChannel,
OpacityChannel
};
virtual QSize sizeHint() const override;
@ -107,11 +109,15 @@ private:
const AlarmImageInfo& getAlarmCoverageImage() const;
const AlarmImageInfo& getAlarmRichBlackImage() const;
const InkCoverageInfo& getInkCoverageInfo() const;
const QImage& getShapeImage() const;
const QImage& getOpacityImage() const;
std::vector<pdf::PDFColorComponent> getInkCoverageImpl() const;
AlarmImageInfo getAlarmCoverageImageImpl() const;
AlarmImageInfo getAlarmRichBlackImageImpl() const;
InkCoverageInfo getInkCoverageInfoImpl() const;
QImage getShapeImageImpl() const;
QImage getOpacityImageImpl() const;
enum InfoBoxStyle
{
@ -150,6 +156,8 @@ private:
mutable pdf::PDFCachedItem<AlarmImageInfo> m_alarmCoverageImage;
mutable pdf::PDFCachedItem<AlarmImageInfo> m_alarmRichBlackImage;
mutable pdf::PDFCachedItem<InkCoverageInfo> m_inkCoverageImage;
mutable pdf::PDFCachedItem<QImage> m_opacityMask;
mutable pdf::PDFCachedItem<QImage> m_shapeMask;
QImage m_pageImage;
pdf::PDFFloatBitmapWithColorSpace m_originalProcessBitmap;