Description: There are several issues with displaying Gradients in EMF+ format: 1. Missing transparency 2. Gradients are sometimes not displayed Steps to Reproduce: 1. Open attachaed file 2. 3. Actual Results: 1. Missing transparency 2. Not all gradients are displayed 3. The angle of gradient is wrong Expected Results: The image is displayed as with MS Paint (see attachment) Reproducible: Always User Profile Reset: No Additional Info:
Created attachment 150394 [details] EMF+ image with gradients to import
Created attachment 150395 [details] Reference PNG image exported with MS Paint
Dear Bartosz, This bug has been in ASSIGNED status for more than 3 months without any activity. Resetting it to NEW. Please assigned it back to yourself if you're still working on this.
The partial fix was submitted with Commit: https://gerrit.libreoffice.org/plugins/gitiles/core/+/4a215887a845452f984c5453de883b538f660ad4%5E%21 Unfortunately I made mistake with ticket number
Hello @Armin I have a big problem with implementing proper gradient support as it seems that gradients are behave unexpectectly. If I use the SpreadMethod Repeat, the gradient is displayed only at first image and on next is gone: https://gerrit.libreoffice.org/c/core/+/66932/7/drawinglayer/source/tools/emfphelperdata.cxx I saw that you are working on #130478. I suspect that the issue is in Graphic Stack which I'm not experinced. Could you please take a look at this issue?
grepping...
Started to check yesterday, seems as if support for brush->wrapMode in EmfPlusHelperData::EMFPPlusFillPolygon is missing. This is in principle https://apireference.aspose.com/net/imaging/aspose.imaging.fileformats.emf.emfplus.consts/emfpluswrapmode and needs to be mapped to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/spreadMethod since we use SVG gradients in Primitives (the most advanced we have currently, new ones possible anytime). Just mapping is not enough, seems as if modes drawinglayer::primitive2d::SpreadMethod::Repeat drawinglayer::primitive2d::SpreadMethod::Reflect are not well supported in SvgLinearGradientPrimitive2D::create2DDecomposition yet, on it...
Thanks Armin. If you would need some additional/specific EMF+ gradient samples, just let me know. I could produce is.
After supporting these modes had to masively adapt SvgGradientHelper/SvgLinearGradientPrimitive2D/SvgRadialGradientPrimitive2D. These were not able to handle cases where the logical color gradient spread was e.g. completely negative but mode on repeat. Made this now to create the needed sub-runs in a single call. Adapted creation of color runs to do in a single effort. Previous version tried to do this from [0.0 .. 1.0] and to re-use transformed versions in the caller if SpreadMethod was on some repeat mode, but had problems when e.g. like in the bugdoc from the task a negative-only fStart/fEnd run was requested in which case it did nothing. Even when reusing the spread might not have been a full one from [0.0 .. 1.0]. This gets complicated due to mirrored runs, but also for gradient definitions with missing entries for 0.0 and 1.0 in which case these have to be guessed to be there with same parametrisation as their nearest existing entries. These *could* have been added at checkPreconditions() but would then create unnecessary spreads on zone overlaps.
Added https://gerrit.libreoffice.org/c/core/+/90329 a 1st version to gerrit. This already does something better, but is not yet correct. There might still be errors in setting up the gradients in drawinglayer\source\tools\emfphelperdata.cxx More important: We need to check if the deep changes keep the SVG import stuff unchanged - it should, but you never know. The gradient spread is just done different (and better, more reliable), but doing this deep change as own commit will allow to better detect problems, including bisecting. @Bartosz: You may check this early 1st step locally if you have the possibility to do so. It is necessary to also create some radial gradients in EMF if possible. It would also be good to some SVG tests with linear and radial gradients - I'll also do some more...
Armin Le Grand committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/c3f0c527b31f5c88263ea63d3d0e332c4783917c tdf#124424 Enhanced SvgGradientHelper for EMF+ It will be available in 7.0.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.
Created attachment 158627 [details] EMF+ test image with linear and path gradient. It could be used for testing
Created attachment 158628 [details] EMF+ test image with linear and path gradient exported to PNG
Created attachment 158630 [details] EMF+ simple linear gradient
Created attachment 158631 [details] EMF+ simple linear gradient exported to PNG
Created attachment 158632 [details] EMF+ Path gradient
Created attachment 158633 [details] EMF+ Path gradient exported to PNG
Have detected some smaller glitches using SVG simple examples. Correcting these...
Corrections done inhttps://gerrit.libreoffice.org/c/core/+/90382. @Bartosz: Thanks for the examples. Could you add/create some for radiant gradients? You are aware that we do not really support PathGradients - that's a missing feature and hard to do correctly. We do currently not have the correct tools for that, like we have for linear and radial by re-using the SvgGradientHelper-based primitives that I did once for SVG. Thus I would say we/you can continue to fix/enhance the linear/radial ones in drawinglayer\source\tools\emfphelperdata.cxx at EmfPlusHelperData::EMFPPlusFillPolygon, but I see no simple way to support BrushTypePathGradient proper anytime soon.
Armin Le Grand committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/c20e70d28df21429bba92b6d8a7d7061c2aa5d8b tdf#124424 Corrections at SvgGradientHelper for EMF+ It will be available in 7.0.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.
I cannot find out why the rotation(s) of the gradients is wrong, I am checking LinearGradientSimple.emf. Left to right the 1st two have a TextureTransformation with 45deg resp. -90deg rotation, the 3rd has no TextureTransformation. When looking at https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.lineargradientbrush?view=netframework-4.8 it is clear that without TextureTransformation all are diagonal. The left obj shall be diagonal, but with the TextureTransformation of 45deg it gets horizontal. The mid shall be horizontal, but starting from diagonal (default, see url above) and a rot of -90deg in the transformation I see no way to get there...? The right shall be vertical, but has no TextureTransformation at all, so has to stay on default (diagonal). I checked now https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-emfplus/fa7c00e7-ef14-4070-b12a-cb047d964ebe and corresp. pages deeply, but see no hint yet - in the other doc al least a 'RelativeTransform' and 'Transform' is mentioned, but I see only one transform in Brush. I have no clue... Bartosz..?
@Bartosz: Please take over again. I have enhanced the linear/radial gradients to do all you will need (hopefully). Have checked if I could identify errors in orienation (comment 21), but seems to require more knowledge on EMF+ do do so. Please also see comment 19 regarding BrushTypePathGradient.
Created attachment 158679 [details] EMF+ Path gradient with two ellipses. All path gradients is imported into LibreOffice as Ellipse gradients Hello Armin. In EMF+ format there is no radiant gradients. Everything other than Linear Gradients is handled by Path Gradients. As a workaround while Path Gradients is needed during EMF+ import, we are using Radial gradients.
Created attachment 158680 [details] EMF+ Path gradient with two ellipses exported to PNG
Bartosz Kosiorek committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/490804ade1103c3fd7569ea093d8d90beab445a3 tdf#124424 Fix orientation of the LinearGradient It will be available in 7.0.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.
Created attachment 158696 [details] EMF+ different linear gradients
Created attachment 158697 [details] EMF+ different linear gradients exported to PNG
Thanks Armin for your patches . I have attached next EMF+ image where I found following issues: 1. The image is not imported with full size. Bottom and right part of EMF+ image is not displayed 2. Some of the linear gradients are not displayed correclty 3. There are overlap lines between the gradients images.
Bartosz Kosiorek committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/87c2d3a3d9d91c18ff8c32760a3c34a99c629c1a tdf#124424 Fix WrapModeTileFlipY option for LinearGradient It will be available in 7.0.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.
Created attachment 158699 [details] Looks better @Bartosz: wow- looks much better now. Also SVG, adding some test files
Created attachment 158700 [details] HAS to work
Created attachment 158701 [details] HAS to work
Bartosz Kosiorek committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/1f540cc7613cdbc0048f4013efe43886d256f86b tdf#124424 EMF+ Add tests for LinearGradient It will be available in 7.0.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.
Bartosz Kosiorek committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/e11796866f94d2f51023e6bc2b23a39af10a7d96 tdf#124424 EMF+ Extend test options of SvgLinearGradientPrimitive2D It will be available in 7.0.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.
Created attachment 158819 [details] The metafile, extracted from ssaved ODG
Comment on attachment 158819 [details] The metafile, extracted from ssaved ODG OOps - sorry, wrong task. Can I ssomehow remove this again..?
Hello Armin, Could you please take a look at attachment 158697 [details] from comment 26, and check how displaying of gradients could be fixed? As I noticed, the wrongly displayed gradients have negative values. It will be great to fix this issue as it impacts many EMF+ images with Linear Gradients. Thanks
Bartosz Kosiorek committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/ad4ee3bb3bf99c3b02ddca2318d39a1c0f2469a0 EMF+ tdf#124424 Add support for transparency to LinearGradient and blend points It will be available in 7.0.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.
Almost all issues with gradients were resolved. The remaining quirks will be resolved in separate bug reports.