[2/4] view: Add support for enhanced metafiles
André Hentschel
nerv at dawncrow.de
Mon Jul 25 16:52:50 CDT 2011
tried hard to keep the filestyle, only using spaces instead of tabs in new code (it already was mixed)
---
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 402b35b..884fb7f 100644
--- a/programs/view/view.c
+++ b/programs/view/view.c
@@ -27,9 +27,10 @@ char szAppName[5] = "View";
char szTitle[80];
HMETAFILE hmf;
+HENHMETAFILE enhmf;
int deltax = 0, deltay = 0;
int width = 0, height = 0;
-BOOL isAldus;
+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;
@@ -157,7 +177,14 @@ LRESULT CALLBACK WndProc(HWND hwnd,
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;
@@ -174,7 +201,11 @@ LRESULT CALLBACK WndProc(HWND hwnd,
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;
--
Best Regards, André Hentschel
More information about the wine-patches
mailing list