d890d4bcaef850448d5762e58c13bd4759d3604d
11 return NtGdiCloseEnhMetaFile(hdc
);
24 return NtGdiCopyMetaFile (hmfSrc
, lpszFile
);
42 Status
= HEAP_strdupA2W ( &lpszFileW
, lpszFile
);
43 if (!NT_SUCCESS (Status
))
44 SetLastError (RtlNtStatusToDosError(Status
));
47 rc
= NtGdiCopyMetaFile ( hmfSrc
, lpszFileW
);
49 HEAP_free ( lpszFileW
);
65 return NtGdiCreateMetaFile ( lpszFile
);
82 Status
= HEAP_strdupA2W ( &lpszFileW
, lpszFile
);
83 if (!NT_SUCCESS (Status
))
84 SetLastError (RtlNtStatusToDosError(Status
));
87 rc
= NtGdiCreateMetaFile ( lpszFileW
);
89 HEAP_free ( lpszFileW
);
104 return NtGdiGetMetaFile ( lpszMetaFile
);
118 LPWSTR lpszMetaFileW
;
121 Status
= HEAP_strdupA2W ( &lpszMetaFileW
, lpszMetaFile
);
122 if (!NT_SUCCESS (Status
))
123 SetLastError (RtlNtStatusToDosError(Status
));
126 rc
= NtGdiGetMetaFile ( lpszMetaFileW
);
128 HEAP_free ( lpszMetaFileW
);
136 HDC WINAPI
CreateEnhMetaFileW(
137 HDC hDC
, /* [in] optional reference DC */
138 LPCWSTR filename
, /* [in] optional filename for disk metafiles */
139 const RECT
* rect
, /* [in] optional bounding rectangle */
140 LPCWSTR description
/* [in] optional description */
148 DWORD size
= 0, length
= 0;
150 mDC
= NtGdiCreateMetafileDC( hDC
); // Basically changes the handle from 1xxxx to 46xxxx.
151 // If hDC == NULL, works just like createdc in win32k.
153 if ( !GdiGetHandleUserData((HGDIOBJ
) mDC
, (PVOID
) &Dc_Attr
))
155 SetLastError (ERROR_INVALID_PARAMETER
);
156 return NULL
; // need to delete the handle?
159 pLDC
= LocalAlloc(LMEM_ZEROINIT
, sizeof(LDC
));
161 Dc_Attr
->pvLDC
= pLDC
;
163 pLDC
->iType
= LDC_EMFDC
167 { /* App name\0Title\0\0 */
168 length
= lstrlenW(description
);
169 length
+= lstrlenW(description
+ length
+ 1);
174 size
= sizeof(ENHMETAFILE
) + (length
+ 3) / 4 * 4;
176 //Allocate ENHMETAFILE structure
177 EmfDC
= LocalAlloc(LMEM_ZEROINIT
, sizeof(ENHMETAFILE
));
178 pLDC
->pvEmfDC
= EmfDC
;
180 EmfDC
->handles_size
= HANDLE_LIST_INC
;
181 EmfDC
->cur_handles
= 1;
183 EmfDC
->horzres
= GetDeviceCaps(mDC
, HORZRES
);
184 EmfDC
->vertres
= GetDeviceCaps(mDC
, VERTRES
);
185 EmfDC
->logpixelsx
= GetDeviceCaps(mDC
, LOGPIXELSX
);
186 EmfDC
->logpixelsy
= GetDeviceCaps(mDC
, LOGPIXELSY
);
187 EmfDC
->horzsize
= GetDeviceCaps(mDC
, HORZSIZE
);
188 EmfDC
->vertsize
= GetDeviceCaps(mDC
, VERTSIZE
);
189 EmfDC
->bitspixel
= GetDeviceCaps(mDC
, BITSPIXEL
);
190 EmfDC
->textcaps
= GetDeviceCaps(mDC
, TEXTCAPS
);
191 EmfDC
->rastercaps
= GetDeviceCaps(mDC
, RASTERCAPS
);
192 EmfDC
->technology
= GetDeviceCaps(mDC
, TECHNOLOGY
);
193 EmfDC
->planes
= GetDeviceCaps(mDC
, PLANES
);
195 EmfDC
->emf
= LocalAlloc(LMEM_ZEROINIT
, size
);
197 EmfDC
->emf
->iType
= EMR_HEADER
;
198 EmfDC
->emf
->nSize
= size
;
200 EmfDC
->emf
->rclBounds
.left
= EmfDC
->emf
->rclBounds
.top
= 0;
201 EmfDC
->emf
->rclBounds
.right
= EmfDC
->emf
->rclBounds
.bottom
= -1;
205 EmfDC
->emf
->rclFrame
.left
= rect
->left
;
206 EmfDC
->emf
->rclFrame
.top
= rect
->top
;
207 EmfDC
->emf
->rclFrame
.right
= rect
->right
;
208 EmfDC
->emf
->rclFrame
.bottom
= rect
->bottom
;
211 { /* Set this to {0,0 - -1,-1} and update it at the end */
212 EmfDC
->emf
->rclFrame
.left
= EmfDC
->emf
->rclFrame
.top
= 0;
213 EmfDC
->emf
->rclFrame
.right
= EmfDC
->emf
->rclFrame
.bottom
= -1;
216 EmfDC
->emf
->dSignature
= ENHMETA_SIGNATURE
;
217 EmfDC
->emf
->nVersion
= 0x10000;
218 EmfDC
->emf
->nBytes
= pLDC
->pvEmfDC
->nSize
;
219 EmfDC
->emf
->nRecords
= 1;
220 EmfDC
->emf
->nHandles
= 1;
222 EmfDC
->emf
->sReserved
= 0; /* According to docs, this is reserved and must be 0 */
223 EmfDC
->emf
->nDescription
= length
/ 2;
225 EmfDC
->emf
->offDescription
= length
? sizeof(ENHMETAHEADER
) : 0;
227 EmfDC
->emf
->nPalEntries
= 0; /* I guess this should start at 0 */
230 EmfDC
->emf
->szlDevice
.cx
= EmfDC
->horzres
;
231 EmfDC
->emf
->szlDevice
.cy
= EmfDC
->vertres
;
233 /* Size in millimeters */
234 EmfDC
->emf
->szlMillimeters
.cx
= EmfDC
->horzsize
;
235 EmfDC
->emf
->szlMillimeters
.cy
= EmfDC
->vertsize
;
237 /* Size in micrometers */
238 EmfDC
->emf
->szlMicrometers
.cx
= EmfDC
->horzsize
* 1000;
239 EmfDC
->emf
->szlMicrometers
.cy
= EmfDC
->vertsize
* 1000;
241 RtlCopyMemory((char *)EmfDC
->emf
+ sizeof(ENHMETAHEADER
), description
, length
);
243 if (filename
) /* disk based metafile */
245 if ((hFile
= CreateFileW(filename
, GENERIC_WRITE
| GENERIC_READ
, 0,
246 NULL
, CREATE_ALWAYS
, 0, 0)) == INVALID_HANDLE_VALUE
)
248 EMFDRV_DeleteDC( EmfDC
);
251 if (!WriteFile( hFile
, (LPSTR
)EmfDC
->emf
, size
, NULL
, NULL
))
253 EMFDRV_DeleteDC( EmfDC
);
272 HENHMETAFILE hemfSrc
,
276 return NtGdiCopyEnhMetaFile ( hemfSrc
, lpszFile
);
286 HENHMETAFILE hemfSrc
,
294 Status
= HEAP_strdupA2W ( &lpszFileW
, lpszFile
);
295 if (!NT_SUCCESS (Status
))
296 SetLastError (RtlNtStatusToDosError(Status
));
299 rc
= NtGdiCopyEnhMetaFile ( hemfSrc
, lpszFileW
);
301 HEAP_free ( lpszFileW
);
316 LPCWSTR lpDescription
319 return NtGdiCreateEnhMetaFile ( hdcRef
, lpFileName
, (CONST LPRECT
)lpRect
, lpDescription
);
336 LPWSTR lpFileNameW
, lpDescriptionW
;
340 if (lpFileName
!= NULL
)
342 Status
= HEAP_strdupA2W ( &lpFileNameW
, lpFileName
);
343 if (!NT_SUCCESS (Status
))
344 SetLastError (RtlNtStatusToDosError(Status
));
349 lpDescriptionW
= NULL
;
350 if (lpDescription
!= NULL
)
352 Status
= HEAP_strdupA2W ( &lpDescriptionW
, lpDescription
);
353 if (!NT_SUCCESS (Status
))
354 SetLastError (RtlNtStatusToDosError(Status
));
359 rc
= NtGdiCreateEnhMetaFile (hdcRef
, lpFileNameW
, (CONST LPRECT
)lpRect
, lpDescriptionW
);
361 if (lpDescriptionW
!= NULL
)
362 HEAP_free ( lpDescriptionW
);
364 if (lpFileNameW
!= NULL
)
365 HEAP_free ( lpFileNameW
);
379 return NtGdiGetEnhMetaFile ( lpszMetaFile
);
393 LPWSTR lpszMetaFileW
;
396 Status
= HEAP_strdupA2W ( &lpszMetaFileW
, lpszMetaFile
);
397 if (!NT_SUCCESS (Status
))
398 SetLastError (RtlNtStatusToDosError(Status
));
401 rc
= NtGdiGetEnhMetaFile ( lpszMetaFileW
);
403 HEAP_free ( lpszMetaFileW
);
415 GetEnhMetaFileDescriptionW(
418 LPWSTR lpszDescription
421 return NtGdiGetEnhMetaFileDescription ( hemf
, cchBuffer
, lpszDescription
);
430 GetEnhMetaFileDescriptionA(
433 LPSTR lpszDescription
437 LPWSTR lpszDescriptionW
;
440 if ( lpszDescription
&& cchBuffer
)
442 lpszDescriptionW
= (LPWSTR
)HEAP_alloc ( cchBuffer
*sizeof(WCHAR
) );
443 if ( !lpszDescriptionW
)
445 SetLastError (RtlNtStatusToDosError(STATUS_NO_MEMORY
));
450 lpszDescriptionW
= NULL
;
452 rc
= NtGdiGetEnhMetaFileDescription ( hemf
, cchBuffer
, lpszDescriptionW
);
454 if ( lpszDescription
&& cchBuffer
)
456 Status
= RtlUnicodeToMultiByteN ( lpszDescription
,
461 HEAP_free ( lpszDescriptionW
);
462 if ( !NT_SUCCESS(Status
) )
464 SetLastError (RtlNtStatusToDosError(Status
));