CGpGraphics.SetPixelOffsetModemethod
Sets the pixel offset mode of this **Graphics** object.
Syntax
FUNCTION SetPixelOffsetMode (BYVAL nMode AS PixelOffsetMode) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
nMode | Element of the PixelOffsetMode enumeration that specifies the pixel offset mode. |
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
Sets the pixel offset mode of this Graphics object.
Remarks
Consider the pixel in the upper-left corner of an image with address (0, 0). With PixelOffsetModeNone, the pixel covers the area between 0.5 and 0.5 in both the x and y directions; that is, the pixel center is at (0, 0). With PixelOffsetModeHalf, the pixel covers the area between 0 and 1 in both the x and y directions; that is, the pixel center is at (0.5, 0.5).
Example
' ======================================================================================== ' This example creates a Graphics object from a device context, sets the pixel offset mode ' quality to PixelOffsetModeHighQuality and draws a line. ' ======================================================================================== SUB Example_SetPixelOffsetMode (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform DIM rxRatio AS SINGLE = graphics.GetDpiX / 96 DIM ryRatio AS SINGLE = graphics.GetDpiY / 96 graphics.ScaleTransform(rxRatio, ryRatio)
' // Set pixel offset mode to high quality graphics.SetPixelOffsetMode(PixelOffsetModeHighQuality)
' // Draw a line or shape DIM pen AS CGpPen = CGpPen(ARGB_RED, 2 * rxRatio, UnitPixel) graphics.DrawLine(@pen, 100, 120, 300, 120)
END SUB ' ========================================================================================
Reference
- Include file
CGpGraphics.inc - Defined in AfxNova/CGpGraphics.inc:265
- Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
- Topic: CGpGraphics Class