Bug 55058 - List of EMF import bugs with examples
Summary: List of EMF import bugs with examples
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
3.6.1.2 release
Hardware: x86 (IA32) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: EMF-WMF
  Show dependency treegraph
 
Reported: 2012-09-18 16:46 UTC by mathog
Modified: 2017-08-25 17:03 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments
Test EMF file (49.59 KB, image/x-emf)
2012-09-18 16:46 UTC, mathog
Details
Test file as seen in Windows Preview (517.55 KB, image/png)
2012-09-18 16:46 UTC, mathog
Details
Test file in LODraw, low magnification (423.36 KB, image/png)
2012-09-18 16:47 UTC, mathog
Details
Test file in LODraw, high magnification of one problem area (151.46 KB, image/png)
2012-09-18 16:48 UTC, mathog
Details
Test file in LOdraw, high magnification of one problem area (109.00 KB, image/png)
2012-09-18 16:48 UTC, mathog
Details
Test file in LODraw, high magnification of one problem area (102.07 KB, image/png)
2012-09-18 16:49 UTC, mathog
Details
Test file in Inkscape, low magnification, for comparison (207.26 KB, image/png)
2012-09-18 16:49 UTC, mathog
Details
EMF file with a nonIdentity rotation matrix in the WORLDTRANSFORM record (81.93 KB, image/x-emf)
2013-01-29 18:24 UTC, mathog
Details
Well-known Cisco's "router" icon in EMF format. (11.25 KB, image/x-emf)
2013-02-18 16:41 UTC, Valek Filippov
Details
More recent, more complete EMF test file (152.39 KB, image/x-emf)
2015-06-16 16:12 UTC, mathog
Details
EMF test file, version 0.2.2 (162.20 KB, video/unknown)
2017-08-25 16:43 UTC, mathog
Details
EMF test file, version 0.2.2 in Windows Preview (221.50 KB, image/png)
2017-08-25 16:44 UTC, mathog
Details
EMF+ test file, version 0.2.1 (196.89 KB, video/unknown)
2017-08-25 16:45 UTC, mathog
Details
EMF+ test file, version 0.2.1, in Windows Preview (231.14 KB, image/png)
2017-08-25 16:47 UTC, mathog
Details
WMF test file, version 0.2.2 (38.53 KB, image/x-wmf)
2017-08-25 16:49 UTC, mathog
Details
WMF test file, version 0.2.2, in Windows Preview (150.80 KB, image/png)
2017-08-25 16:50 UTC, mathog
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mathog 2012-09-18 16:46:02 UTC
Created attachment 67335 [details]
Test EMF file

I have recently been doing working on the EMF import/export capabilities of Inkscape (https://bugs.launchpad.net/inkscape/+bug/988601) and today I got around
to trying one of the test files on LODraw 3.6.1.2.  There were a few issues found.

1.  EMR_SMALLTEXTOUT - not supported
2.  Pattern fill (all modes) - not supported
3.  Pattern stroke (all modes) - not supported
4.  Some discrepancies in textalignment modes (using Windows Preview as the gold
standard).
5.  After import into LODraw and then "break" dash patterns on lines are lost.
6.  Fill winding attribute is broken (see the two 5 pointed filled stars)
7.  Font sizes vary on rotated text (see the three roundish clusters of 
    text at the top edge of the diagram.)
8.  EMR_GRADIENTFILL - not supported.  (Note, this is not supported in Inkscape
either, and I have never been able to get the rectangular gradient records to work - all attempts resulted in EMF files which were toxic to Windows Preview.)
9.  Graphics errors: line with the purple filled, turquoise lined figures.  LODraw does the 5th and 7th figures incorrectly.
10. Graphics errors:  the two lines with the same shapes, which are regular and 16bit versions of various records.  The first item in the 2nd and 3rd groups is filled by LODraw, but it should not be.

The test EMF file was produced by libUEMF 0.8, which is not released yet but will be later today.
Comment 1 mathog 2012-09-18 16:46:47 UTC
Created attachment 67336 [details]
Test file as seen in Windows Preview
Comment 2 mathog 2012-09-18 16:47:33 UTC
Created attachment 67337 [details]
Test file in LODraw, low magnification
Comment 3 mathog 2012-09-18 16:48:02 UTC
Created attachment 67338 [details]
Test file in LODraw, high magnification of one problem area
Comment 4 mathog 2012-09-18 16:48:31 UTC
Created attachment 67339 [details]
Test file in LOdraw, high magnification of one problem area
Comment 5 mathog 2012-09-18 16:49:01 UTC
Created attachment 67340 [details]
Test file in LODraw, high magnification of one problem area
Comment 6 mathog 2012-09-18 16:49:51 UTC
Created attachment 67341 [details]
Test file in Inkscape, low magnification, for comparison
Comment 7 mathog 2012-09-18 17:00:03 UTC
The attachment lodraw_himag3.png was made after "break" - it shows the loss of the dot/dash pattern on the lines.

The relevant pieces of code in Inkscape are in the src/extensions/internal directory of that distribution, in the files:

emf-inout.cpp
emf-inout.h
emf-print.cpp
emf-print.h
uemf.c
uemf.h

I suspect that items 9 and 10 are due to logic errors in the LODraw equivalent of the code at the top of the main read loop in emf-inout.cpp starting around line 1408.  This is the code which determines at what point, during the processing of the EMF file, to stroke/fill each internal object, which turned out to be quite complex.

There are also some differences in the handling of EMR_BITBLT between Inkscape and LODraw, but since those operations are very hard to translate to internal objects, I would be hard pressed to say which, if either, is doing it "right".
Comment 8 mathog 2012-09-18 17:02:01 UTC
Sorry, forgot the link to libUEMF:

http://libuemf.sourceforge.net/
Comment 9 mathog 2013-01-29 18:24:35 UTC
Created attachment 73863 [details]
EMF file with a nonIdentity rotation matrix in the WORLDTRANSFORM record

An email exchange with Valek Filippov has turned up an ancient bug in the EMF input implementation in inkscape - EMF WORLDTRANSFORM records with nonidentity rotation matrices result in a mangled drawing.  Unfortunately LibreOffice 3.6 (on Windows XP, 32 bit) has much the same issue.  The attached file is thoroughly mangled when imported into LODraw.
Comment 10 Valek Filippov 2013-02-18 16:41:51 UTC
Created attachment 75058 [details]
Well-known Cisco's "router" icon in EMF format.

Problem with Polybezier16?
Comment 11 Valek Filippov 2013-02-18 16:53:25 UTC
EMF attachment 75058 [details] includes "nested" EMF+(EMF(EMF+)).
Drawing outer EMF gives standard router icon with known "1 pxl off IntersectClipRect" problem.
Most inner EMF+ has DrawPath/DrawEllipse and FillPath/FillEllipse commands.
Comment 12 QA Administrators 2015-04-19 03:21:32 UTC Comment hidden (obsolete)
Comment 13 Buovjaga 2015-06-16 10:39:33 UTC
Opened attachment 67335 [details], not much seems to have changed. The "Degrees" stars don't have bold text anymore.

Win 7 Pro 64-bit Version: 5.1.0.0.alpha1+
Build ID: 80ec99db4325a439a8a3f1d420d0a80f8bf9c439
TinderBox: Win-x86@62-merge-TDF, Branch:MASTER, Time: 2015-06-16_00:00:20
Locale: fi-FI (fi_FI)
Comment 14 mathog 2015-06-16 16:12:23 UTC
Created attachment 116589 [details]
More recent, more complete EMF test file

I'm uploading a more recent and complete EMF test file.  Among other things, it has a full set of clipping tests and some gradient record tests (real gradients, not the fake ones made up hundreds of colored rectangular slices).
Comment 15 QA Administrators 2016-11-08 10:39:07 UTC Comment hidden (obsolete)
Comment 16 Buovjaga 2017-08-25 14:14:15 UTC
Patrick: I thought this might interest you.
attachment 67336 [details] is the desired rendering of attachment 67335 [details]
It exposes several issues, most are old. A regression against the new renderer is the gradients turning blocky (hard edges).

Also note attachment 116589 [details] which is a more recent and more complete test file.
Comment 17 Armin Le Grand (CIB) 2017-08-25 14:16:22 UTC
Checked with file from comment 14, looks not too bad with new EMF+ mechanisms, but there are some parts which may be improved. Thanks for the testfile! I will add the people in CC that are on it.
BTW: Repaint with new mechanism and primitives is now *way faster* even than MS's Paint app, jay ;-)
Comment 18 Patrick Jaap 2017-08-25 15:33:19 UTC
Hi, attachment 67335 [details] does not contain any EMF+ records, it is just pure EMF. But I can take a look into the EMF parsing, there seems to be something wrong with the color choice.
Comment 19 Buovjaga 2017-08-25 15:44:56 UTC
(In reply to Patrick Jaap from comment #18)
> Hi, attachment 67335 [details] does not contain any EMF+ records, it is just
> pure EMF. But I can take a look into the EMF parsing, there seems to be
> something wrong with the color choice.

It is weird.. I am seeing the blockiness on Linux but not on Windows (build from 24th).
Comment 20 Patrick Jaap 2017-08-25 16:10:44 UTC
The broken gradients of attachment 67335 [details] are produced by a MetaActionType::BMPSCALE which is really strange. Either the MetaAction contains a broken Bitmap or the subsequent BitmapPrimitive2D does something wrong. It has definitely nothing to do with EMF+ gradients.
Comment 21 Armin Le Grand (CIB) 2017-08-25 16:17:04 UTC
Short check with the Metafile-to-Primitive converter: The file from comment 14 indeed is a pure emf file, containing no EMF+ parts at all. Thus it should look identical in older versions, checking...
Comment 22 Armin Le Grand (CIB) 2017-08-25 16:18:10 UTC
Looks pretty much the same on 5.2 and current, indeed has nothing to do with EMF+ stuff, but is an older error in EMF import - which itself was never complete or error-free.
Comment 23 Buovjaga 2017-08-25 16:42:40 UTC
(In reply to Armin Le Grand (CIB) from comment #22)
> Looks pretty much the same on 5.2 and current, indeed has nothing to do with
> EMF+ stuff, but is an older error in EMF import - which itself was never
> complete or error-free.

Aargh, you are right: I see the problem with 5.4 on Linux (but not on 3.6). I should open a new report for the regression.
Comment 24 mathog 2017-08-25 16:43:32 UTC
Created attachment 135791 [details]
EMF test file, version 0.2.2

Most recent EMF test file.  Pure EMF, no EMF+.
Comment 25 mathog 2017-08-25 16:44:40 UTC
Created attachment 135792 [details]
EMF test file, version 0.2.2 in Windows Preview

Windows XP Preview of 0.2.2 EMF test file.
Comment 26 mathog 2017-08-25 16:45:44 UTC
Created attachment 135793 [details]
EMF+ test file, version 0.2.1

EMF+ test file, version 0.2.1
Comment 27 mathog 2017-08-25 16:47:02 UTC
Created attachment 135794 [details]
EMF+ test file, version 0.2.1, in Windows Preview

EMF+ test file, version 0.2.1, as seen in Windows XP Preview
Comment 28 mathog 2017-08-25 16:49:35 UTC
Created attachment 135795 [details]
WMF test file, version 0.2.2

WMF test file, version 0.2.2
Comment 29 mathog 2017-08-25 16:50:36 UTC
Created attachment 135796 [details]
WMF test file, version 0.2.2, in Windows Preview

WMF test file, version 0.2.2, as seen in Windows XP Preview
Comment 30 mathog 2017-08-25 17:03:05 UTC
My most recent EMF, EMF+, and WMF test files have been uploaded, along with images of each made on Windows XP using "Windows Preview".  In many instances to see what is actually going on, for instance line end treatments, it is necessary to zoom in with the actual viewer.  Current versions of Inkscape can also be used to view the EMF and WMF files and it is, to the best of my ability, 1:1 with the Windows XP Preview image.  Inkscape does not yet have EMF+ display.  The code to generate these test files and other related EMF, EMF+, WMF code is at:

  https://sourceforge.net/projects/libuemf/

If anybody reading this knows how to properly handle files containing mixtures of EMF and EMF+ records please contact me or post a link to the section of the relevant Microsoft documentation.  An EMF document may contain an object described in both EMF and EMF+ records and there is no obvious way to determine which EMF object description corresponds to which EMF+ object description.  So as far as I can tell it seems the only safe thing to do is to either render just the EMF records or just the EMF+ records.  However, some applications (like some versions of PowerPoint) will render everything in a diagram to an EMF file as both EMF and EMF+ records except the text, which is EMF only.  So that the EMF+ description in the EMF file is always incomplete.