A Windows Metafile .wmf bug?

Bugs found in XnView Classic. Please report only one bug per topic!

Moderators: XnTriq, helmut, xnview

Post Reply
cday
XnThusiast
Posts: 3985
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

A Windows Metafile .wmf bug?

Post by cday »

The attached Example_EMF.wmf file displays differently in [another popular freeware program] and in XnView Classic 2.34 :
Left - Other program 997 x 1007 px<br />Right - XnView Classic 2.34 541 x 547 px
Left - Other program 997 x 1007 px
Right - XnView Classic 2.34 541 x 547 px
Comparing the images, the [other program] on the left and XnView on the right, it looks as if the XnView image is probably slightly offset vertically downwards, with a narrow white band at the top and a small amount of the image missing at the bottom.

Both screenshots are with viewing mode 'Fit image to window'.

The displayed pixel dimensions are also noticeably different, 997 x 1007 px for the [other program] and 541 x 547 for XnView Classic .
Attachments
Example_WMF.zip
(447 Bytes) Downloaded 106 times
Mixer
Banned
Posts: 166
Joined: Fri Aug 28, 2015 6:24 am

Re: A Windows Metafile .wmf bug?

Post by Mixer »

Yes, a bug I think, but you should report it to developers of [another popular freeware program] IMHO.
WMF is a vector graphics format, and by the output from Inkscape (which defines this file to be originally 506x512 dots) I declare XnView the winner in this duel. Well, there is some chance both Inkscape and XnView are wrong too.
Image
Internet Explorer doesn't draw it right from the most top line of window client area either, leaving white stripe.
User avatar
XnTriq
Moderator & Librarian
Posts: 6339
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: A Windows Metafile .wmf bug?

Post by XnTriq »

Here's what MetaFileExplorer has to say about Example_WMF.WMF:

Code: Select all

EMR_HEADER
	DWORD iType: 1
	DWORD nSize: 108
	RECTL rclBounds: {258, 27, 2745, 3082}
	RECTL rclFrame: {64.50mm, 6.33mm, 686.25mm, 722.34mm}
	DWORD dSignature: ' EMF'
	DWORD nVersion: 0x10000
	DWORD nBytes: 620
	DWORD nRecords: 24
	WORD nHandles: 3
	WORD sReserved: 0
	DWORD nDescription: 0
	DWORD offDescription: 0
	DWORD nPalEntries: 0
	SIZEL szlDevice: {1280, 1024}
	SIZEL szlMillimeters: {320, 240}
EMR_SETVIEWPORTEXTEX
	SIZEL szlExtent: {1280, 1024}
EMR_SETWINDOWEXTEX
	SIZEL szlExtent: {1280, 1024}
EMR_SETWINDOWEXTEX
	SIZEL szlExtent: {3035, 3067}
EMR_SETWINDOWORGEX
	POINTL ptlOrigin: {0, 0}
EMR_SETROP2
	DWORD iMode: R2_COPYPEN
EMR_SETPOLYFILLMODE
	DWORD iMode: ALTERNATE
EMR_SETBKMODE
	DWORD iMode: OPAQUE
EMR_SETBKCOLOR
	COLORREF crColor: RGB(255, 255, 255)
EMR_SETTEXTALIGN
	DWORD iMode: TA_BASELINE | TA_LEFT | TA_NOUPDATECP
EMR_CREATEPEN
	DWORD ihPen: 1
	LOGPEN lopn
		UINT lopnStyle: PS_SOLID
		POINT lopnWidth: {0, 0}
		COLORREF lopnColor: RGB(0, 0, 0)
EMR_SELECTOBJECT
	DWORD ihObject: 1
EMR_SETBKMODE
	DWORD iMode: TRANSPARENT
EMR_CREATEBRUSHINDIRECT
	DWORD ihBrush: 2
	LOGBRUSH32 lb
		UINT lbStyle: BS_SOLID
		COLORREF lbColor: RGB(0, 255, 255)
		ULONG lbHatch: ignored
EMR_SELECTOBJECT
	DWORD ihObject: 2
EMR_SELECTOBJECT
	DWORD ihObject: ENHMETA_STOCK_OBJECT | NULL_PEN
EMR_DELETEOBJECT
	DWORD ihObject: 1
EMR_POLYGON16
	RECTL rclBounds: {258, 27, 2745, 3082}
	DWORD cpts: 41
	POINTL apts[1]
		[0] {333, 27}
		[1] {1178, 27}
		[2] {1424, 46}
		[3] {1625, 104}
		[4] {1774, 195}
		[5] {1868, 319}
		[6] {1900, 469}
		[7] {1867, 643}
		[8] {1763, 838}
		[9] {1584, 1051}
		[10] {576, 2058}
		[11] {395, 2269}
		[12] {291, 2464}
		[13] {258, 2638}
		[14] {292, 2789}
		[15] {385, 2911}
		[16] {535, 3004}
		[17] {735, 3061}
		[18] {983, 3082}
		[19] {1860, 3082}
		[20] {2705, 3082}
		[21] {1828, 3082}
		[22] {1580, 3061}
		[23] {1380, 3004}
		[24] {1230, 2911}
		[25] {1137, 2789}
		[26] {1103, 2638}
		[27] {1136, 2464}
		[28] {1240, 2269}
		[29] {1421, 2058}
		[30] {2429, 1051}
		[31] {2608, 838}
		[32] {2712, 643}
		[33] {2745, 469}
		[34] {2713, 319}
		[35] {2619, 195}
		[36] {2470, 104}
		[37] {2269, 46}
		[38] {2023, 27}
		[39] {1178, 27}
		[40] {333, 27}
EMR_SELECTOBJECT
	DWORD ihObject: ENHMETA_STOCK_OBJECT | BLACK_PEN
EMR_SELECTOBJECT
	DWORD ihObject: ENHMETA_STOCK_OBJECT | WHITE_BRUSH
EMR_SELECTPALETTE
	DWORD ihPal: ENHMETA_STOCK_OBJECT | DEFAULT_PALETTE
EMR_EXTSELECTCLIPRGN
	DWORD cbRgnData: 0
	DWORD iMode: RGN_COPY
	BYTE RgnData[1]
		RGNDATAHEADER rdh
			DWORD dwSize: 40
			DWORD iType: 12
			DWORD nCount: 2
			DWORD nRgnSize: 14
			RECT rcBound: {20, 0, 16, 20}
		char Buffer[1]
EMR_DELETEOBJECT
	DWORD ihObject: 2
EMR_EOF
	DWORD nPalEntries: 0
	DWORD offPalEntries: 16
	DWORD nSizeLast: 20
I've converted cday's WMF with the following programs to PNG:
  1. Cerious ThumbsPlus
  2. Corel Photo-Paint
  3. Deneba Canvas
  4. FastStone Image Viewer
  5. Jasc Paint Shop Pro
  6. MeeSoft Image Analyzer
  7. Microsoft Internet Explorer
  8. Ontrack PowerDesk Pro
  9. TechSmith SnagIt Studio
  10. Xara XS
Conversion with #4 + #6 and #8 + #9 yields identical results.
With the exception of Canvas + Xara (+ I****View), all tested applications (including XnView) produce an offset from the top border.
Attachments
p129705.zip
(9.8 KiB) Downloaded 103 times
cday
XnThusiast
Posts: 3985
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: A Windows Metafile .wmf bug?

Post by cday »

Mixer wrote:Yes, a bug I think, but you should report it to developers of [aother popular freeware program] IMHO.
I was careful to include a question mark in the subject title...
Mixer wrote:WMF is a vector graphics format, and by the output from Inkscape (which defines this file to be originally 506x512 dots) I declare XnView the winner in this duel. Well, there is some chance both Inkscape and XnView are wrong too.
There is surprising variation in the detailed image pixel dimensions from the several programs tested, but the [other] program dimensions seem out of line the rest...
XnTriq wrote: I've converted cday's WMF with the following programs to PNG:
  1. Cerious ThumbsPlus
  2. Corel Photo-Paint
  3. Deneba Canvas
  4. FastStone Image Viewer
  5. Jasc Paint Shop Pro
  6. MeeSoft Image Analyzer
  7. Microsoft Internet Explorer
  8. Ontrack PowerDesk Pro
  9. TechSmith SnagIt Studio
  10. Xara XS
Conversion with #4 + #6 and #8 + #9 yields identical results.
With the exception of Canvas + Xara (+ I****View), all tested applications (including XnView) produce an offset from the top border.
Examining the two images I originally posted, intuitively the [other] program result on the left somehow seems more plausible: a symmetrical outline vertically without a white band at the top. So possibly, notwithstanding the results of XnTriq's careful tests, that is indeed the correct rendering of the file...

Some more tests using other example WMF files might be helpful, if anyone has the time...
Mixer
Banned
Posts: 166
Joined: Fri Aug 28, 2015 6:24 am

Re: A Windows Metafile .wmf bug?

Post by Mixer »

If you look at EMR_POLYGON16 defining array of points, you'll see none has its Y coordinate set to 0, therefore this mirrored-S object shouldn't touch upper border of the canvas. As you can see, its bounding rectangle has coordinates of its left-top and right-bottom corners (258, 27) and (2745, 3082) respectively. To me it looks like if it's a matter of what you count as desirable result of processing vector graphics metafile, only drawn texture or texture printed onto canvas. You need to read specification of WMF/EMF format.

Code: Select all

EMR_POLYGON16
	RECTL rclBounds: {258, 27, 2745, 3082}
	DWORD cpts: 41
	POINTL apts[1]
		[0] {333, 27}
		[1] {1178, 27}
		[2] {1424, 46}
		[3] {1625, 104}
		[4] {1774, 195}
		[5] {1868, 319}
		[6] {1900, 469}
		[7] {1867, 643}
		[8] {1763, 838}
		[9] {1584, 1051}
		[10] {576, 2058}
		[11] {395, 2269}
		[12] {291, 2464}
		[13] {258, 2638}
		[14] {292, 2789}
		[15] {385, 2911}
		[16] {535, 3004}
		[17] {735, 3061}
		[18] {983, 3082}
		[19] {1860, 3082}
		[20] {2705, 3082}
		[21] {1828, 3082}
		[22] {1580, 3061}
		[23] {1380, 3004}
		[24] {1230, 2911}
		[25] {1137, 2789}
		[26] {1103, 2638}
		[27] {1136, 2464}
		[28] {1240, 2269}
		[29] {1421, 2058}
		[30] {2429, 1051}
		[31] {2608, 838}
		[32] {2712, 643}
		[33] {2745, 469}
		[34] {2713, 319}
		[35] {2619, 195}
		[36] {2470, 104}
		[37] {2269, 46}
		[38] {2023, 27}
		[39] {1178, 27}
		[40] {333, 27}
Btw, even comparing to output of utilities which don't preserve bounding borders of this aqua curve, [another freeware application] fails because bending angle of the drawn object is wrong.
cday
XnThusiast
Posts: 3985
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: A Windows Metafile .wmf bug?

Post by cday »

Mixer wrote:If you look at EMR_POLYGON16 defining array of points, you'll see none has its Y coordinate set to 0, therefore this mirrored-S object shouldn't touch upper border of the canvas. As you can see, its bounding rectangle has coordinates of its left-top and right-bottom corners (258, 27) and (2745, 3082) respectively.
Thank you for the valuable technical insights you are able to provide!

But if there should be a band above the object in the image, as displayed by XnView and most other software, surely the lowest part of the object should also be displayed, as in the [other] program image, so that the full symmetrical shape is visible?
Mixer wrote:To me it looks like if it's a matter of what you count as desirable result of processing vector graphics metafile, only drawn texture or texture printed onto canvas. You need to read specification of WMF/EMF format.
Surely the full canvas??
Mixer
Banned
Posts: 166
Joined: Fri Aug 28, 2015 6:24 am

Re: A Windows Metafile .wmf bug?

Post by Mixer »

I guess if you stretch enough horizontally mirrored-S from any of non-[other] pictures till it matches width of mirrored-S from [other] picture (if they have equal height), you'll get two identical images. To me it looks like this [other] software expands drawn area (bounding rectangle and wavy shape) to all available canvas, malforming its proportions.
And as addition, I suspect that WMF vector graphics may have areas of drawings not supposed to be shown in final picture, like scenes made in Adobe Flash do.
I have not dig in all values of .wmf file header, so you can recalculate it yourself, if you like, where goes which point of 3xxx to 3xxx pixel texture in xxx to xxx millimeters printing area declared there, and how it supposed to look on the screen.
Surely the full canvas??
Xara_XS and Deneba_Canvas disagree (you can download zip attached by XnTriq to see).
User avatar
XnTriq
Moderator & Librarian
Posts: 6339
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: A Windows Metafile .wmf bug?

Post by XnTriq »

Ciarán Ó Duibhín ([url=http://www.smo.uhi.ac.uk/~oduibhin/oideasra/viewmeta/viewmeta.htm]ViewMeta[/url]) wrote:Note added in 2012: for a number of years now, the free general graphics viewer I****View has been able to display .emf files at any desired size, by magnifying the vector graphics and then converting to bitmap (rather than, as previously, by converting to bitmap and then magnifying, which severely limited the obtainable resolution). There is now no advantage in using ViewMeta, and I recommend the use of I****View to display .emf files. BUT PLEASE READ ON …

May 2014: It is necessary to qualify the above note. Contrary to what I wrote there, I****View still converts an .emf file to a bitmap and performs magnification on that bitmap. The size in pixels of the initial bitmap depends on the screen resolution, and it seems to be just the general increase in screen resolution which has resulted in improved display of .emf files in I****View in recent years. Also I****View has added an option "Use resample for fitting" to the View / Display options menu, and this option is set on by default, but it does not appear to have much effect on the display of .emf files. If the display is still unsatisfactory, a trick which may help is to select "Fit window to image", enlarge the drawing, select "Fit images to window", and select (from the Open menu) "Reopen". However this procedure cannot enlarge the image beyond the point where it fills the screen. In summary, this means that there are .emf files for which ViewMeta may still give better results.
EMFexplorer allows you to view EMF records as text. This is the tools's take on Example_WMF.WMF:

Code: Select all

R0001: [001] EMR_HEADER	(s=108)	{{ Bounds(44,5,469,562), Frame(0,0,12977,13111), ver(0x10000), size(1020), recs(26), handles(3), pals(0), dev_pix(1280,1024), dev_mil(320,240), pixf_size(0), pixf_ofs(0), openGL(0) }}
R0002: [070] EMR_GDICOMMENT	(s=388)	{GDI.Embedded WMF}
R0003: [017] EMR_SETMAPMODE	(s=12)	{iMode(8=MM_ANISOTROPIC)}
R0004: [011] EMR_SETVIEWPORTEXTEX	(s=16)	{szlExtent(519,559)}
R0005: [009] EMR_SETWINDOWEXTEX	(s=16)	{szlExtent(519,559)}
R0006: [009] EMR_SETWINDOWEXTEX	(s=16)	{szlExtent(3035,3067)}
R0007: [010] EMR_SETWINDOWORGEX	(s=16)	{ptlOrigin(0,0)}
R0008: [020] EMR_SETROP2	(s=12)	{iMode(13=R2_COPYPEN)}
R0009: [019] EMR_SETPOLYFILLMODE	(s=12)	{iMode(1=ALTERNATE)}
R0010: [018] EMR_SETBKMODE	(s=12)	{iMode(2=OPAQUE)}
R0011: [025] EMR_SETBKCOLOR	(s=12)	{0x00FFFFFF}
R0012: [022] EMR_SETTEXTALIGN	(s=12)	{iMode(24= TA_BASELINE)}
R0013: [038] EMR_CREATEPEN	(s=28)	{ihPen(1), style(0=PS_SOLID | COSMETIC), width(0), color(0x00000000)}
R0014: [037] EMR_SELECTOBJECT	(s=12)	{Table object: 1=OBJ_PEN.(PS_SOLID | COSMETIC)}
R0015: [018] EMR_SETBKMODE	(s=12)	{iMode(1=TRANSPARENT)}
R0016: [039] EMR_CREATEBRUSHINDIRECT	(s=24)	{ihBrush(2), style(0=BS_SOLID, color:0x00FFFF00)}
R0017: [037] EMR_SELECTOBJECT	(s=12)	{Table object: 2=OBJ_BRUSH.(BS_SOLID)}
R0018: [037] EMR_SELECTOBJECT	(s=12)	{Stock object: 8=OBJ_PEN.(PS_NULL)}
R0019: [040] EMR_DELETEOBJECT	(s=12)	{ihObject(1)}
R0020: [086] EMR_POLYGON16	(s=192)	{rclBounds(44,5,469,562), nbPoints:41, P1(333,27) - Pn(333,27)}
R0021: [037] EMR_SELECTOBJECT	(s=12)	{Stock object: 7=OBJ_PEN.(PS_SOLID | COSMETIC)}
R0022: [037] EMR_SELECTOBJECT	(s=12)	{Stock object: 0=OBJ_BRUSH.(BS_SOLID)}
R0023: [048] EMR_SELECTPALETTE	(s=12)	{ihPal(Stock object: 15)}
R0024: [075] EMR_EXTSELECTCLIPRGN	(s=16)	{iMode(5=RGN_COPY), RGNDATA[ptr:0x00152d7c, size:0, box()]}
R0025: [040] EMR_DELETEOBJECT	(s=12)	{ihObject(2)}
R0026: [014] EMR_EOF	(s=20)	{nPalEntries:0, offPalEntries:16, nSizeLast:20}
Mixer
Banned
Posts: 166
Joined: Fri Aug 28, 2015 6:24 am

Re: A Windows Metafile .wmf bug?

Post by Mixer »

With or without white space, all presented viewers (including XnView) draw this image differently than [the other app], which deforms the shape.

P.S. (added later than last XnTriq's post) Try to insert this .wmf into Microsoft Word document, I expect those guys should know how their format is supposed to look.

P.P.S. uploaded for testing purpose (if anyone is interested) quick made with Inkscape .wmf drawing. It is just A4 white canvas with red circle partially moved beyond left border in the top half of picture. XnView, MS Paint display it as expected. [another popular freeware program] v4.4.1 gives me A4-sized red ellipse, that's not what I meant.
Attachments
drawing.wmf.zip
(583 Bytes) Downloaded 92 times
Last edited by Mixer on Wed Jan 20, 2016 3:56 am, edited 2 times in total.
User avatar
XnTriq
Moderator & Librarian
Posts: 6339
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: A Windows Metafile .wmf bug?

Post by XnTriq »

Mixer wrote:With or without white space, all presented viewers (including XnView) draw this image differently than [the other app], which deforms the shape.
Confirmed:
  • FrazMitic EMFexplorer
  • GP Directory Opus
  • iGrafx Image (Micrografx Picture Publisher)
  • I****View
  • ViewMeta
  • Visual Integrity Metafile Viewer
Attachments
p129720.zip
(9.74 KiB) Downloaded 90 times
User avatar
omniplex
Posts: 127
Joined: Thu Feb 10, 2011 1:52 pm
Location: Hamburg
Contact:

Re: A Windows Metafile .wmf bug?

Post by omniplex »

Mixer wrote:Try to insert this .wmf into Microsoft Word document, I expect those guys should know how their format is supposed to look.
I can open it directly in MS Paint on Windows 7, in IE 9 (whining that I should install IE 11 now, sigh), and I can add it as picture to an example.odt in WordPad.exe. When ODT works I expect that RTF and DOCX would be identical or at least similar.

FWIW, the visual effect is nearer to the right side (XnView) in cday's post. Is there a special reason why nobody dares mention "other software" by name? I think I know that you're not talking about ImageMagick or the GIMP. :-P
User avatar
XnTriq
Moderator & Librarian
Posts: 6339
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: A Windows Metafile .wmf bug?

Post by XnTriq »

  1. Cerious ThumbsPlus
  2. Corel Photo-Paint
  3. Deneba Canvas
  4. FastStone Image Viewer
  5. FrazMitic EMFexplorer
  6. GP Directory Opus
  7. iGrafx Image
  8. IrfanView
  9. Jasc Paint Shop Pro
  10. MeeSoft Image Analyzer
  11. Microsoft Internet Explorer
  12. Microsoft Paint
  13. Microsoft Windows Picture and Fax Viewer
  14. Ontrack PowerDesk Pro
  15. TechSmith SnagIt Studio
  16. ViewMeta
  17. Visual Integrity Metafile Viewer
  18. Xara XS
  19. XnView
Attachments
p129748.gif
p129748.gif (20.7 KiB) Viewed 2781 times
User avatar
XnTriq
Moderator & Librarian
Posts: 6339
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: A Windows Metafile .wmf bug?

Post by XnTriq »

Mixer wrote:P.P.S. uploaded for testing purpose (if anyone is interested) quick made with Inkscape .wmf drawing. It is just A4 white canvas with red circle partially moved beyond left border in the top half of picture. XnView, MS Paint display it as expected. [another popular freeware program] v4.4.1 gives me A4-sized red ellipse, that's not what I meant.
  • Cerious ThumbsPlus
  • Corel Photo-Paint
  • Deneba Canvas
  • FastStone Image Viewer
  • FrazMitic EMFexplorer
  • GP Directory Opus (“Unknown picture format”)
  • iGrafx Image
  • IrfanView
  • Jasc Paint Shop Pro
  • MeeSoft Image Analyzer
  • Microsoft Internet Explorer
  • Microsoft Paint
  • Microsoft Windows Picture & Fax Viewer
  • Ontrack PowerDesk Pro (“Image : drawing.wmf - Not enough memory available!”)
  • PhotoFiltre
  • TechSmith SnagIt Studio (“Unable to open the background image”)
  • Visual Integrity Metafile Viewer
  • Xara XS (“Could not open the input file.”)
  • XnView Classic
  • XnView MP
Attachments
p129786.zip
Conversion results for drawing.wmf
(19.67 KiB) Downloaded 82 times
User avatar
omniplex
Posts: 127
Joined: Thu Feb 10, 2011 1:52 pm
Location: Hamburg
Contact:

Re: A Windows Metafile .wmf bug?

Post by omniplex »

omniplex wrote:IE 9
Ditto IE11 after I've upgraded IE9. Oddly IE11 cannot display the other example drawing.wmf, it shows a broken image icon. IE11 can display the Image0.emf attached to the emz XnView crash thread, but so far I found nothing that can handle the obscure EMZ in this thread.

In practice I've never seen any WMF or EMF on my box for years (I vaguely recall a printer spool folder). But any format with its own icon in XnView (including WMF and EMF, but not WMZ or EMZ) is by definition relevant -- until Pierre kills those icons. :twisted:
Post Reply