LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { ENHMETAHEADER emh ; HDC hdc, hdcEMF ; HENHMETAFILE hemfOld, hemf ; PAINTSTRUCT ps ; RECT rect ; switch (message) { case WM_CREATE: // Retrieve existing metafile and header hemfOld = GetEnhMetaFile (TEXT ("..\\emf3\\emf3.emf")) ; GetEnhMetaFileHeader (hemfOld, sizeof (ENHMETAHEADER), &emh) ; // Create a new metafile DC hdcEMF = CreateEnhMetaFile (NULL, TEXT ("emf7.emf"), NULL, TEXT ("EMF7\0EMF Demo #7\0")) ; // Enumerate the existing metafile EnumEnhMetaFile (hdcEMF, hemfOld, EnhMetaFileProc, NULL, (RECT *) & emh.rclBounds) ; // Clean up hemf = CloseEnhMetaFile (hdcEMF) ; DeleteEnhMetaFile (hemfOld) ; DeleteEnhMetaFile (hemf) ; return 0 ; case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; GetClientRect (hwnd, &rect) ; rect.left = rect.right / 4 ; rect.right = 3 * rect.right / 4 ; rect.top = rect.bottom / 4 ; rect.bottom = 3 * rect.bottom / 4 ; hemf = GetEnhMetaFile (TEXT ("emf7.emf")) ; PlayEnhMetaFile (hdc, hemf, &rect) ; DeleteEnhMetaFile (hemf) ; EndPaint (hwnd, &ps) ; return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
void PaintRoutine (HWND hwnd, HDC hdc, int cxArea, int cyArea) { ENHMETAHEADER emh ; HENHMETAFILE hemf ; int cxMms, cyMms, cxPix, cyPix, cxImage, cyImage ; RECT rect ; cxMms = GetDeviceCaps (hdc, HORZSIZE) ; cyMms = GetDeviceCaps (hdc, VERTSIZE) ; cxPix = GetDeviceCaps (hdc, HORZRES) ; cyPix = GetDeviceCaps (hdc, VERTRES) ; hemf = GetEnhMetaFile (TEXT ("emf11.emf")) ; GetEnhMetaFileHeader (hemf, sizeof (emh), &emh) ; cxImage = emh.rclFrame.right - emh.rclFrame.left ; cyImage = emh.rclFrame.bottom - emh.rclFrame.top ; cxImage = cxImage * cxPix / cxMms / 100 ; cyImage = cyImage * cyPix / cyMms / 100 ; rect.left = (cxArea - cxImage) / 2 ; rect.top = (cyArea - cyImage) / 2 ; rect.right = (cxArea + cxImage) / 2 ; rect.bottom = (cyArea + cyImage) / 2 ; PlayEnhMetaFile (hdc, hemf, &rect) ; DeleteEnhMetaFile (hemf) ; }
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc ; HENHMETAFILE hemf ; PAINTSTRUCT ps ; RECT rect ; switch (message) { case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; GetClientRect (hwnd, &rect) ; rect.left = rect.right / 4 ; rect.right = 3 * rect.right / 4 ; rect.top = rect.bottom / 4 ; rect.bottom = 3 * rect.bottom / 4 ; hemf = GetEnhMetaFile (TEXT ("..\\emf3\\emf3.emf")) ; EnumEnhMetaFile (hdc, hemf, EnhMetaFileProc, NULL, &rect) ; DeleteEnhMetaFile (hemf) ; EndPaint (hwnd, &ps) ; return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
void OpenEnhMetaFile(HWND hWnd) { OPENFILENAME LFile; WCHAR FileName[MAX_PATH], FilePath[MAX_PATH]; FileName[0] = '\0'; FilePath[0] = '\0'; LFile.lStructSize = sizeof(OPENFILENAME); LFile.hwndOwner = hWnd; LFile.lpstrFilter =L"EMF (*.emf)\0"; LFile.lpstrCustomFilter = 0; LFile.lpstrFile = FilePath; LFile.nMaxFile = MAX_PATH * sizeof(WCHAR); LFile.lpstrFileTitle = FileName; LFile.nMaxFileTitle = MAX_PATH * sizeof(WCHAR); LFile.lpstrInitialDir = 0; LFile.lpstrDefExt = L"emf\0"; LFile.lpstrTitle = L"Open file from:"; LFile.Flags = OFN_PATHMUSTEXIST; GetOpenFileName(&LFile); HENHMETAFILE enhFile = GetEnhMetaFile(LFile.lpstrFile); RECT client; GetClientRect(hWnd, &client); client.left += scrhor / 3; client.top += scrvert / 3; client.right += scrhor / 3; client.bottom += scrvert / 3; PlayEnhMetaFile(hdc1, enhFile, &client); PlayEnhMetaFile(hdc2, enhFile, &client); DeleteEnhMetaFile(enhFile); InvalidateRect(hWnd, NULL, false); }
/* * clipboard_file_to_data - ファイルからデータを作成 */ HANDLE clipboard_file_to_data(const TCHAR *file_name, TCHAR *format_name, DWORD *ret_size, TCHAR *err_str) { HANDLE ret = NULL; BYTE *data; BYTE *mem; DWORD size; switch (clipboard_get_format(0, format_name)) { case CF_OWNERDISPLAY: return NULL; case CF_DSPMETAFILEPICT: case CF_METAFILEPICT: // メタファイル if ((ret = GlobalAlloc(GHND, sizeof(METAFILEPICT))) == NULL) { message_get_error(GetLastError(), err_str); return NULL; } if ((mem = GlobalLock(ret)) == NULL) { message_get_error(GetLastError(), err_str); GlobalFree(ret); return NULL; } if ((((METAFILEPICT *)mem)->hMF = GetMetaFile(file_name)) == NULL) { message_get_error(GetLastError(), err_str); GlobalUnlock(ret); GlobalFree(ret); return NULL; } size = GetMetaFileBitsEx(((METAFILEPICT *)mem)->hMF, 0, NULL); GlobalUnlock(ret); break; case CF_DSPENHMETAFILE: case CF_ENHMETAFILE: if ((ret = GetEnhMetaFile(file_name)) == NULL) { message_get_error(GetLastError(), err_str); } size = GetEnhMetaFileBits(ret, 0, NULL); break; default: // その他 // ファイルの読み込み if ((data = file_read_buf(file_name, &size, err_str)) == NULL) { return NULL; } // バイト列をデータに変換 ret = clipboard_bytes_to_data(format_name, data, &size); mem_free(&data); break; } if (ret_size != NULL) { *ret_size = size; } return ret; }
VOID OpenImage(HWND hWnd, LPCWSTR fileName) { HDC windowDC = GetDC(hWnd); HENHMETAFILE hemf = GetEnhMetaFile(fileName); GetClientRect(hWnd, &rect); ClearWindow(memoryDC); RefreshMetafileDC(hWnd); PlayEnhMetaFile(memoryDC, hemf, &rect); PlayEnhMetaFile(metafileDC, hemf, &rect); ReleaseDC(hWnd, windowDC); DeleteEnhMetaFile(hemf); }
HENHMETAFILE QueryOpenEMFFile(TCHAR szFileName[]) { KFileDialog fd; if ( fd.GetOpenFileName(NULL, _T("emf|spl"), _T("Enhanced Metafiles|Win NT/2000 EMF Spool Files")) ) { if ( szFileName ) _tcscpy(szFileName, fd.m_TitleName); return GetEnhMetaFile(fd.m_TitleName); } else return NULL; }
void wxEnhMetaFile::Init() { if ( m_filename.empty() ) { m_hMF = 0; } else // have valid file name, load metafile from it { m_hMF = GetEnhMetaFile(m_filename); if ( !m_hMF ) wxLogSysError(_("Failed to load metafile from file \"%s\"."), m_filename.c_str()); } }
BOOL KCanvasWindow::LoadEmfFile(const char *filename) { HENHMETAFILE hNew; int len; hNew = GetEnhMetaFile(filename); if (hNew!=NULL) // standard EMF file { len = GetEnhMetaFileHeader(hNew, sizeof(MetaHeader), &MetaHeader); assert(len != 0); } else { KInputFile * ntemf = new KInputFile; if (ntemf==NULL) return FALSE; if (!ntemf->Open(filename)) return FALSE; if (!CheckNTSpoolEmfFile(ntemf, & MetaHeader)) { ntemf->Close(); return FALSE; } if (hNTMetaFile) delete hNTMetaFile; hNTMetaFile = ntemf; } if (hMetaFile) DeleteEnhMetaFile(hMetaFile); hMetaFile = hNew; strcpy(CurEmfFileName, filename); // make sure canvas window in visible and big enough, by resizing it's parent EmfScope.WakeUp(); SetScaleColor(0, 0); // force redraw with current scale return TRUE; }
int emf_to_clipboard (char *emfname) { HWND mainw; HENHMETAFILE hemf, hemfclip; HANDLE htest; mainw = GDK_WINDOW_HWND(mdata->main->window); if (mainw == NULL) { errbox("Got NULL HWND"); return 1; } if (!OpenClipboard(mainw)) { errbox(_("Cannot open the clipboard")); return 1; } EmptyClipboard(); hemf = GetEnhMetaFile(emfname); if (hemf == NULL) { errbox("Couldn't get handle to graphic metafile"); return 1; } hemfclip = CopyEnhMetaFile(hemf, NULL); if (hemfclip == NULL) { errbox("Couldn't copy graphic metafile"); return 1; } htest = SetClipboardData(CF_ENHMETAFILE, hemfclip); if (htest == NULL) { errbox("Failed to put data on clipboard"); return 1; } CloseClipboard(); DeleteEnhMetaFile(hemf); return 0; }
BOOL CFemmplotDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; // clear out any old metafile; DeleteEnhMetaFile(hMetaPlot); HasBoundingBox=FALSE; HENHMETAFILE hMetaPlotFile = GetEnhMetaFile(lpszPathName); if (hMetaPlotFile!=NULL){ DWORD len =(DWORD) GetEnhMetaFileBits(hMetaPlotFile,NULL,NULL); unsigned char *buff=(unsigned char *) malloc(len); if(GetEnhMetaFileBits(hMetaPlotFile,len,buff)==0) MsgBox("MetaFile not copied"); hMetaPlot=SetEnhMetaFileBits(len,buff); } else MsgBox("Problem opening specified file"); DeleteEnhMetaFile(hMetaPlotFile); // TODO: Add your specialized creation code here return TRUE; }
static HENHMETAFILE ReadEnhMetaFile(const char *path,long *width, long *height) { #pragma pack( push ) #pragma pack( 2 ) typedef struct { DWORD dwKey; WORD hmf; SMALL_RECT bbox; WORD wInch; DWORD dwReserved; WORD wCheckSum; } APMHEADER, *PAPMHEADER; #pragma pack( pop ) DWORD dwSize; ENHMETAHEADER emfh; HANDLE hFile; HDC hDC; HENHMETAFILE hTemp; LPBYTE pBits; METAFILEPICT mp; HMETAFILE hOld; *width=512; *height=512; hTemp=GetEnhMetaFile(path); #if defined(MAGICKCORE_HAVE__WFOPEN) if (hTemp == (HENHMETAFILE) NULL) { wchar_t *unicode_path; unicode_path=ConvertUTF8ToUTF16(path); if (unicode_path != (wchar_t *) NULL) { hTemp=GetEnhMetaFileW(unicode_path); unicode_path=(wchar_t *) RelinquishMagickMemory(unicode_path); } } #endif if (hTemp != (HENHMETAFILE) NULL) { /* Enhanced metafile. */ GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh); *width=emfh.rclFrame.right-emfh.rclFrame.left; *height=emfh.rclFrame.bottom-emfh.rclFrame.top; return(hTemp); } hOld=GetMetaFile(path); if (hOld != (HMETAFILE) NULL) { /* 16bit windows metafile. */ dwSize=GetMetaFileBitsEx(hOld,0,NULL); if (dwSize == 0) { DeleteMetaFile(hOld); return((HENHMETAFILE) NULL); } pBits=(LPBYTE) AcquireQuantumMemory(dwSize,sizeof(*pBits)); if (pBits == (LPBYTE) NULL) { DeleteMetaFile(hOld); return((HENHMETAFILE) NULL); } if (GetMetaFileBitsEx(hOld,dwSize,pBits) == 0) { pBits=(BYTE *) DestroyString((char *) pBits); DeleteMetaFile(hOld); return((HENHMETAFILE) NULL); } /* Make an enhanced metafile from the windows metafile. */ mp.mm=MM_ANISOTROPIC; mp.xExt=1000; mp.yExt=1000; mp.hMF=NULL; hDC=GetDC(NULL); hTemp=SetWinMetaFileBits(dwSize,pBits,hDC,&mp); ReleaseDC(NULL,hDC); DeleteMetaFile(hOld); pBits=(BYTE *) DestroyString((char *) pBits); GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh); *width=emfh.rclFrame.right-emfh.rclFrame.left; *height=emfh.rclFrame.bottom-emfh.rclFrame.top; return(hTemp); } /* Aldus Placeable metafile. */ hFile=CreateFile(path,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return(NULL); dwSize=GetFileSize(hFile,NULL); pBits=(LPBYTE) AcquireQuantumMemory(dwSize,sizeof(*pBits)); ReadFile(hFile,pBits,dwSize,&dwSize,NULL); CloseHandle(hFile); if (((PAPMHEADER) pBits)->dwKey != 0x9ac6cdd7l) { pBits=(BYTE *) DestroyString((char *) pBits); return((HENHMETAFILE) NULL); } /* Make an enhanced metafile from the placable metafile. */ mp.mm=MM_ANISOTROPIC; mp.xExt=((PAPMHEADER) pBits)->bbox.Right-((PAPMHEADER) pBits)->bbox.Left; *width=mp.xExt; mp.xExt=(mp.xExt*2540l)/(DWORD) (((PAPMHEADER) pBits)->wInch); mp.yExt=((PAPMHEADER)pBits)->bbox.Bottom-((PAPMHEADER) pBits)->bbox.Top; *height=mp.yExt; mp.yExt=(mp.yExt*2540l)/(DWORD) (((PAPMHEADER) pBits)->wInch); mp.hMF=NULL; hDC=GetDC(NULL); hTemp=SetWinMetaFileBits(dwSize,&(pBits[sizeof(APMHEADER)]),hDC,&mp); ReleaseDC(NULL,hDC); pBits=(BYTE *) DestroyString((char *) pBits); return(hTemp); }
BOOL __stdcall pvdFileOpen2(void *pContext, const wchar_t *pFileName, INT64 lFileSize, const BYTE *pBuf, UINT32 lBuf, pvdInfoImage2 *pImageInfo) { _ASSERTE(pImageInfo->cbSize >= sizeof(pvdInfoImage2)); WmfContext *pw = (WmfContext*)CALLOC(sizeof(WmfContext)); if (!pw) { pImageInfo->nErrNumber = PWE_NOT_ENOUGH_MEMORY; return FALSE; } //pw->h = GetEnhMetaFile ( pFileName+4 ); const wchar_t *p = GetExtension(pFileName); if (!p) { pImageInfo->nErrNumber = PWE_NO_EXTENSION; return FALSE; } pImageInfo->nErrNumber = PWE_WIN32_ERROR; // заранее //if (pImageInfo->PreferredSize.cx && pImageInfo->PreferredSize.cy) { // pw->PreferredSize = pImageInfo->PreferredSize; //} else { pw->PreferredSize.cx = 1000; pw->PreferredSize.cy = 1000; //} // First try to read it as an enhanced metafile // If it works, simply return the handle pw->h = SetEnhMetaFileBits(lBuf, pBuf); gnLastWin32Error = GetLastError(); if (!pw->h) { pw->h = GetEnhMetaFile( pFileName ); gnLastWin32Error = GetLastError(); } if (!pw->h) { HMETAFILE hOld; DWORD dwSize; LPBYTE pBits; METAFILEPICT mp; HDC hDC; if( (hOld = GetMetaFile( pFileName )) != NULL ) { // Ok, it is a 16bit windows metafile // How big are the bits? if( (dwSize = GetMetaFileBitsEx( hOld, 0, NULL )) == 0 ) { gnLastWin32Error = GetLastError(); DeleteMetaFile( hOld ); //MessageBox( hWndParent, "Failed to Get MetaFile Bits Size", "Error Reading MetaFile", MB_OK ); } else { // Allocate that much memory if( (pBits = (LPBYTE)CALLOC( dwSize )) == NULL ) { pImageInfo->nErrNumber = PWE_NOT_ENOUGH_MEMORY; gnLastWin32Error = GetLastError(); DeleteMetaFile( hOld ); //MessageBox( hWndParent, "Failed to Allocate Memory for Metafile Bits", "Error Reading MetaFile", MB_OK ); //return NULL; } else { // Get the metafile bits if( GetMetaFileBitsEx( hOld, dwSize, pBits ) == 0 ) { gnLastWin32Error = GetLastError(); FREE( pBits ); DeleteMetaFile( hOld ); //MessageBox( hWndParent, "Failed to Get MetaFile Bits", "Error Reading MetaFile", MB_OK ); //return NULL; } else { // Fill out a METAFILEPICT structure mp.mm = MM_ANISOTROPIC; mp.xExt = 1000; mp.yExt = 1000; mp.hMF = NULL; // Get a reference DC hDC = GetDC( NULL ); // Make an enhanced metafile from the windows metafile pw->h = SetWinMetaFileBits( dwSize, pBits, hDC, &mp ); gnLastWin32Error = GetLastError(); // Clean up ReleaseDC( NULL, hDC ); DeleteMetaFile( hOld ); FREE( pBits ); } } } } } if (!pw->h) { DWORD dwSize = lBuf; LPBYTE pBits = (LPBYTE)pBuf; METAFILEPICT mp; HDC hDC; // Is it a placeable metafile? (check the key) if( ((PAPMHEADER)pBits)->dwKey != 0x9ac6cdd7l ) { // Not a metafile that we know how to recognise - bail out //MessageBox( hWndParent, "Not a Valid Metafile", szFileName, MB_OK ); //return NULL; pImageInfo->nErrNumber = PWE_NOT_VALID_METAFILE; } else { // Ok, its a placeable metafile // Fill out a METAFILEPICT structure mp.mm = MM_ANISOTROPIC; mp.xExt = ((PAPMHEADER)pBits)->bbox.Right - ((PAPMHEADER)pBits)->bbox.Left; mp.xExt = ( mp.xExt * 2540l ) / (DWORD)(((PAPMHEADER)pBits)->wInch); mp.yExt = ((PAPMHEADER)pBits)->bbox.Bottom - ((PAPMHEADER)pBits)->bbox.Top; mp.yExt = ( mp.yExt * 2540l ) / (DWORD)(((PAPMHEADER)pBits)->wInch); mp.hMF = NULL; // Get a reference DC hDC = GetDC( NULL ); // Create an enhanced metafile from the bits pw->h = SetWinMetaFileBits( dwSize, &(pBits[sizeof(APMHEADER)]), hDC, &mp ); gnLastWin32Error = GetLastError(); // Clean up ReleaseDC( NULL, hDC ); //free( pBits ); //if( hTemp == NULL ) // MessageBox( hWndParent, "Failed to Create MetaFile from Bits", "Error Reading MetaFile", MB_OK ); //return hTemp; } } //if (pw->h) { // //pw->hCompDC = CreateCompatibleDC(NULL); // pw->mfp.mm = MM_ISOTROPIC; // pw->mfp.xExt = pw->PreferredSize.cx; // pw->mfp.yExt = pw->PreferredSize.cy; // pw->h = (HENHMETAFILE)SetMetaFileBitsEx (lBuf, pBuf); // gnLastWin32Error = GetLastError(); // pw->h = SetWinMetaFileBits(lBuf, pBuf, NULL, NULL); //pw->hCompDC, &pw->mfp); // gnLastWin32Error = GetLastError(); //} if (!pw->h) { //gnLastWin32Error = GetLastError(); -- уже FREE(pw); return FALSE; } pw->AddRef(); _ASSERTE(pw->nRefCount == 1); ENHMETAHEADER emh = {0}; DWORD PixelsX, PixelsY, MMX, MMY; emh.nSize = sizeof(ENHMETAHEADER); if( GetEnhMetaFileHeader( pw->h, sizeof( ENHMETAHEADER ), &emh ) ) { // Get the characteristics of the output device HDC hDC = GetDC(NULL); PixelsX = GetDeviceCaps( hDC, HORZRES ); PixelsY = GetDeviceCaps( hDC, VERTRES ); MMX = GetDeviceCaps( hDC, HORZSIZE ) * 100; MMY = GetDeviceCaps( hDC, VERTSIZE ) * 100; ReleaseDC(NULL, hDC); // Calculate the rect in which to draw the metafile based on the // intended size and the current output device resolution // Remember that the intended size is given in 0.01mm units, so // convert those to device units on the target device //pw->PreferredSize.cx = (int)((float)(emh.rclFrame.right - emh.rclFrame.left) * PixelsX / (MMX)); //pw->PreferredSize.cy = (int)((float)(emh.rclFrame.bottom - emh.rclFrame.top) * PixelsY / (MMY)); pw->PreferredSize.cx = ip.MulDivI32((emh.rclFrame.right - emh.rclFrame.left), PixelsX, MMX); pw->PreferredSize.cy = ip.MulDivI32((emh.rclFrame.bottom - emh.rclFrame.top), PixelsY, MMY); _ASSERTE(pw->PreferredSize.cx>0 && pw->PreferredSize.cy>0); if (pw->PreferredSize.cx < 0) pw->PreferredSize.cx = -pw->PreferredSize.cx; if (pw->PreferredSize.cy < 0) pw->PreferredSize.cy = -pw->PreferredSize.cy; } pImageInfo->pImageContext = pw; pImageInfo->nPages = 1; pImageInfo->Flags = 0; pImageInfo->pFormatName = L"WMF"; pImageInfo->pCompression = NULL; pImageInfo->pComments = NULL; return TRUE; }
static HENHMETAFILE ReadEnhMetaFile(const char *szFileName,long *width, long *height) { #pragma pack( push, 2 ) typedef struct { DWORD dwKey; WORD hmf; SMALL_RECT bbox; WORD wInch; DWORD dwReserved; WORD wCheckSum; } APMHEADER, *PAPMHEADER; #pragma pack( pop ) DWORD dwSize; ENHMETAHEADER emfh; HANDLE hFile; HDC hDC; HENHMETAFILE hTemp; LPBYTE pBits; METAFILEPICT mp; HMETAFILE hOld; *width=512; *height=512; hTemp=GetEnhMetaFile(szFileName); if (hTemp != (HENHMETAFILE) NULL) { /* Enhanced metafile. */ GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh); *width=emfh.rclFrame.right-emfh.rclFrame.left; *height=emfh.rclFrame.bottom-emfh.rclFrame.top; return(hTemp); } hOld=GetMetaFile(szFileName); if (hOld != (HMETAFILE) NULL) { /* 16bit windows metafile. */ dwSize=GetMetaFileBitsEx(hOld,0,NULL); if (dwSize == 0) { DeleteMetaFile(hOld); return((HENHMETAFILE) NULL); } pBits=MagickAllocateMemory(LPBYTE,dwSize); if (pBits == (LPBYTE) NULL) { DeleteMetaFile(hOld); return((HENHMETAFILE) NULL); } if (GetMetaFileBitsEx(hOld,dwSize,pBits) == 0) { MagickFreeMemory(pBits); DeleteMetaFile(hOld); return((HENHMETAFILE) NULL); } /* Make an enhanced metafile from the windows metafile. */ mp.mm=MM_ANISOTROPIC; mp.xExt=1000; mp.yExt=1000; mp.hMF=NULL; hDC=GetDC(NULL); hTemp=SetWinMetaFileBits(dwSize,pBits,hDC,&mp); ReleaseDC(NULL,hDC); DeleteMetaFile(hOld); MagickFreeMemory(pBits); GetEnhMetaFileHeader(hTemp,sizeof(ENHMETAHEADER),&emfh); *width=emfh.rclFrame.right-emfh.rclFrame.left; *height=emfh.rclFrame.bottom-emfh.rclFrame.top; return(hTemp); } /* Aldus Placeable metafile. */ hFile=CreateFile(szFileName,GENERIC_READ,0,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL); if (hFile == INVALID_HANDLE_VALUE) return(NULL); dwSize=GetFileSize(hFile,NULL); pBits=MagickAllocateMemory(LPBYTE,dwSize); ReadFile(hFile,pBits,dwSize,&dwSize,NULL); CloseHandle(hFile); if (((PAPMHEADER) pBits)->dwKey != 0x9ac6cdd7l) { MagickFreeMemory(pBits); return((HENHMETAFILE) NULL); } /* Make an enhanced metafile from the placable metafile. */ mp.mm=MM_ANISOTROPIC; mp.xExt=((PAPMHEADER) pBits)->bbox.Right-((PAPMHEADER) pBits)->bbox.Left; *width=mp.xExt; mp.xExt=(mp.xExt*2540l)/(DWORD) (((PAPMHEADER) pBits)->wInch); mp.yExt=((PAPMHEADER)pBits)->bbox.Bottom-((PAPMHEADER) pBits)->bbox.Top; *height=mp.yExt; mp.yExt=(mp.yExt*2540l)/(DWORD) (((PAPMHEADER) pBits)->wInch); mp.hMF=NULL; hDC=GetDC(NULL); hTemp=SetWinMetaFileBits(dwSize,&(pBits[sizeof(APMHEADER)]),hDC,&mp); ReleaseDC(NULL,hDC); MagickFreeMemory(pBits); return(hTemp); }