Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 517407

Summary: Export wide Diagram in image using png format produced truncated diagram.
Product: [Modeling] Sirius Reporter: Jessy Mallet <jessy.mallet>
Component: DiagramAssignee: Pierre-Charles David <pierre-charles.david>
Status: CLOSED FIXED QA Contact: Julien Dupont <julien.dupont>
Severity: major    
Priority: P3 CC: cedric.brun, julien.dupont, pierre-charles.david
Version: unspecifiedKeywords: triaged
Target Milestone: 5.0.0   
Hardware: PC   
OS: Windows NT   
See Also: https://git.eclipse.org/r/98540
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=9261d08efd5a8090ad7f6959fb5b90d3c21c7cc1
Whiteboard:
Attachments:
Description Flags
Test case to reproduce bug.
none
Export diagram KO
none
Export diagram OK
none
Exported diagrams on master (with the bug) vs with the patch none

Description Jessy Mallet CLA 2017-05-30 03:17:13 EDT
Created attachment 268620 [details]
Test case to reproduce bug.

When user export diagram as image with png format, the diagram exported is truncated (see diag-5815-5575.png).
With other format (jpg/gif/bmp/svg), the diagram is well exported without problem (see diag-5815-5575.jpg).

Steps to reproduce :
* Import project Compartiments (from exportDiagramCut.zip)
* Open diagram "diag-5815-5575" 
* export this diagram as image with jpg format : the diagram is fully exported -> OK
* export this diagram as image with png format : the diagram is truncated -> KO
Comment 1 Jessy Mallet CLA 2017-05-30 03:17:45 EDT
Created attachment 268621 [details]
Export diagram KO
Comment 2 Jessy Mallet CLA 2017-05-30 03:18:19 EDT
Created attachment 268622 [details]
Export diagram OK
Comment 3 Pierre-Charles David CLA 2017-06-01 04:12:28 EDT
This seems caused by the changes made for https://bugs.eclipse.org/bugs/show_bug.cgi?id=507056:
* on current master (Sirius 5.0.0rc2), I reproduce the issue (under Linux).
* with the patches made for #507056 reverted, the bug is no longer there.

I'll look into it. @cedric I'm adding you in CC in case I have specific questions about your code.
Comment 4 Pierre-Charles David CLA 2017-06-01 08:52:36 EDT
Bug #507056 had 3 commits. After reverting the whole set (back to a working state), and re-applying them one by one:
* 71b84800013644898560aa649ccd8e0d55afd86c: introduces the regression.
  * A small diagram is exported (in PNG only) with quite a lot of unneeded whitespace to the right and bottom: a 12156×4106 pixels PNG, where only the top-left ~1200×400 are used for the diagram. 
  * A large diagram gets exported (in PNG) with all the parts visible, and a little bit of unneeded whitespace. 7409×6626 pixels, where "only" ~6900×5250 are occupied. At least in this state the whole diagram is visible.
* 069b6e20e89226709b111fbda0046f07dfc1ceca: does not change anything
* fd45868c116805919c041bdc2e099cdc9b3fde35:
  * The small diagram is exported to a smaller PNG (3483×1176), but sill exhibits the unneeded whitespace issue: only ~1200×400 are occupied.
  * The large diagram is exported to a 2166×1902 PNG, but this time the bottom-right part of the diagram is lost.

From this data (at least in the case of the small diagram), it seems the scaling factor used to determine the physical size of the PNG canvas is not passed to the underlying rendering code, which renders it at the "native" scaling factor.
Comment 5 Pierre-Charles David CLA 2017-06-01 09:47:48 EDT
I have a simple fix for the first issue visible on small diagrams, which is actually different from the one reported. No luck yet on the second one.
Comment 6 Eclipse Genie CLA 2017-06-02 09:52:15 EDT
New Gerrit change created: https://git.eclipse.org/r/98540
Comment 7 Pierre-Charles David CLA 2017-06-06 08:06:54 EDT
Created attachment 268768 [details]
Exported diagrams on master (with the bug) vs with the patch

It looks like the patch at https://git.eclipse.org/r/#/c/98540/1 fixes all the issues. Attached is a comparison of 2 exported diagrams (one small, one large) with all supported images formats, on master (5324a88e840fc4fb548b076f89a61a331b7e4141) and with the patch.
Comment 9 Pierre-Charles David CLA 2017-06-06 08:11:26 EDT
Fixed by 9261d08efd5a8090ad7f6959fb5b90d3c21c7cc1..
Comment 10 Pierre-Charles David CLA 2017-06-29 03:31:40 EDT
Available in Sirius 5.0.0, see https://wiki.eclipse.org/Sirius/5.0.0 for details.