Bug 234708 - [ImageSupport] Embedded images are displayed clipped by 1 pixel
Summary: [ImageSupport] Embedded images are displayed clipped by 1 pixel
Status: RESOLVED FIXED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 normal
Target Milestone: 2.2.1   Edit
Assignee: Alex Boyko CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-29 15:27 EDT by Alex Boyko CLA
Modified: 2010-07-19 12:25 EDT (History)
1 user (show)

See Also:


Attachments
fix patch for future reference (22.21 KB, patch)
2008-05-29 15:27 EDT, Alex Boyko CLA
no flags Details | Diff
proposed patch (46.84 KB, patch)
2009-07-08 15:58 EDT, Alex Boyko CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Boyko CLA 2008-05-29 15:27:45 EDT
Created attachment 102717 [details]
fix patch for future reference

There is a high chance that the embedded image on the diagram is clipped by 1 pixel on the top and/or on the left.
It is easy to spot the issue with a circular shape SVG image.

RenderHelper does the scaling of the image to render an embedded image such that the quality of image doesn't suffer the scaling, this is done for SVG images. When render helper performs the scaling it doesn't take into account the fractionalX and fractionalY defined on scaled graphics and hence the clipping rectangle and the actual area where the image is drawn can be different and, therefore, 1 pixel of the image might be clipped.

I'm attaching the patch that fixes the issue. However, it may break GMF clients, which use ScaledGraphics wrapped around MapModeGraphics or any other GMF graphics implementing DrawableRenderedImage interface.
The best way to fix would probably be making the interface public as well as having GMF ScaledGraphics implementing this interface.
Comment 1 Alex Boyko CLA 2009-07-08 15:58:12 EDT
Created attachment 141130 [details]
proposed patch

A possible patch that fixes the issue.

Changed RenderedMapModeGraphics and RenderedScaledGraphics such that the target rectangle is scaled with fractional parts included.
RenderHelper only works correctly for RenderedXXXGraphics, hence swept the runtime code and replaced ScaledGraphics with RenderedScaledGraphics and MapModeGraphics with RenderedMapModeGraphics where appropriate.
The call to listener.paintFigureWhileRendering never has the right graphics object (most of the time it's SWTGraphics) and hence the red rectangle with cross is either never visible (clipped) or just to big. Therefore, it is better that we don't paint at all or just paint something at the RenderHelper level. For now nothing is painted what not rendered yet image.

I'd like to raise a bug for 2.3 to get rid of RenderedXXXGraphics and merge them with ScaledGraphics and MapModeGraphics. Move most of classes from draw2d.ui.render to draw2d.ui plugin.

Anthony, can you please review this patch and let me know what you think?
Thanks!
Comment 2 Anthony Hunter CLA 2009-07-08 17:56:44 EDT
I cannot see anything wrong with the patch.

Only two administrative comments:

I do not get why we added +@SuppressWarnings("restriction")
to SWTDiagramPrinter.
If it is to get rid of the two warnings that were already there for gc.setXORMode, I would not add these @SuppressWarnings, we need to know we are using deprecated methods.

You will need to add @since 1.2 to 
DiagramScalableFreeformLayeredPane.createMapModeGraphics
DiagramScalableFreeformLayeredPane.createScaledGraphics
Comment 3 Alex Boyko CLA 2009-07-08 18:31:18 EDT
Thanks!
Added @since 1.2 blocks
The restriction was just a left over. The package hosting the RenderedXXXGraphics was made visible to printing plugin, so I just forgot to remove the suppress restriction i put there previously.

Committed to HEAD and maintenance.
Comment 4 Eclipse Webmaster CLA 2010-07-19 12:25:53 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime Diagram was the original product and component for this bug