Bug 152061 - FILEOPEN: DOCX Bitmap image scale is calculated incorrectly
Summary: FILEOPEN: DOCX Bitmap image scale is calculated incorrectly
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.5.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Hossein
URL:
Whiteboard: target:7.5.0 target:7.4.4
Keywords: bisected, regression
Depends on:
Blocks:
 
Reported: 2022-11-15 23:43 UTC by Hossein
Modified: 2022-11-16 12:18 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
DOCX file with a single image inside (48.91 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2022-11-15 23:43 UTC, Hossein
Details
PDF output of the above DOCX file with LO dev 7.5 (2.33 KB, application/pdf)
2022-11-15 23:47 UTC, Hossein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hossein 2022-11-15 23:43:49 UTC
Created attachment 183618 [details]
DOCX file with a single image inside

Description:
While opening a file containing an image, its size is calculated incorrectly, and thus only portion of it is visible. This is a regression because it is OK in 7.4, but not OK in the latest 7.5 dev master.

Steps to Reproduce:
1. Open the attachment

Actual Results:
The image (which is a logo, and 2 lines of text below it) is displayed partially. The problem is display-only, because the PDF output seems to be OK.

Expected Results:
The image should be displayed completely. The attachment is a JPEG file, with the size of 219 × 303 pixels.

Reproducible: Always


User Profile Reset: No


Additional Info:

Reproducible with the latest LO 7.5 dev master:
Version: 7.5.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 16433bb162e060256f3ac47dd09630590f9e4ce0
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Not reproducible with 7.4:
Version: 7.4.0.3 / LibreOffice Community
Build ID: f85e47c08ddd19c015c0114a68350214f7066f5a
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 1 Hossein 2022-11-15 23:47:34 UTC
Created attachment 183619 [details]
PDF output of the above DOCX file with LO dev 7.5

This is the PDF output created from the above DOCX example using the latest LO 7.5 dev master. The PDF output is OK. The display of the image in LO is not OK.
Comment 2 Hossein 2022-11-16 03:28:46 UTC
As the commit is relatively new, I had to do a bisect:

Bisected to:
 c2c37eadf32c80bcd8f168b9fc67f32002b3cb07 is the first bad commit
commit c2c37eadf32c80bcd8f168b9fc67f32002b3cb07
Author: Caolán McNamara <caolanm@redhat.com>
Date:   Fri Nov 11 15:12:30 2022 +0000

    Related: tdf#151898 consider surface scaling if prescale with Bitmap::Scale
    
    whose introduction dates back to:
    
    commit c0ce7ca4884f7f6d1016bd1dbcc22066cb4a7797
    Date:   Sat Jul 7 13:07:03 2012 +0200
    
        Prescale image with Bitmap::Scale to improve quality.
    
    don't prescale past the level of detail that the surface could retain
    
    Change-Id: I1022688d45d2bb7b692f4ba619198fccea8eab36
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142591
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm@redhat.com>

$ git bisect log
git bisect start
# good: [cfc8a8f5d841b3f84d207196153be67da7f60652] CppunitTest_svx_core: inherit from UnoApiTest
git bisect good cfc8a8f5d841b3f84d207196153be67da7f60652
# bad: [16433bb162e060256f3ac47dd09630590f9e4ce0] CppunitTest_sc_subsequent_filters_test: inherit from UnoApiXmlTest
git bisect bad 16433bb162e060256f3ac47dd09630590f9e4ce0
# good: [c8eaebecd3af29c031c26142c9d3f7d7abf75b0d] Avoid an explicit static_cast
git bisect good c8eaebecd3af29c031c26142c9d3f7d7abf75b0d
# good: [ecb6ba6fb677a711afd515139cc7cf9cce771003] Drop useless std::move of const object
git bisect good ecb6ba6fb677a711afd515139cc7cf9cce771003
# bad: [b257b4f247bc2a1fa4d469ec82e37bdbb268951b] svx: On table style removal, revert to the default style
git bisect bad b257b4f247bc2a1fa4d469ec82e37bdbb268951b
# bad: [bd7f1270cf58eba7600d1b4c6c8ca9a901a04f66] tdf#125085 PPTX WordArt import: get shape font from run
git bisect bad bd7f1270cf58eba7600d1b4c6c8ca9a901a04f66
# good: [c725028f15c36fc626d9ad8cdc288eb73c3e2643] SVG export: fix handling of semi-transparent, multi-para shape text
git bisect good c725028f15c36fc626d9ad8cdc288eb73c3e2643
# bad: [1bfb323801b9c88879b5948b16d47cdbbee87ab9] tdf#151988: Enable "Characters per line" and "Character width" when switch...
git bisect bad 1bfb323801b9c88879b5948b16d47cdbbee87ab9
# bad: [c2c37eadf32c80bcd8f168b9fc67f32002b3cb07] Related: tdf#151898 consider surface scaling if prescale with Bitmap::Scale
git bisect bad c2c37eadf32c80bcd8f168b9fc67f32002b3cb07
# good: [7986d35eee84fdf391c563602fb348758e1cd254] move password handling from SwModelTestBase to UnoApiTest
git bisect good 7986d35eee84fdf391c563602fb348758e1cd254
# first bad commit: [c2c37eadf32c80bcd8f168b9fc67f32002b3cb07] Related: tdf#151898 consider surface scaling if prescale with Bitmap::Scale
Comment 3 Commit Notification 2022-11-16 10:18:44 UTC
Hossein committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/31d510389928c8f8a495a85cdab4c12d1bbbd3ce

tdf#152061 Fix bitmap image scaling

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Commit Notification 2022-11-16 12:18:05 UTC
Hossein committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/19174e373aa6cb5db6975f925a8a1211f219301b

tdf#152061 Fix bitmap image scaling

It will be available in 7.4.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.