Help Center

GdipCloneImageAttributesfunction

Makes a copy of an **ImageAttributes** object.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipCloneImageAttributes (BYVAL imageattr AS CONST GpImageAttributes PTR, BYVAL cloneImageattr AS GpImageAttributes PTR PTR) AS GpStatus

Parameters

NameDescription
imageattr[in] Pointer to the ImageAttributes object.
cloneImageattrout] Pointer to a variable that receives a pointer to the new ImageAttributes object.

Description

Makes a copy of an ImageAttributes object.

Example

' ======================================================================================== ' This example loads an image, creates an ImageAttributes object with a wrap mode, ' clones it using GdipCloneImageAttributes, and draws the same image twice using ' the original and cloned attributes. ' ======================================================================================== SUB Example_CloneImageAttributes (BYVAL hdc AS HDC)

DIM hStatus AS LONG

' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)

' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)

' // Load an image from file DIM image AS GpImage PTR hStatus = GdipLoadImageFromFile("climber.jpg", @image) ' // Set the resolution of this image object to the user's DPI settings hStatus = GdipBitmapSetResolution(image, dpiX, dpiY)

' // Get the width and height of the image DIM AS LONG nWidth, nHeight hStatus = GdipGetImageWidth(image, @nWidth) hStatus = GdipGetImageHeight(image, @nHeight)

' // Create an ImageAttributes object DIM imgAttr AS GpImageAttributes PTR hStatus = GdipCreateImageAttributes(@imgAttr)

' // Set the wrap mode to WrapModeTile GdipSetImageAttributesWrapMode(imgAttr, WrapModeTile, ARGB_RED, FALSE)

' // Clone the ImageAttributes DIM cloneAttr AS GpImageAttributes PTR hStatus = GdipCloneImageAttributes(imgAttr, @cloneAttr)

' // Draw the image hStatus = GdipDrawImageRectRect(graphics, image, _

10, 10, nWidth, nHeight, _         ' dest rect
         0, 0, 2 * nWidth, 2 * nHeight, _   ' source dest
         UnitPixel, imgAttr, NULL, NULL)

' // Draw the image using cloned attributes hStatus = GdipDrawImageRectRect(graphics, image, _

200, 10, nWidth, nHeight, _        ' dest rect
         0, 0, 2 * nWidth, 2 * nHeight, _   ' source dest
         UnitPixel, imgAttr, NULL, NULL)

' // Cleanup IF cloneAttr THEN GdipDisposeImageAttributes(cloneAttr) IF imgAttr THEN GdipDisposeImageAttributes(imgAttr) IF image THEN GdipDisposeImage(image) IF graphics THEN GdipDeleteGraphics(graphics)

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

Reference

  • Defined in AfxNova/AfxGdiPlus.bi:2128
  • Documented in Graphics/GdiPlus Flat Api/GdiPlusImageAttributes.md
  • Topic: ImageAttributes Functions