[Libreoffice-commits] core.git: vcl/source

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 10 10:15:32 UTC 2021


 vcl/source/filter/png/PngImageReader.cxx |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

New commits:
commit 67411b19665279bacb45cbe50788cac0fa270074
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Mar 5 18:01:11 2021 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Wed Mar 10 11:14:49 2021 +0100

    read png preferred physical size in PngImageReader
    
    Change-Id: Id0ad53a5b279a0d9f83a6ba9646d5fa139b3ac2d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112037
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
    Tested-by: Jenkins

diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx
index 58e67156b029..be94f99b04d2 100644
--- a/vcl/source/filter/png/PngImageReader.cxx
+++ b/vcl/source/filter/png/PngImageReader.cxx
@@ -133,6 +133,18 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32)
         return false;
     }
 
+    Size prefSize;
+    png_uint_32 res_x = 0;
+    png_uint_32 res_y = 0;
+    int unit_type = 0;
+    if (png_get_pHYs(pPng, pInfo, &res_x, &res_y, &unit_type) != 0
+        && unit_type == PNG_RESOLUTION_METER && res_x && res_y)
+    {
+        // convert into MapUnit::Map100thMM
+        prefSize = Size(static_cast<sal_Int32>((100000.0 * width) / res_x),
+                        static_cast<sal_Int32>((100000.0 * height) / res_y));
+    }
+
     {
         if (colorType == PNG_COLOR_TYPE_RGB)
         {
@@ -263,6 +275,12 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32)
 
     png_destroy_read_struct(&pPng, &pInfo, nullptr);
 
+    if (!prefSize.IsEmpty())
+    {
+        rBitmapEx.SetPrefMapMode(MapMode(MapUnit::Map100thMM));
+        rBitmapEx.SetPrefSize(prefSize);
+    }
+
     return true;
 }
 


More information about the Libreoffice-commits mailing list