diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-03-05 18:01:11 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-03-10 11:14:49 +0100 |
commit | 67411b19665279bacb45cbe50788cac0fa270074 (patch) | |
tree | d8a7c23d8b2f8e87079cf9b0dc3cb47e7d775f5a | |
parent | 7abfb02bda53ed71cdca335fa99490992fa7092b (diff) |
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@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | vcl/source/filter/png/PngImageReader.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
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; } |