Issue 121267 - Not all exporters support ClipRegions in Metafiles
Not all exporters support ClipRegions in Metafiles
Status: VERIFIED FIXED
Product: Draw
Classification: Application
Component: save-export
4.0.0-dev
All All
: P3 normal (vote)
: 4.0.0
Assigned To: Armin Le Grand
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-24 12:01 UTC by Armin Le Grand
Modified: 2013-07-12 16:28 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation on: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Armin Le Grand 2012-10-24 12:01:58 UTC
ALG: This is a follow-up to #121185#. The problem is that most exports are still based on getting the Metafile of the content as base for export to vector formats, but do not  support clip actions (e.g. META_CLIPREGION_ACTION). This is true for the following formats: emf, wmf, swf, met.
This is a gereral error, but can be seen more often now after #121185#. To reproduce:
- New Draw/Imperss
- Create rectangle, fill with gradient which obviosuly potentially has graphics outside the object bounds (e.g. elliptical)
- Convert to metafile (GraphicObject containing metafile)
- Export to one of the formats
-> The gradient parts sticking out of the object will not be clipped
Comment 1 Armin Le Grand 2012-10-24 12:02:11 UTC
ALG: Taking over
Comment 2 Armin Le Grand 2012-10-24 12:07:19 UTC
ALG: Thought abou this. There are generally three solutions:

(a) Change the exports to be based on primitives (rewrite)
(b) Extend old exports to take clip region actions int account
(c) Clip metafile independent of export as export preparation

Possibility (a) will take too long and will be the long-term solution. Possibility (b) is poyyible, but hard to do in old code, also unclear how far e.g. WMF supports ClipRegions based on polygons, will be more like RegionBands.

Decided to do (c) and add a tooling method for clipping the content of a metafile against it's contained clip regions. This can then be used to prepare the metafile for these old exporters.
Comment 3 Armin Le Grand 2012-10-24 14:08:48 UTC
ALG: Progressing with (c), adapted to wmf and emf to check, works as expected. Extending implementation...
Comment 4 Armin Le Grand 2012-10-24 17:27:10 UTC
ALG: Added all kinds of geometry primitives, works well. Checked the bug with the same method as in comment1, but with hatch fill. Bad news: Same problem here. Good news: Can be also solved with my new method.
Also checked with bitmap fill, same problem arises. This is more complicated to solve (and thus bad news); it also shows that metafile formats are really aged.

I'm thinking again about a evtl. even more general solution for metafile-based exports...
Comment 5 Armin Le Grand 2012-10-25 16:28:52 UTC
ALG: Implemented clipping for the bitmap-based actions, works well. Chekcing further usages (swf).

Note: In swf, gradient gets 'grepped' from META_GRADIENTEX_ACTION using XGRAD_SEQ_BEGIN/XGRAD_SEQ_END.
Note: Rotated GraphicObjects with bitmaps in metafiles work, non-rotated still painting over, check Metafile creation.
Comment 6 Armin Le Grand 2012-10-26 10:22:45 UTC
ALG: Adapted for swf, added gradient actions to have unroated stuff correct. Both notes are done, all comment actions are handled now. looking for met (not very urgent, but nice to have)...
Comment 7 Armin Le Grand 2012-10-26 11:14:10 UTC
ALG: Added preprocessing to met, done more checks.
Found an error in VclMetafileProcessor2D (converter from primitives to metafile) in the MaskPrimitive2D handling; when resulting clip region is empty, do *mot* process sub-content, there can be no content. This may have lead to geometry in the metafile outside the clip regions. Testing...
Comment 8 Armin Le Grand 2012-10-26 11:49:41 UTC
ALG: Okay, works. Also limited bitmap prescaling when directly handling FillGraphicPrimitive2D in VclProcessor2D to avoid performance problems. Pretty much done, doing some more tests...
Comment 9 SVN Robot 2012-10-26 12:01:13 UTC
"alg" committed SVN revision 1402475 into trunk:
#121267# added support for taking clipping into account for metafile-based ex...
Comment 10 Armin Le Grand 2012-10-26 12:04:19 UTC
ALG: Okay, done. Hatch, bitmap and gradient fills in metafiles (roated or not) will now be clipped and exported in emf, wmf, swf and met file formats. Also done some speedups and fixes which came up during investigation.
This needs thorough testing (all kinds of metafile graphics to mentioned export formats). It started as a temporary workaround for old filters based on metafiles as data transport format, but when you think about it noone will ever update emf/wmf exporters to primitives (maybe importers, though), so it is not only a short-term solution.
Comment 11 Li Feng Wang 2012-11-08 08:46:09 UTC
Verified pass with trunk r1404513