bool wxMetafileDataObject::SetData(size_t WXUNUSED(len), const void *buf) { const METAFILEPICT *mfpict = (const METAFILEPICT *)buf; wxMetafile mf; mf.SetWindowsMappingMode(mfpict->mm); LONG w = mfpict->xExt, h = mfpict->yExt; if ( mfpict->mm == MM_ANISOTROPIC ) { // in this case xExt and yExt contain suggested size in HIMETRIC units // (0.01 mm) - transform this to something more reasonable (pixels) HIMETRICToPixel(&w, &h); } mf.SetWidth(w); mf.SetHeight(h); mf.SetHMETAFILE((WXHANDLE)mfpict->hMF); wxCHECK_MSG( mfpict->hMF, false, wxT("pasting invalid metafile") ); SetMetafile(mf); return true; }
wxSize wxEnhMetaFile::GetSize() const { wxSize size = wxDefaultSize; if ( Ok() ) { ENHMETAHEADER hdr; if ( !::GetEnhMetaFileHeader(GetEMF(), sizeof(hdr), &hdr) ) { wxLogLastError(_T("GetEnhMetaFileHeader")); } else { // the width and height are in HIMETRIC (0.01mm) units, transform // them to pixels LONG w = hdr.rclFrame.right, h = hdr.rclFrame.bottom; HIMETRICToPixel(&w, &h); size.x = w; size.y = h; } } return size; }
void HIMETRICToPixel(LONG *x, LONG *y) { HIMETRICToPixel(x, y, ScreenHDC()); }