GdipCreateImageAttributesfunction
Creates an **ImageAttributes** object.
Syntax
FUNCTION GdipCreateImageAttributes (BYVAL imageattr AS GpImageAttributes PTR PTR) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
imageattr | [out] Pointer to a variable that receives a pointer to the new created ImageAttributes object. |
Description
Creates an ImageAttributes object.
Example
' ======================================================================================== ' The following example creates an Image object loading an image from file, creates an ' ImageAttributes object, sets the wrap mode to WrapModeTile and draws the specified ' source rectangle to the destination rectangle, which is four times as large as the ' image itself. ' ======================================================================================== SUB Example_CreateImageAttributes (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_BLUE, 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)
' // Cleanup IF imgAttr THEN GdipDisposeImageAttributes(imgAttr) IF image THEN GdipDisposeImage(image) IF graphics THEN GdipDeleteGraphics(graphics)
END SUB ' ========================================================================================
Reference
- Defined in AfxNova/AfxGdiPlus.bi:2127
- Documented in Graphics/GdiPlus Flat Api/GdiPlusImageAttributes.md
- Topic: ImageAttributes Functions