Add support for TIFF format. Closes smart-pattern/valentina#87

This commit is contained in:
Roman Telezhynskyi 2021-01-23 18:47:41 +02:00
parent f81babbf7b
commit 2406e98350
12 changed files with 67 additions and 7 deletions

View File

@ -10,6 +10,7 @@
- Improve restrict dimension dialog. Disable not available combinations.
- Improve multisize measurements format. Allow excluding combinations inside min/max range.
- New warning. Grainline is not valid.
- [smart-pattern/valentina#87] Add support for TIFF format.
# Version 0.7.41 Dec 4, 2020
- Bug fixes.

View File

@ -44,9 +44,9 @@ build:
# OPTIONAL: ingredient packages are packages which become part of the AppImage.
# you may want to remove parts of their content in script section.
# ingredients:
# packages:
# - xterm
ingredients:
packages:
- libqt5-qtimageformats
script:
# OPTIONAL: compile or modify the AppDir. The environment variables:
@ -59,6 +59,7 @@ script:
# create the image file
- unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
- rm -rf /usr/share/licenses/libqt5-qtimageformats
# bundle icu's data
- mkdir -p $BUILD_APPDIR/usr/share/icu
- cp /usr/share/icu/*/icudt*.dat $BUILD_APPDIR/usr/share/icu/

View File

@ -16,7 +16,7 @@ Vcs-Browser: https://gitlab.com/smart-pattern/valentina
Package: valentina
Architecture: i386 amd64
Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.4.0) | libqt5core5 (>= 5.4.0), libqt5gui5 (>= 5.4.0) | libqt5gui5-gles (>= 5.4.0), libqt5printsupport5 (>= 5.4.0), libqt5svg5 (>= 5.4.0), libqt5widgets5 (>= 5.4.0), libqt5xml5 (>= 5.4.0), libqt5xmlpatterns5 (>= 5.4.0), libqt5concurrent5(>= 5.4.0), libqt5opengl5 (>= 5.4.0), libstdc++6 (>= 4.8), poppler-utils
Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.4.0) | libqt5core5 (>= 5.4.0), libqt5gui5 (>= 5.4.0) | libqt5gui5-gles (>= 5.4.0), libqt5printsupport5 (>= 5.4.0), libqt5svg5 (>= 5.4.0), libqt5widgets5 (>= 5.4.0), libqt5xml5 (>= 5.4.0), libqt5xmlpatterns5 (>= 5.4.0), libqt5concurrent5(>= 5.4.0), libqt5opengl5 (>= 5.4.0), libstdc++6 (>= 4.8), poppler-utils, qt5-image-formats-plugins (>= 5.4.0)
Conflicts: seamly2d
Description: Pattern making program.
Valentina is a cross-platform patternmaking program which allows designers

View File

@ -129,7 +129,10 @@ The path to output destination folder. By default the directory at which the app
.BR "*" " AutoCAD DXF 2013 ASTM файли (*.dxf) = 32,"
.RE
.RS
.BR "*" " PDF tiled files (*.pdf) = 33."
.BR "*" " PDF tiled files (*.pdf) = 33,"
.RE
.RS
.BR "*" " TIFF файли (*.tif) = 35."
.RE
.IP "--bdxf"
.RB "Export dxf in binary form."

2
dist/debian/control vendored
View File

@ -16,7 +16,7 @@ Vcs-Browser: https://gitlab.com/smart-pattern/valentina
Package: valentina
Architecture: i386 amd64
Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.4.0) | libqt5core5 (>= 5.4.0), libqt5gui5 (>= 5.4.0) | libqt5gui5-gles (>= 5.4.0), libqt5printsupport5 (>= 5.4.0), libqt5svg5 (>= 5.4.0), libqt5widgets5 (>= 5.4.0), libqt5xml5 (>= 5.4.0), libqt5xmlpatterns5 (>= 5.4.0), libqt5concurrent5(>= 5.4.0), libqt5opengl5 (>= 5.4.0), libstdc++6 (>= 4.8), poppler-utils
Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.4.0) | libqt5core5 (>= 5.4.0), libqt5gui5 (>= 5.4.0) | libqt5gui5-gles (>= 5.4.0), libqt5printsupport5 (>= 5.4.0), libqt5svg5 (>= 5.4.0), libqt5widgets5 (>= 5.4.0), libqt5xml5 (>= 5.4.0), libqt5xmlpatterns5 (>= 5.4.0), libqt5concurrent5(>= 5.4.0), libqt5opengl5 (>= 5.4.0), libstdc++6 (>= 4.8), poppler-utils, qt5-image-formats-plugins (>= 5.4.0)
Conflicts: seamly2d
Description: Pattern making program.
Valentina is a cross-platform patternmaking program which allows designers

View File

@ -129,7 +129,10 @@ The path to output destination folder. By default the directory at which the app
.BR "*" " AutoCAD DXF 2013 ASTM файли (*.dxf) = 32,"
.RE
.RS
.BR "*" " PDF tiled files (*.pdf) = 33."
.BR "*" " PDF tiled files (*.pdf) = 33,"
.RE
.RS
.BR "*" " TIFF файли (*.tif) = 35."
.RE
.IP "--bdxf"
.RB "Export dxf in binary form."

View File

@ -43,6 +43,8 @@ BuildRequires: libproxy-pacrunner
BuildRequires: qttools5
BuildRequires: qtbase5-common-devel >= 5.4.0
Requires: qtimageformats5
%if 0%{?mageia} == 6
BuildRequires: pkgconfig(openssl)
%else
@ -58,6 +60,8 @@ BuildRequires: libqt5-qttools
BuildRequires: libQt5Svg-devel
BuildRequires: update-desktop-files
Requires: libqt5-qtimageformats
%if 0%{?suse_version} == 1310
BuildRequires: libQt5XmlPatterns-devel
%endif

View File

@ -235,6 +235,7 @@ void DialogSaveLayout::SetBinaryDXFFormat(bool binary)
case LayoutExportFormats::PS:
case LayoutExportFormats::EPS:
case LayoutExportFormats::NC:
case LayoutExportFormats::TIF:
default:
ui->checkBoxBinaryDXF->setChecked(false);
break;
@ -282,6 +283,7 @@ bool DialogSaveLayout::IsBinaryDXFFormat() const
case LayoutExportFormats::PS:
case LayoutExportFormats::EPS:
case LayoutExportFormats::NC:
case LayoutExportFormats::TIF:
default:
return false;
}
@ -421,6 +423,8 @@ QString DialogSaveLayout::ExportFormatDescription(LayoutExportFormats format)
return QStringLiteral("PDF %1 %2 (*.pdf)").arg(tr("tiled"), filesStr);
case LayoutExportFormats::NC:
return QStringLiteral("%1 %2 (*.nc)").arg(tr("Numerical control"), filesStr);
case LayoutExportFormats::TIF:
return QStringLiteral("TIFF %1 (*.tif)").arg(filesStr);
default:
return QString();
}
@ -474,6 +478,8 @@ QString DialogSaveLayout::ExportFormatSuffix(LayoutExportFormats format)
return QStringLiteral(".dxf");
case LayoutExportFormats::NC:
return QStringLiteral(".nc");
case LayoutExportFormats::TIF:
return QStringLiteral(".tif");
default:
return QString();
}
@ -606,6 +612,7 @@ void DialogSaveLayout::ShowExample()
case LayoutExportFormats::PS:
case LayoutExportFormats::EPS:
case LayoutExportFormats::NC:
case LayoutExportFormats::TIF:
default:
break;
}
@ -843,6 +850,7 @@ QVector<std::pair<QString, LayoutExportFormats> > DialogSaveLayout::InitFormats(
InitFormat(LayoutExportFormats::DXF_AC1027_ASTM);
InitFormat(LayoutExportFormats::PDFTiled);
// InitFormat(LayoutExportFormats::NC);
InitFormat(LayoutExportFormats::TIF);
return list;
}

View File

@ -1200,6 +1200,11 @@ void MainWindowsNoGUI::ExportScene(const QList<QGraphicsScene *> &scenes,
exporter.ExportToFlatDXF(scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::TIF:
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
exporter.ExportToTIF(scene);
break;
default:
qDebug() << "Can't recognize file type." << Q_FUNC_INFO;
break;

View File

@ -73,6 +73,7 @@ enum class LayoutExportFormats : qint8
DXF_AC1027_ASTM = 32, /* ACAD 2013. */
PDFTiled = 33,
NC = 34, /*G-code. Reserved for future*/
TIF = 35,
COUNT /*Use only for validation*/
};

View File

@ -38,6 +38,7 @@
#include <QtDebug>
#include <QCursor>
#include <QGraphicsItem>
#include <QImageWriter>
#include "../vmisc/vmath.h"
#include "../vmisc/defglobal.h"
@ -169,6 +170,38 @@ void VLayoutExporter::ExportToPNG(QGraphicsScene *scene) const
image.save(m_fileName);
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToTIF(QGraphicsScene *scene) const
{
// Create the image with the exact size of the shrunk scene
QSize drawingSize;
drawingSize.setWidth(qFloor(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right()));
drawingSize.setHeight(qFloor(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom()));
QImage image(drawingSize, QImage::Format_ARGB32);
image.fill(Qt::white);
QPainter painter(&image);
painter.translate(m_margins.left(), m_margins.top());
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(m_pen);
painter.setBrush(QBrush(Qt::NoBrush));
painter.scale(m_xScale, m_yScale);
scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio);
QImageWriter writer;
writer.setFormat("TIF");
writer.setCompression(1); // LZW-compression
writer.setFileName(m_fileName);
if (not writer.write(image))
{ // failed to save file
qCritical() << qUtf8Printable(tr("Can't save file '%1'. Error: %2.").arg(m_fileName, writer.errorString()));
return;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutExporter::ExportToPDF(QGraphicsScene *scene) const
{

View File

@ -79,6 +79,7 @@ public:
void ExportToSVG(QGraphicsScene *scene) const;
void ExportToPNG(QGraphicsScene *scene) const;
void ExportToTIF(QGraphicsScene *scene) const;
void ExportToPDF(QGraphicsScene *scene) const;
void ExportToOBJ(QGraphicsScene *scene) const;
void ExportToPS(QGraphicsScene *scene) const;