Question

I'm interested in how meta files are actually played in GDI. First of all, when meta file is created, does it actually contain function calls and parameter values, so the primitives can be drawn? I know that it is used for vector drawings, so this makes sense... Second, how is meta file played? Does the actual meta get drawn, and then its somehow BitBlitted to DC, or is drawn to the DC immediately? If I, lets say, use FloodFill to fill something in the metafile, can problems derive if the object in the meta intersects with the object drawn in the DC? Per example if the object in the DC is filled with color that is used in FloodField. Thank you.

Was it helpful?

Solution

A metafile is pretty simple, just a set of records that match the GDI functions you called to generate it. Each record has a number that corresponds to the specific GDI function, followed by the argument values you passed to that function. The declaration of the record from the winapi:

typedef struct tagENHMETARECORD {
  DWORD iType;
  DWORD nSize;
  DWORD dParm[1];
} ENHMETARECORD, *PENHMETARECORD;

iType is the function number, nSize is the size of the record, dParm stores the function argument values.

So when you call PlayMetafile(), Windows simply makes the exact same GDI function calls again. The HDC argument you pass determines where the drawing output will go. Easy peasy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top