GdipSetImageAttributesWrapModefunction
Sets the wrap mode of the **ImageAttributes** object.
Syntax
FUNCTION GdipSetImageAttributesWrapMode (BYVAL imageattr AS GpImageAttributes PTR, BYVAL wrap AS WrapMode, BYVAL argb AS ARGB, BYVAL clamp AS BOOL) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
imageattr | [in] Pointer to the ImageAttributes object. | |
wrap | [in] Element of the WrapMode enumeration that specifies how repeated copies of an image are used to tile an area. | |
argb | [in] ARGB color that specifies the color of pixels outside of a rendered image. This color is visible if the wrap parameter is set to WrapModeClamp and the source rectangle passed to GdipDrawImage is larger than the image itself. |
Description
Sets the wrap mode of the ImageAttributes object.
Example
' ======================================================================================== ' The following example calls DrawImage twice. In both calls, the specified source rectangle ' is four times as large as the image itself. In the first call to DrawImage, the ' ImageAttributes object has its wrap mode set to WrapModeClamp, so the portion of the ' source rectangle outside the image is filled with red according to the second argument ' passed to ImageAttributes.SetWrapMode. In the second call to DrawImage, the ImageAttributes ' object has its wrap mode set to WrapModeTile, so the portion of the source rectangle ' outside the image is filled with repeated copies of the image. ' ======================================================================================== SUB Example_SetWrapMode (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 WrapModeClamp (no tile) GdipSetImageAttributesWrapMode(imgAttr, WrapModeClamp, ARGB_RED, FALSE)
' // 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)
' // Change the wrap mode to WrapModeTile GdipSetImageAttributesWrapMode(imgAttr, WrapModeTile, ARGB_RED, FALSE)
' // Draw the image with the new attribute hStatus = GdipDrawImageRectRect(graphics, image, _
200, 10, nWidth, nHeight, _ ' dest rect
0, 0, 2 * nWidth, 2 * nHeight, _ ' source dest
UnitPixel, imgAttr, NULL, NULL)
' // Cleanup IF imgAttr THEN GdipDisposeImageAttributes(imgAttr) IF image THEN GdipDisposeImage(image) IF graphics THEN GdipDeleteGraphics(graphics)
END SUB ' ========================================================================================
Reference
- Defined in AfxNova/AfxGdiPlus.bi:2148
- Documented in Graphics/GdiPlus Flat Api/GdiPlusImageAttributes.md
- Topic: ImageAttributes Functions