Help Center

CGpGraphicsPathIterator.EnumerateMetafileDestPointmethod

GraphicsmethodCGpGraphics.incdoc-orphan
No implementation located. This member is documented, but the source scan found no matching declaration. It is likely declared in a header this scan does not resolve, or provided by a macro.

Syntax

FUNCTION EnumerateMetafileDestPoint (BYVAL pMetafile AS CGpMetafile PTR, BYVAL destPoint AS GpPointF PTR, BYVAL pCallback AS EnumerateMetafileProc, BYVAL pCallbackData AS ANU PTR = NULL, BYVAL pImageAttributes AS CGpImageAttributes PTR = NULL) AS GpStatus
Also documented as EnumerateMetafile — one description covers them all.

Parameters

NameDescription
pMetafilePointer to a metafile to be enumerated.
destPointReference to a point that specifies the upper-left corner of the displayed metafile.
pCallbackOptional. Pointer to an application-defined callback function. The prototype for the callback function is given in Gdiplustypes.inc.
pCallbackDataOptional. Pointer to a block of data that is passed to the callback function. The default value is NULL.
pImageAttributesOptional. Pointer to an ImageAttributes object that specifies color adjustments for the displayed metafile. The default value is NULLL.
destPointsPointer to an array of destination points. This is an array of three points that defines the destination parallelogram for the displayed metafile.
nCountInteger that specifies the number of points in the destPoints array.
destRectReference to a GpRectF object that specifies the rectangle in which the metafile is displayed.
srcRectReference to a rectangle that specifies the portion of the metafile that is displayed.
srcUnitElement of the GpUnit enumeration that specifies the unit of measure for the source rectangle.

Return value

If the function succeeds, it returns StatusOk, which is an element of the GpStatus enumeration.

If the function fails, it returns one of the other elements of the GpStatus enumeration.

Description

Calls an application-defined callback function for each record in a specified metafile. You can use this method to display a metafile by calling PlayRecord in the callback function.

Note: Not yet implemented.

Examples

' ======================================================================================== ' Enumerate and Replay Metafile Records ' Calls your callback for each record in the metafile. ' You can inspect record types, sizes, and optionally replay or skip them. ' The destination point defines where the metafile is rendered. ' ========================================================================================

' ======================================================================================== ' Callback function prototype ' ======================================================================================== FUNCTION MetafileCallback (BYVAL recordType AS EmfPlusRecordType, BYVAL flags AS UINT, _

BYVAL dataSize AS UINT, BYVAL byteData AS CONST UBYTE PTR, _
                       BYVAL callbackData AS ANY PTR) AS BOOL

' You can inspect or modify each record here OutputDebugStringW "Record type: " & WSTR(recordType) & " Size: " & WSTR(dataSize) RETURN TRUE ' Continue enumeration END FUNCTION ' ========================================================================================

' ======================================================================================== SUB Example_EnumerateMetafileDestPoint (BYVAL hdc AS HDC)

' // Load metafile DIM metafile AS CGpMetafile = CGpMetafile("SampleMetafile.emf") IF metafile.GetLastStatus <> StatusOk THEN

AfxMsg "Failed to load metafile."
  EXIT SUB

END IF

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale trandform graphics.ScaleTransformForDpi

' // Destination point DIM destPoint AS GpPointF = (50.0, 50.0)

' // Enumerate and replay records DIM status AS GpStatus = graphics.EnumerateMetafileDestPoint(@metafile, @destPoint, @MetafileCallback, NULL, NULL) IF status <> StatusOk THEN

AfxMsg "Enumeration failed: " & WSTR(status)

END IF

END SUB ' ========================================================================================

' ======================================================================================== ' Enumerate and Replay Metafile at Multiple Points. ' Efficiently renders the same metafile content at multiple locations. ' Lets you inspect or modify records during playback. ' Ideal for stamping, watermarking, or tiled rendering. ' ========================================================================================

' ======================================================================================== ' Callback function prototype ' ======================================================================================== FUNCTION MetafileCallback (BYVAL recordType AS EmfPlusRecordType, BYVAL flags AS UINT, _

BYVAL dataSize AS UINT, BYVAL byteData AS CONST UBYTE PTR, _
                       BYVAL callbackData AS ANY PTR) AS BOOL

' You can inspect or modify each record here OutputDebugStringW "Record type: " & WSTR(recordType) & " Size: " & WSTR(dataSize) RETURN TRUE ' Continue enumeration END FUNCTION ' ========================================================================================

' ======================================================================================== SUB Example_EnumerateMetafileDestPoints (BYVAL hdc AS HDC)

' // Load metafile DIM metafile AS CGpMetafile = CGpMetafile("SampleMetafile.emf") IF metafile.GetLastStatus <> StatusOk THEN

AfxMsg "Failed to load metafile."
  EXIT SUB

END IF

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale trandform graphics.ScaleTransformForDpi

' // Define multiple destination points DIM points(2) AS GpPointF points(0) = TYPE<GpPointF>(50.0, 50.0) ' Top-left points(1) = TYPE<GpPointF>(250.0, 50.0) ' Top-right points(2) = TYPE<GpPointF>(50.0, 200.0) ' Bottom-left

' // Enumerate and replay records at each point DIM status AS GpStatus = graphics.EnumerateMetafileDestPoints(@metafile, @points(0), 3, @MetafileCallback, NULL, NULL) IF status <> StatusOk THEN

AfxMsg "Enumeration failed: " & WSTR(status)

END IF

END SUB ' ========================================================================================

' ======================================================================================== ' Enumerate and Replay Metafile Records ' Calls your callback for each record in the metafile. ' Scales and positions metafile content within a defined rectangle. ' Lets you inspect or selectively replay records. ' Ideal for layout-sensitive rendering (e.g. thumbnails, previews, print areas). ' ========================================================================================

' ======================================================================================== ' Callback function prototype ' ======================================================================================== FUNCTION MetafileCallback (BYVAL recordType AS EmfPlusRecordType, BYVAL flags AS UINT, _

BYVAL dataSize AS UINT, BYVAL byteData AS CONST UBYTE PTR, _
                       BYVAL callbackData AS ANY PTR) AS BOOL

' You can inspect or modify each record here OutputDebugStringW "Record type: " & WSTR(recordType) & " Size: " & WSTR(dataSize) RETURN TRUE ' Continue enumeration END FUNCTION ' ========================================================================================

' ======================================================================================== SUB Example_EnumerateMetafileDestRect (BYVAL hdc AS HDC)

' // Load metafile DIM metafile AS CGpMetafile = CGpMetafile("SampleMetafile.emf") IF metafile.GetLastStatus <> StatusOk THEN

AfxMsg "Failed to load metafile."
  EXIT SUB

END IF

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale trandform graphics.ScaleTransformForDpi

' // Define destination rectangle DIM destRect AS GpRectF = (50.0, 50.0, 300.0, 200.0)

' // Enumerate and replay records DIM status AS GpStatus = graphics.EnumerateMetafileDestRect(@metafile, @destRect, @MetafileCallback, NULL, NULL) IF status <> StatusOk THEN

AfxMsg "Enumeration failed: " & WSTR(status)

END IF

END SUB ' ========================================================================================

' ======================================================================================== ' Enumerate and Replay Cropped Metafile at a Point. ' Allows you: ' Crop the metafile using srcRect ' Render it at a specific destPoint ' Control units via srcUnit (e.g., UnitPixel, UnitMillimeter) ' Intercept records via a callback ' Apply image attributes (e.g., color adjustments, gamma correction) ' ========================================================================================

' ======================================================================================== ' Callback function prototype ' ======================================================================================== FUNCTION MetafileCallback (BYVAL recordType AS EmfPlusRecordType, BYVAL flags AS UINT, _

BYVAL dataSize AS UINT, BYVAL byteData AS CONST UBYTE PTR, _
                       BYVAL callbackData AS ANY PTR) AS BOOL

' You can inspect or modify each record here OutputDebugStringW "Record type: " & WSTR(recordType) & " Size: " & WSTR(dataSize) RETURN TRUE ' Continue enumeration END FUNCTION ' ========================================================================================

' ======================================================================================== SUB Example_EnumerateMetafileSrcRectDestPoint (BYVAL hdc AS HDC)

' // Load metafile DIM metafile AS CGpMetafile = CGpMetafile("SampleMetafile.emf") IF metafile.GetLastStatus <> StatusOk THEN

AfxMsg "Failed to load metafile."
  EXIT SUB

END IF

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale trandform graphics.ScaleTransformForDpi

' // Define source rectangle (crop area) DIM srcRect AS GpRectF = (50.0, 50.0, 300.0, 200.0)

' // Define destination point DIM destPoint AS GpPointF = (300.0, 100.0)

' // Enumerate and replay records DIM status AS GpStatus = graphics.EnumerateMetafileSrcRectDestPoint(@metafile, @destPoint, @srcRect, _

UnitPixel, @MetafileCallback, NULL, NULL)

IF status <> StatusOk THEN

AfxMsg "Enumeration failed: " & WSTR(status)

END IF

END SUB ' ========================================================================================

' ======================================================================================== ' Cropped and Transformed Metafile Playback. ' Combines cropping and transforming in one step. ' Destination points define a parallelogram, allowing skew, rotation, and scaling. ' Ideal for advanced rendering scenarios like perspective effects or layout fitting. ' ========================================================================================

' ======================================================================================== ' Callback function prototype ' ======================================================================================== FUNCTION MetafileCallback (BYVAL recordType AS EmfPlusRecordType, BYVAL flags AS UINT, _

BYVAL dataSize AS UINT, BYVAL byteData AS CONST UBYTE PTR, _
                       BYVAL callbackData AS ANY PTR) AS BOOL

' You can inspect or modify each record here OutputDebugStringW "Record type: " & WSTR(recordType) & " Size: " & WSTR(dataSize) RETURN TRUE ' Continue enumeration END FUNCTION ' ========================================================================================

' ======================================================================================== SUB Example_EnumerateMetafileSrcRectDestPoints (BYVAL hdc AS HDC)

' // Load metafile DIM metafile AS CGpMetafile = CGpMetafile("SampleMetafile.emf") IF metafile.GetLastStatus <> StatusOk THEN

AfxMsg "Failed to load metafile."
  EXIT SUB

END IF

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale trandform graphics.ScaleTransformForDpi

' // Define source rectangle (crop area) DIM srcRect AS GpRectF = (50.0, 50.0, 200.0, 100.0)

' // Define destination parallelogram (3 points) DIM destPoints(2) AS GpPointF destPoints(0) = TYPE<GpPointF>(300.0, 100.0) ' Top-left destPoints(1) = TYPE<GpPointF>(500.0, 120.0) ' Top-right (skewed) destPoints(2) = TYPE<GpPointF>(280.0, 250.0) ' Bottom-left

' // Enumerate and replay records DIM status AS GpStatus = graphics.EnumerateMetafileSrcRectDestPoints(@metafile, @destPoints(0), 3, _

@srcRect, UnitPixel, @MetafileCallback, NULL, NULL)

IF status <> StatusOk THEN

AfxMsg "Enumeration failed: " & WSTR(status)

END IF

END SUB ' ========================================================================================

' ======================================================================================== ' Cropped Metafile Playback in a Rectangle ' Cropping: Only the portion inside srcRect is processed. ' Scaling and positioning: The content is rendered inside destRect, stretched or shrunk as needed. ' Inspection: The callback lets you analyze or selectively replay records. ' ========================================================================================

' ======================================================================================== ' Callback function prototype ' ======================================================================================== FUNCTION MetafileCallback (BYVAL recordType AS EmfPlusRecordType, BYVAL flags AS UINT, _

BYVAL dataSize AS UINT, BYVAL byteData AS CONST UBYTE PTR, _
                       BYVAL callbackData AS ANY PTR) AS BOOL

' You can inspect or modify each record here OutputDebugStringW "Record type: " & WSTR(recordType) & " Size: " & WSTR(dataSize) RETURN TRUE ' Continue enumeration END FUNCTION ' ========================================================================================

' ======================================================================================== SUB Example_EnumerateMetafileSrcRectDestRect (BYVAL hdc AS HDC)

' // Load metafile DIM metafile AS CGpMetafile = CGpMetafile("SampleMetafile.emf") IF metafile.GetLastStatus <> StatusOk THEN

AfxMsg "Failed to load metafile."
  EXIT SUB

END IF

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale trandform graphics.ScaleTransformForDpi

' // Define source rectangle (crop area) DIM srcRect AS GpRectF = (50.0, 50.0, 200.0, 100.0)

' // Define destination rectangle (where to draw) DIM destRect AS GpRectF = (300.0, 100.0, 400.0, 200.0)

' // Enumerate and replay records DIM status AS GpStatus = graphics.EnumerateMetafileSrcRectDestRect(@metafile, @destRect, @srcRect, _

UnitPixel, @MetafileCallback, NULL, NULL)

IF status <> StatusOk THEN

AfxMsg "Enumeration failed: " & WSTR(status)

END IF

END SUB ' ========================================================================================

Reference

  • Include file CGpGraphics.inc
  • Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
  • Topic: CGpGraphics Class