Home COM GDI+ WebBrowser Data Access 

Graphics Functions (GDI+)

 

 

The Graphics functions provide methods for drawing lines, curves, figures, images, and text. A Graphics object stores attributes of the display device and attributes of the items to be drawn.

 

Return Values

If the function succeeds, it returns Ok, which is an element of the Status enumeration.

 

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

 

GdipGetClip

 

Description

Gets the clipping region of this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetClip(

GpGraphics *graphics,

GpRegion *region

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetClip ( _

    BYVAL graphics AS DWORD, _

    BYREF region AS DWORD _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

region

[out] Pointer to a Region object that receives the clipping region.

 

GdipGetClipBounds

 

Description

Gets a rectangle that encloses the clipping region of this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetClipBounds(

    GpGraphics *graphics,

    GpRectF *rect

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetClipBounds ( _

    BYVAL graphics AS DWORD, _

    BYREF pRect AS RECTF _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

rect

[out] Pointer to a RectF structure that receives the rectangle that encloses the clipping region.

Remarks

The world transformation is applied to the clipping region and then the enclosing rectangle is calculated.

 

If you do not explicitly set the clipping region of a Graphics object, its clipping region is infinite. When the clipping region is infinite, GetClipBounds returns a large rectangle. The X and Y data members of that rectangle are large negative numbers, and the Width and Height data members are large positive numbers.

 

GdipGetClipBoundsI

 

Description

Gets a rectangle that encloses the clipping region of this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetClipBoundsI(

    GpGraphics *graphics,

    GpRect *rect

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetClipBoundsI ( _

    BYVAL graphics AS DWORD, _

    BYREF pRect AS RECTL _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

rect

[out] Pointer to a RectL structure that receives the rectangle that encloses the clipping region.

Remarks

The world transformation is applied to the clipping region and then the enclosing rectangle is calculated.

 

If you do not explicitly set the clipping region of a Graphics object, its clipping region is infinite. When the clipping region is infinite, GetClipBounds returns a large rectangle. The X and Y data members of that rectangle are large negative numbers, and the Width and Height data members are large positive numbers.

 

GdipGetCompositingMode

 

Description

Gets the compositing mode currently set for this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetCompositingMode(

    GpGraphics *graphics,

    CompositingMode *compositingMode

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetCompositingMode ( _

    BYVAL graphics AS DWORD, _

    BYREF compositingMode AS LONG _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

compositingMode

[out] Pointer to a variable that receives the compositing mode currently set for this Graphics object.

Remarks

Suppose you create a SolidBrush object based on a color that has an alpha component of 192, which is about 75 percent of 255. If your Graphics object has its compositing mode set to CompositingModeSourceOver, then areas filled with the solid brush are a blend that is 75 percent brush color and 25 percent background color. If your Graphics object has its compositing mode set to CompositingModeSourceCopy, then the background color is not blended with the brush color. However, the color rendered by the brush has an intensity that is 75 percent of what it would be if the alpha component were 255.

 

GdipGetCompositingQuality

 

Description

Gets the compositing quality currently set for this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetCompositingQuality(

    GpGraphics *graphics,

    CompositingQuality *compositingQuality

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetCompositingQuality ( _

    BYVAL graphics AS DWORD, _

    BYREF compositingQuality AS LONG _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

compositingQuality

[out] Pointer to a variable that receives the compositing quality currently set for this Graphics object.

 

GdipGetDC

 

Description

Gets a handle to the device context associated with this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetDC(

    GpGraphics* graphics,

    HDC * hdc

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetDC ( _

    BYVAL graphics AS DWORD, _

    BYREF hDC AS DWORD _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

hdc

[out] Handle to the device context associated with this Graphics object.

Remarks

Each call to the GdipGetDC fujnction should be paired with a call to the GdipReleaseDC function. Do not call any Graphics functions between the calls to GdipGetDC and GdipReleaseDC. If you attempt to call a Graphics function between GdipGetDC and GdipReleaseDC, the method will fail and will return ObjectBusy.

 

Any state changes you make to the device context between GdipGetDC and GdipReleaseDC will be ignored by GDI+ and will not be reflected in rendering done by GDI+.

 

GdipGetDpiX

 

Description

Gets the horizontal resolution, in dots per inch, of the display device associated with this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetDpiX(

    GpGraphics *graphics,

    REAL* dpi

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetDpiX ( _

    BYVAL graphics AS DWORD, _

    BYREF dpi AS SINGLE _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

dpi

[out] Pointer to a variable that receives the horizontal resolution, in dots per inch, of the display device associated with this Graphics object.

 

GdipGetDpiY

 

Description

Gets the Vertical resolution, in dots per inch, of the display device associated with this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetDpiY(

    GpGraphics *graphics,

    REAL* dpi

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetDpiY ( _

    BYVAL graphics AS DWORD, _

    BYREF dpi AS SINGLE _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

dpi

[out] Pointer to a variable that receives the vertical resolution, in dots per inch, of the display device associated with this Graphics object.

 

GdipGetHemfFromMetafile

 

Description

Gets a Windows handle to an Enhanced Metafile (EMF) file.

Syntax

GpStatus WINGDIPAPI GdipGetHemfFromMetafile(

    GpMetafile * metafile,

    HENHMETAFILE * hEmf

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetHemfFromMetafile ( _

    BYVAL metafile AS DWORD, _

    BYREF hEmf AS DWORD _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

hEmf

[out] Pointer to a variable that receives the Windows handle to an Enhanced Metafile (EMF) file.

Remarks

This method sets the Metafile object to an invalid state. The user is responsible for calling DeleteEnhMetafile, to delete the Windows handle.

 

GdipGetImageDecoders

 

Description

Gets an array of ImageCodecInfo objects that contain information about the available image decoders.

Syntax

Status GdpiGetImageDecoders(      
    UINT numDecoders,

    UINT size,

    ImageCodecInfo *decoders

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetImageDecoders ( _

    BYVAL numDecoders AS DWORD, _

    BYVAL nsize AS DWORD, _

    BYREF decoders AS ANY _

) AS LONG

Parameters

 

numDecoders

[in] Long integer value that specifies the number of available image decoders. Call GetImageDecodersSize to determine this number.

size

[in] Long integer value that specifies the size, in bytes, of the array of ImageCodecInfo objects. Call GetImageDecodersSize to determine this number.

decoders

[out] Pointer to a buffer that receives the array of ImageCodecInfo objects. You must allocate memory for this buffer. Call GetImageDecodersSize to determine the size of the required buffer.

 

GdipGetImageDecodersSize

 

Description

Gets the number of available image decoders and the total size of the array of ImageCodecInfo objects that is returned by the GdipGetImageDecoders function.

Syntax

Status GdipGetImageDecodersSize(      
    UINT *numDecoders,

    UINT *size

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetImageDecodersSize ( _

    BYREF numDecoders AS DWORD, _

    BYREF nsize AS DWORD _

) AS LONG

Parameters

 

numDecoders

[out] Pointer to a variable that receives the number of available image decoders.

size

[out] Pointer to a variable that receives the total size, in bytes, of the array of ImageCodecInfo structures that is returned by the GdipGetImageDecoders function.

 

GdipGetImageEncoders

 

Description

The GdipGetImageEncoders function gets an array of ImageCodecInfo structures that contain information about the available image encoders.

Syntax

Status GetImageEncoders(      
    UINT numEncoders,

    UINT size,

    ImageCodecInfo *encoders

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetImageEncoders ( _

    BYVAL numEncoders AS DWORD, _

    BYVAL nsize AS DWORD, _

    BYREF encoders AS ANY _

) AS LONG

Parameters

 

numEncoders

[in] Long ingteger value that specifies the number of available image encoders. Call GdipGetImageEncodersSize to determine this number.

size

[in] Long ingteger value that specifies the size, in bytes, of the array of ImageCodecInfo structures. Call GdipGetImageEncodersSize to determine this number.

encoders

[out] Pointer to a buffer that receives the array of ImageCodecInfo structures. You must allocate memory for this buffer. Call GdipGetImageEncodersSize to determine the size of the required buffer.

 

GdipGetImageEncodersSize

 

Description

The GdipGetImageEncodersSize function gets the number of available image encoders and the total size of the array of ImageCodecInfo structures that is returned by the GdipGetImageEncoders function.

Syntax

Status GdipGetImageEncodersSize(      
    UINT *numEncoders,

    UINT *size

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetImageEncodersSize ( _

    BYREF numEncoders AS DWORD, _

    BYREF nsize AS DWORD _

) AS LONG

Parameters

 

numEncoders

[out] Pointer to a variable that receives the number of available image encoders.

size

[out] Pointer to a variable that receives the total size, in bytes, of the array of ImageCodecInfo structures that is returned by GdipGetImageEncoders.

 

GdipGetInterpolationMode

 

Description

Gets the interpolation mode currently set for this Graphics object. The interpolation mode determines the algorithm that is used when images are scaled or rotated.

Syntax

GpStatus WINGDIPAPI GdipGetInterpolationMode(

    GpGraphics *graphics,

    InterpolationMode *interpolationMode

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetInterpolationMode ( _

    BYVAL graphics AS DWORD, _

    BYREF interpolationMode AS LONG _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

interpolationMode

[out] Pointer to a v ariable that receives the element of the InterpolationMode enumeration that specifies the interpolation mode.

 

GdipGetMetafileDownLevelRasterizationLimit

 

Description

Gets the rasterization limit currently set for this metafile. The rasterization limit is the resolution used for certain brush bitmaps that are stored in the metafile. For a detailed explanation of the rasterization limit, see GdipGetMetafileHeaderFromEmf.

Syntax

GpStatus WINGDIPAPI GdipGetMetafileDownLevelRasterizationLimit(

    GDIPCONST GpMetafile * metafile,

    UINT * metafileRasterizationLimitDpi

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetMetafileDownLevelRasterizationLimit ( _

    BYVAL metafile AS DWORD, _

    BYREF metafileRasterizationLimitDpi AS DWORD _

) AS LONG

Parameters

 

metafile

[in] Pointer to the Metafile object.

metafileRasterizationLimitDpi

[out] Pointer to a variable that receives the rasterization limit in dots per inch (dpi).

 

GdipGetMetafileHeaderFromEmf

 

Description

Gets the header.

Syntax

GpStatus WINGDIPAPI GdipGetMetafileHeaderFromEmf(

    HENHMETAFILE hEmf,

    MetafileHeader * header

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetMetafileHeaderFromEmf ( _

    BYVAL hEmf AS DWORD, _

    BYREF header AS MetafileHeader _

) AS LONG

Parameters

 

hEmf

[in] Windows handle to a metafile.

header

[out] Pointer to a variable that receives the header, which contains the attributes of the metafile.

 

GdipGetMetafileHeaderFromFile

 

Description

Gets the header.

Syntax

GpStatus WINGDIPAPI GdipGetMetafileHeaderFromFile(

    GDIPCONST WCHAR* filename,

    MetafileHeader * header

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetMetafileHeaderFromFile ( _

    BYVAL pFilename AS STRING, _

    BYREF header AS MetafileHeader _

) AS LONG

Parameters

 

filename

[in] Pointer to a wide-character string that specifies the name of an existing Metafile object that contains the header.

header

[out] Pointer to a variable that receives the header, which contains the attributes of the metafile.

 

GdipGetMetafileHeaderFromMetafile

 

Description

Gets the header.

Syntax

GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(

    GpMetafile * metafile,

    MetafileHeader * header

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetMetafileHeaderFromMetafile ( _

    BYVAL metafile AS DWORD, _

    BYREF header AS MetafileHeader _

) AS LONG

Parameters

 

metafile

[in] Pointer to a wide-character string that specifies the name of an existing Metafile object that contains the header.

header

[out] Pointer to a variable that receives the header, which contains the attributes of the metafile.

 

GdipGetMetafileHeaderFromStream

 

Description

Gets the header.

Syntax

GpStatus WINGDIPAPI GdipGetMetafileHeaderFromStream(

    IStream * stream

    MetafileHeader * header

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetMetafileHeaderFromStream ( _

    BYVAL pStream AS DWORD, _

    BYREF header AS MetafileHeader _

) AS LONG

Parameters

 

stream

[in] Pointer to a COM IStream interface that points to a stream of data in a file.

header

[out] Pointer to a variable that receives the header, which contains the attributes of the metafile.

 

GdipGetNearestColor

 

Description

Gets the nearest color to the color that is passed in. This method works on 8-bits per pixel or lower display devices for which there is an 8-bit color palette.

Syntax

GpStatus WINGDIPAPI GdipGetNearestColor(

    GpGraphics *graphics,

    ARGB* argb

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetNearestColor ( _

    BYVAL graphics AS DWORD, _

    BYREF argb AS DWORD _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

argb

[in, out] Pointer to a variable that, on input, specifies the color to be tested and, on output, receives the nearest color found in the color palette.

 

GdipGetPageScale

 

Description

Gets the scaling factor currently set for the page transformation of this Graphics object. The page transformation converts page coordinates to device coordinates.

Syntax

GpStatus WINGDIPAPI GdipGetPageScale(

    GpGraphics *graphics,

    REAL *scale

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetPageScale ( _

    BYVAL graphics AS DWORD, _

    BYREF pScale AS SINGLE _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

scale

[out] Pointer to a variable thatg receives the scaling factor currently set for the page transformation of this Graphics object.

 

GdipGetPageUnit

 

Description

Gets the unit of measure currently set for this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetPageUnit(

    GpGraphics *graphics,

    GpUnit *unit

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetPageUnit ( _

    BYVAL graphics AS DWORD, _

    BYREF unit AS LONG _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

unit

[out] Pointer to a variable that receives an element of the Unit enumeration that indicates the unit of measure currently set for this Graphics object.

 

GdipGetPixelOffsetMode

 

Description

Gets the pixel offset mode currently set for this Graphics object.

Syntax

GpStatus WINGDIPAPI GdipGetPixelOffsetMode(

    GpGraphics* graphics,

    PixelOffsetMode *pixelOffsetMode

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetPixelOffsetMode ( _

    BYVAL graphics AS DWORD, _

    BYREF pixelOffsetMode AS LONG _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

pixelOffsetMode

[out] Pointer to a variable that receives an element of the PixelOffsetMode enumeration that specifies the pixel offset mode.

 

GdipGetRenderingOrigin

 

Description

Gets the rendering origin currently set for this Graphics object. The rendering origin is used to set the dither origin for 8-bits per pixel and 16-bits per pixel dithering and is also used to set the origin for hatch brushes.

Syntax

GpStatus WINGDIPAPI GdipGetRenderingOrigin(

    GpGraphics *graphics,

    INT *x,

    INT *y

);

PowerBASIC Syntax

DECLARE FUNCTION GdipGetRenderingOrigin ( _