André Hentschel : view: Add support for enhanced metafiles.
Alexandre Julliard
julliard at winehq.org
Wed Jul 27 13:25:27 CDT 2011
Module: wine
Branch: master
Commit: 8286bfee71fc3ed92cb3dd2b552e5fa544e7a141
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8286bfee71fc3ed92cb3dd2b552e5fa544e7a141
Author: André Hentschel <nerv at dawncrow.de>
Date: Mon Jul 25 23:52:50 2011 +0200
view: Add support for enhanced metafiles.
---
programs/view/view.c | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/programs/view/view.c b/programs/view/view.c
index e266209..917784d 100644
--- a/programs/view/view.c
+++ b/programs/view/view.c
@@ -27,9 +27,10 @@ static char szAppName[5] = "View";
static char szTitle[80];
static HMETAFILE hmf;
+static HENHMETAFILE enhmf;
static int deltax = 0, deltay = 0;
static int width = 0, height = 0;
-static BOOL isAldus;
+static BOOL isAldus, isEnhanced;
#include "pshpack1.h"
typedef struct
@@ -52,7 +53,7 @@ static BOOL FileOpen(HWND hWnd, char *fn, int fnsz)
0, 0, NULL, NULL, 0, 0, NULL,
fnsz, NULL, 0, NULL, NULL,
OFN_SHOWHELP, 0, 0, NULL, 0, NULL };
- ofn.lpstrFilter = "Metafiles\0*.wmf\0";
+ ofn.lpstrFilter = "Metafiles\0*.wmf;*.emf\0";
ofn.hwndOwner = hWnd;
ofn.lpstrFile = fn;
if( fnsz < 1 )
@@ -61,6 +62,25 @@ static BOOL FileOpen(HWND hWnd, char *fn, int fnsz)
return GetOpenFileName(&ofn);
}
+static BOOL FileIsEnhanced( LPCSTR szFileName )
+{
+ HFILE hInFile;
+ ENHMETAHEADER enh;
+
+ if( (hInFile = _lopen( szFileName, OF_READ ) ) == HFILE_ERROR )
+ return FALSE;
+
+ if( _lread( hInFile, &enh, sizeof(ENHMETAHEADER) ) != sizeof(ENHMETAHEADER) )
+ {
+ _lclose( hInFile );
+ return FALSE;
+ }
+ _lclose( hInFile );
+
+ /* Is it enhanced? */
+ return (enh.dSignature == ENHMETA_SIGNATURE);
+}
+
static BOOL FileIsPlaceable( LPCSTR szFileName )
{
HFILE hInFile;
@@ -154,7 +174,14 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM
SetWindowExtEx(ps.hdc, width, height, NULL);
SetViewportExtEx(ps.hdc, width, height, NULL);
SetViewportOrgEx(ps.hdc, deltax, deltay, NULL);
- if(hmf) PlayMetaFile(ps.hdc, hmf);
+ if (isEnhanced && enhmf)
+ {
+ RECT r;
+ GetClientRect(hwnd, &r);
+ PlayEnhMetaFile(ps.hdc, enhmf, &r);
+ }
+ else if (hmf)
+ PlayMetaFile(ps.hdc, hmf);
EndPaint(hwnd, &ps);
}
break;
@@ -171,7 +198,11 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM
hmf = GetPlaceableMetaFile(hwnd, filename);
} else {
RECT r;
- hmf = GetMetaFile(filename);
+ isEnhanced = FileIsEnhanced(filename);
+ if (isEnhanced)
+ enhmf = GetEnhMetaFile(filename);
+ else
+ hmf = GetMetaFile(filename);
GetClientRect(hwnd, &r);
width = r.right - r.left;
height = r.bottom - r.top;
More information about the wine-cvs
mailing list