[Libreoffice-commits] core.git: vcl/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Feb 22 14:29:44 UTC 2017
vcl/source/gdi/pdfwriter_impl.cxx | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
New commits:
commit 57c5ad79609134e0ff0013a002cc80a570e81c20
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Feb 22 14:51:16 2017 +0100
tdf#106059 PDF export: set matrix and bbox for PDF images
We still unconditionally refer to the bitmap, but now the correct
/Matrix and /BBox is set along with the necessary scaling inside the
stream, so that when there will be a vector image reference, it'll
appear at the correct position / size.
Change-Id: I9c13c11fe76995b3b3d31a135eeaa895ee0abb0d
Reviewed-on: https://gerrit.libreoffice.org/34543
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index b18f4fc..be69ad0 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -11184,6 +11184,19 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
if (!updateObject(rObject.m_nFormObject))
return false;
+ // Count /Matrix and /BBox.
+ // vcl::ImportPDF() works with 96 DPI so use the same values here, too.
+ sal_Int32 nOldDPIX = getReferenceDevice()->GetDPIX();
+ getReferenceDevice()->SetDPIX(96);
+ sal_Int32 nOldDPIY = getReferenceDevice()->GetDPIY();
+ getReferenceDevice()->SetDPIY(96);
+ Size aSize = getReferenceDevice()->PixelToLogic(rObject.m_aBitmap.GetPrefSize(), MapMode(m_aMapMode.GetMapUnit()));
+ getReferenceDevice()->SetDPIX(nOldDPIX);
+ getReferenceDevice()->SetDPIY(nOldDPIY);
+ double fScaleX = 1.0 / aSize.Width();
+ double fScaleY = 1.0 / aSize.Height();
+
+ // Now have all the info to write the form XObject.
aLine.append(rObject.m_nFormObject);
aLine.append(" 0 obj\n");
aLine.append("<< /Type /XObject");
@@ -11193,13 +11206,28 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
aLine.append(" ");
aLine.append(rObject.m_nObject);
aLine.append(" 0 R>> >>");
- aLine.append(" /BBox [ 0 0 1 1 ]");
+ aLine.append(" /Matrix [ ");
+ appendDouble(fScaleX, aLine);
+ aLine.append(" 0 0 ");
+ appendDouble(fScaleY, aLine);
+ aLine.append(" 0 0 ]");
+ aLine.append(" /BBox [ 0 0 ");
+ aLine.append(aSize.Width());
+ aLine.append(" ");
+ aLine.append(aSize.Height());
+ aLine.append(" ]");
aLine.append(" /Length ");
OStringBuffer aStream;
+ aStream.append("q ");
+ aStream.append(aSize.Width());
+ aStream.append(" 0 0 ");
+ aStream.append(aSize.Height());
+ aStream.append(" 0 0 cm\n");
aStream.append("/Im");
aStream.append(rObject.m_nObject);
- aStream.append(" Do");
+ aStream.append(" Do\n");
+ aStream.append("Q");
aLine.append(aStream.getLength());
aLine.append(">>\nstream\n");
More information about the Libreoffice-commits
mailing list