EMF Import: Line Graph gets wrong colors.

Bug #1221907 reported by Alvin Penner
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
Medium
Unassigned

Bug Description

this is a re-issue of Bug 382420, which has been marked Fix Released. The original report was : "When importing this EMF file the preview has the correct colors, but once imported the colors have been swapped so that some lines are the wrong color."

attached is the file

Tags: emf importing
Revision history for this message
Alvin Penner (apenner) wrote :
Revision history for this message
Alvin Penner (apenner) wrote :

- attached is the file Line Graph_12472.svg, obtained by importing the file Line Graph.emf into Windows XP, Inkscape rev 12472
   - it appears to show the colors correctly

Revision history for this message
Alvin Penner (apenner) wrote :

- attached is the file Line Graph_12496.svg, obtained by importing the file Line Graph.emf into Windows XP, Inkscape rev 12496
- it has two separate problems. first the image is blank due to a white rectangle.
- after removing the white rectangle there are a number of black rectangles under it which are hiding the line graph.
- it is likely that there is a line graph in this image, but I was not able to find it due to the number of black rectangles. I could not determine the colors of the line graph.

Revision history for this message
su_v (suv-lp) wrote :

Reproduced with r12504 on OS X 10.7.5:

The lines of the graph are present but hidden among/under the black rectangles (clipping gone wrong?) - as can be verified in outline view mode. The colors though are missing: all paths use an aparently greyscale EMFimage as pattern fill.

@David - could you take a closer look what's happening here?

tags: added: emf importing
Changed in inkscape:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
su_v (suv-lp) wrote :

Related (AFAICT same issues) as with the diagram in EMF file from
- Bug #382421 “EMF Import: Semi-transparent object disappear”
  <https://bugs.launchpad.net/inkscape/+bug/382421>

Revision history for this message
su_v (suv-lp) wrote :
Revision history for this message
David Mathog (mathog) wrote :

EMF is a paint graphics format (it could encode the drawing of the Mona Lisa, brush stroke by brush stroke, mixing colors on the painting as it went). Despite that, _some_ EMF records are easily turned into objects. The example file uses paint mixing operations via BitBlt records, with varying Raster Operations to obtain the colors that are shown in Windows Preview (or any other application that uses GDI libraries). Inkscape cannot do that, it is not a raster graphics program. The best it can do is pull out the object like parts of the file, which are here the graphs (as Polygon16 records). BitBlts are sometimes used to draw rectangles, so they must be shown too. In this file it does not work out well, the graph parts end up gray and buried beneath a mound of colored rectangles.

If you have a windows machine, obtain a program called "metafile explorer" (http://www.flounder.com/metafileexplorer.htm) and open the example file in it. Check the "to selection" draw option, and then work your way down through the record list selecting one record at a time. This will show you exactly how complicated the paint operations are that were used to construct this EMF file.

I would mark this "do not fix" if there is a "cannot fix" option.

Revision history for this message
David Mathog (mathog) wrote :

Correction #7, last line, "is a cannot fix" should have been "is not a cannot fix".

Revision history for this message
Beluga (buovjaga) wrote :

Still imported wrong. Kind of like stacker bar charts instead of lines.

Arch Linux 64-bit, KDE Plasma 5
Inkscape 0.92+devel 15099 (GTK3)

Revision history for this message
David Mathog (mathog) wrote :

The inability to correctly import EMF raster graphics has two "solutions", as I see it, both requiring some sort of special case import. The first method would be to try to detect that a series of bitblt operations is in progress, emulate what Windows does for those operations, and produce as a final result a PNG which results from those operations. The second would be to extend on the first to reduce that image to simpler objects (lines, simple shapes, and the like.) If anybody ever has the time or inclination the first looks like a couple of weeks worth of work. The second one is much harder, maybe about as much work as Master's thesis? Perhaps less if there is some code around already for this which could be adapted.

Revision history for this message
David Mathog (mathog) wrote :

There is a reference for the raster operations, if anybody wants to see what comment 10
is referring to.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd162892%28v=vs.85%29.aspx

Revision history for this message
Alvin Penner (apenner) wrote :

as far as I remember, this bug is not related in any way to raster graphics imports. This bug is a re-issue of Bug 382420, which was originally fixed in rev 10128.
see http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/10128
The fix in rev 10128 was subsequently over-written by changes made since then. The original fix involved creating an PEMRCREATEDIBPATTERNBRUSHPT. That should probably be attempted again to see if it still works.

Revision history for this message
David Mathog (mathog) wrote :

Please get a copy of Windows Metafile Explorer and look at the EMF. A large part of it consists of a long series of BITBLT and SETROP2 commands. It is using binary raster operations to define what the pen does and it is fiddling around with color logic operations to draw and redraw blocks of the screen to compose the colors drawn (in a very complex manner).

For instance, once you have the test EMF opened in Metafile explorer, set that program with:

draw: to selection
rectangle: client

click on one of the EMR_SETROP2 lines about 2/3 of the way to the bottom, then click on the
EMR_BITBLT which preceded or follows it. In most of those in one position you will see a big colored rectangle, and in the other that rectangle will have gone away.

To follow what it does in metafile explorer click downwards on one record at a time and it will display the draw operations up to the record selected. Some records will not change the display because their actions do not take effect into a BITBLT or other operation which follows it.

Revision history for this message
David Mathog (mathog) wrote :

I should add, this EMF may have worked on Windows only versions of Inkscape prior to the introduction of my portable EMF code, as at that time it was making direct calls to the OS, which of course supports both binary raster and ternary raster operations. If you still have an old enough version to check, it would be interesting to see if any of the drawn lines are selectable.

Alvin Penner (apenner)
Changed in inkscape:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.