EMF linear gradient bug fixes and new features
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
Fix Released
|
Wishlist
|
David Mathog |
Bug Description
The attached patch does the following:
1. Fixes two bugs affecting gradients with 3 or more stops when written to an EMF file as a series of colored slices. These
bugs were a general mangling of the gradient and the wrong color being applied to the first slice above a stop.
2. Brings libUEMF files in Inkscape up to the current release level for that library. Also adds EMF+ pieces into src/libuemf
(even though they are not yet used).
3. Fully implements reading and writing of the EMF horizontal and vertical GradientFill records. (After _finally_ figuring out with the help of Microsoft support why the linear form of this record, implemented exactly to their documentation, was toxic to the Windows GDI library.) This output method is enabled if the new EMF output option "Use native rectangular linear gradients" is checked. If the existing "Convert gradients to colored polygon series" is also checked the former takes precedence. The Gradientfill method can only be applied when the gradient is perfectly aligned with one side of the rectangular area - no tilt at all is allowed. That said, the entire rectangle may be rotated, so long as its gradient rotates with it. Multi-stop linear gradients are written out as individual Gradientfill records. When they are read back in they become a series of rectangles with 2 stop gradients abutted to each other. This looks the same.
4. Partial implementation of the EMF triangle GradientFill record. This type of gradient is used in GDI and is comprised of a triangle with a different color at each corner. SVG has no equivalent gradient. On output to EMF Inkscape never produces this type of record since it does not support this type of gradient. On input it draws the appropriate size triangle, but as a solid, using the first vertex's color.
The attached file may be used to test 1 and 3. To see the bugs from (1) on an unpatched Inkscape read it in, then save it to EMF with "Convert gradients to colored polygon series" checked. Read it back in, and the gradients will be mangled. Do the same thing with the patch applied and the gradients should look the same as in the S (except for some moire effects). It the patched Inkscape is used and "Use native rectangular linear gradients" is checked when the EMF is made, then when that EMF is read back in it will have abutted linear gradients emulating the original 4 stop linear gradients for those cases where the gradient was aligned with one side of the rectangle, and will fall back to slices for the one linear case that isn't aligned and the radial gradient. (That is: original SVG file = 1 rectangle with a 4 stop linear gradient, EMF produced by patched inkscape = 3 abutted rectangles with one 2 stop gradient each, EMF produced by unpatched inkscape = hundreds of slices emulating the gradient.)
To see the triangle gradient open test_libuemf_
this in Windows Preview:
http://
The triangle gradients are on the left edge about halfway up.
Now a huge disclaimer. I do not know of any program other than Inkscape that can make full use of the EMF GradientFill record. EMF files with this record will generally display properly in Windows Picture and Fax Viewer, or any other application like PowerPoint that uses the Windows GDI library to display the EMF file. However, none of them seem to be able to convert from that to their native formats. In PowerPoint, for instance, use "Insert picture" with the EMF file produced above and it will look as it should in the slide. Try to ungroup it though, which would covert it to PowerPoint's own object format, and the GradientFill parts will disappear.
Related branches
tags: | added: emf exporting gradient importing |
tags: | added: documentation |
Changed in inkscape: | |
assignee: | nobody → David Mathog (mathog) |
status: | New → In Progress |
Changed in inkscape: | |
status: | Fix Committed → Fix Released |
The patch