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.

 

GdipBeginContainer

 

Description

Begins a new graphics container.

Syntax

GpStatus WINGDIPAPI GdipBeginContainer(

    GpGraphics *graphics,

    GDIPCONST GpRectF* dstrect,

    GDIPCONST GpRectF *srcrect,

    GpUnit unit,

    GraphicsContainer *state

);

PowerBASIC Syntax

DECLARE FUNCTION GdipBeginContainer ( _

    BYVAL graphics AS DWORD, _

    BYREF dstrect AS RECTF, _

    BYREF srcRect AS RECTF, _

    BYVAL unit AS LONG, _

    BYREF pState AS DWORD _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

dstrect

[in] Reference to a rectangle that, together with srcrect, specifies a transformation for the container.

srcrect

[in] Reference to a rectangle that, together with dstrect, specifies a transformation for the container.

unit

[int] Unit of measure for the container.

state

[out] Pointer to a value that receives a value that identifies the container.

Remarks

Use this function to create nested graphics containers. Graphics containers are used to retain graphics state, such as transformations, clipping regions, and various rendering properties.

 

The GdipBeginContainer function returns a value of type GraphicsContainer. When you have finished using a container, pass that value to the GdipEndContainer function.

 

When you call the GdipBeginContainer function, an information block that holds the state of the Graphics object is put on a stack. The GdipBeginContainer function returns a value that identifies that information block. When you pass the identifying value to the GdipEndContainer function, the information block is removed from the stack and is used to restore the Graphics object to the state it was in at the time of the GdipBeginContainer call.

Containers can be nested; that is, you can call the GdipBeginContainer function several times before you call the GdipEndContainer function. Each time you call the GdipBeginContainer function, an information block is put on the stack, and you receive an identifier for the information block. When you pass one of those identifiers to the GdipEndContainer function, the Graphics object is returned to the state it was in at the time of the GdipBeginContainer call that returned that particular identifier. The information block placed on the stack by that GdipBeginContainer call is removed from the stack, and all information blocks placed on that stack after that GdipBeginContainer call are also removed.

Calls to the GdipSaveGraphics function place information blocks on the same stack as calls to the GdipBeginContainer function. Just as an GdipEndContainer call is paired with a GdipBeginContainer call, a GdipRestoreGraphics call is paired with a GdipSaveGraphics call.

 

Caution When you call GdipEndContainer, all information blocks placed on the stack (by GdipSaveGraphics or by GdipBeginContainer) after the corresponding call to  GdipBeginContainerare removed from the stack. Likewise, when you call GdipRestoreGraphics, all information blocks placed on the stack (by GdipSaveGraphics or by GdipBeginContainer) after the corresponding call to GdipSaveGraphics are removed from the stack.

 

For more information about graphics containers, see Nested Graphics Containers.

 

GdipBeginContainer2

 

Description

Begins a new graphics container.

Syntax

GpStatus WINGDIPAPI GdipBeginContainer2(

    GpGraphics *graphics,

    GraphicsContainer *state

);

PowerBASIC Syntax

DECLARE FUNCTION GdipBeginContainer2 ( _

    BYVAL graphics AS DWORD, _

    BYREF pState AS DWORD _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

state

[out] Pointer to a variable that receives a value that identifies the container.

 

GdipBeginContainerI

 

Description

Begins a new graphics container.

Syntax

GpStatus WINGDIPAPI GdipBeginContainerI(

    GpGraphics *graphics,

    GDIPCONST GpRect* dstrect,

    GDIPCONST GpRect *srcrect,

    GpUnit unit,

    GraphicsContainer *state

);

PowerBASIC Syntax

DECLARE FUNCTION GdipBeginContainerI ( _

    BYVAL graphics AS DWORD, _

    BYREF dstrect AS RECTL, _

    BYREF srcRect AS RECTL, _

    BYVAL unit AS LONG, _

    BYREF pState AS DWORD _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

dstrect

[in] Reference to a rectangle that, together with srcrect, specifies a transformation for the container.

srcrect

[in] Reference to a rectangle that, together with dstrect, specifies a transformation for the container.

unit

[int] Unit of measure for the container.

state

[out] Pointer to a variable that receives a value that identifies the container.

 

GdipComment

 

Description

Adds a text comment to an existing metafile.

Syntax

GpStatus WINGDIPAPI GdipComment(

    GpGraphics* graphics,

    UINT sizeData,

    GDIPCONST BYTE * data

);

PowerBASIC Syntax

DECLARE FUNCTION GdipComment ( _

    BYVAL graphics AS DWORD, _

    BYVAL sizeData AS DWORD, _

    BYREF pData AS ANY _

) AS LONG

Parameters

 

graphics

[in] Pointer to the Graphics object.

sizeData

[in] Integer that specifies the number of bytes in the value of the data parameter.

data

[in] Pointer to a buffer that contains the comment.

 

GdipCreateFromHDC

 

Description

Creates a Graphics object that is associated with a specified device context.

Syntax

GpStatus WINGDIPAPI GdipCreateFromHDC(

    HDC hdc,

    GpGraphics **graphics

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateFromHDC ( _

    BYVAL hDC AS DWORD, _

    BYREF graphics AS DWORD _

) AS LONG

Parameters

 

hdc

[in] Handle to a device context that will be associated with the new Graphics object.

graphics

[out] Pointer to a variable that receives a pointer to the new created Graphics object.

Remarks

When you use this function to create a Graphics object, make sure that the Graphics object is deleted before the device context is released.

 

GdipCreateFromHDC2

 

Description

Creates a Graphics object that is associated with a specified device context and a specified device.

Syntax

GpStatus WINGDIPAPI GdipCreateFromHDC2(

    HDC hdc,

    HANDLE hDevice,

    GpGraphics **graphics

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateFromHDC2 ( _

    BYVAL hDC AS DWORD, _

    BYVAL hDevice AS DWORD, _

    BYREF graphics AS DWORD _

) AS LONG

Parameters

 

hdc

[in] Handle to a device context that will be associated with the new Graphics object.

hdevice

[in] Handle to a device that will be associated with the new Graphics object.

graphics

[out] Pointer to a variable that receives a pointer to the new created Graphics object.

Remarks

When you use this function to create a Graphics object, make sure that the Graphics object is deleted before the device context is released.

 

GdipCreateFromHWND

 

Description

Creates a Graphics object that is associated with a specified window.

Syntax

GpStatus WINGDIPAPI GdipCreateFromHWND(

    HWND hwnd,

    GpGraphics **graphics

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateFromHWND ( _

    BYVAL hwnd AS DWORD, _

    BYREF graphics AS DWORD _

) AS LONG

Parameters

 

hwnd

[in] Handle to a window that will be associated with the new Graphics object.

graphics

[out] Pointer to a variable that receives a pointer to the new created Graphics object.

 

GdipCreateFromHWNDICM

 

Description

Creates a Graphics object that is associated with a specified window.

Syntax

GpStatus WINGDIPAPI GdipCreateFromHWNDICM(

    HWND hwnd,

    GpGraphics **graphics

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateFromHWNDICM ( _

    BYVAL hwnd AS DWORD, _

    BYREF graphics AS DWORD _

) AS LONG

Parameters

 

hwnd

[in] Handle to a window that will be associated with the new Graphics object.

graphics

[out] Pointer to a variable that receives a pointer to the new created Graphics object.

 

GdipCreateHalftonePalette

 

Description

Gets a Windows halftone palette.

Syntax

HPALETTE WINGDIPAPI GdipCreateHalftonePalette();

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateHalftonePalette() AS DWORD

Return Value

Returns a handle to a Windows halftone palette.

Remarks

The purpose of the GdipCreateHalftonePalette function is to enable GDI+ to produce a better quality halftone when the display uses 8 bits per pixel. To display an image using the halftone palette, use the following procedure:

  1. Call GdipCreateHalftonePalette to get a GDI+ halftone palette.

  2. Select the halftone palette into a device context.

  3. Realize the palette by calling the RealizePalette function.

  4. Construct a Graphics object from a handle to the device context.

  5. Call one of the GdipDrawImage functions of the Graphics object.

Be sure to delete the palette when you have finished using it. If you do not follow the preceding procedure, then on an 8-bits-per-pixel-display device, the default, 16-color process is used, which results in a lesser quality halftone.

 

GdipCreateMetafileFromEmf

 

Description

Creates a Microsoft Windows GDI+Metafile object for playback based on a Windows Graphics Device Interface (GDI) Enhanced Metafile (EMF) file.

Syntax

GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(

    HENHMETAFILE hEmf,

    BOOL deleteEmf,

    GpMetafile **metafile

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateMetafileFromEmf ( _

    BYVAL hEmf AS DWORD, _

    BYVAL deleteEmf AS LONG, _

    BYREF metafile AS DWORD _

) AS LONG

Parameters

 

hEmf

[in] Windows handle to a metafile.

deleteEmf

[in] Boolean value that specifies whether the Windows handle to a metafile is deleted when the Metafile object is deleted. TRUE specifies that the hEmf Windows handle is deleted, and FALSE specifies that the hEmf Windows handle is not deleted. The default value is FALSE.

metafile

[out] Pointer to a variable that receives a pointer to the new created Metafile object.

 

GdipCreateMetafileFromFile

 

Description

Creates a Metafile object for playback.

Syntax

GpStatus WINGDIPAPI GdipCreateMetafileFromFile(

    GDIPCONST WCHAR* file,

    GpMetafile **metafile

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateMetafileFromFile ( _

    BYVAL file AS STRING, _

    BYREF metafile AS DWORD _

) AS LONG

Parameters

 

file

[in] Pointer to a wide-character string that specifies the name of an existing disk file used to create the Metafile object for playback.

metafile

[out] Pointer to a variable that receives a pointer to the new created Metafile object.

 

GdipCreateMetafileFromStream

 

Description

Creates a Metafile object from an IStream interface for playback.

Syntax

GpStatus WINGDIPAPI GdipCreateMetafileFromStream(

    IStream * stream,

    GpMetafile **metafile

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateMetafileFromStream ( _

    BYVAL pStream AS DWORD, _

    BYREF metafile AS DWORD _

) AS LONG

Parameters

 

stream

[in] Pointer to a Component Object Model (COM) IStream interface that points to a data stream in a file.

metafile

[out] Pointer to a variable that receives a pointer to the new created Metafile object.

 

GdipCreateMetafileFromWmf

 

Description

Creates a Microsoft Windows GDI+Metafile object for recording. The format will be placeable metafile.

Syntax

GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(

    HMETAFILE hWmf,

    BOOL deleteWmf,

    GDIPCONST WmfPlaceableFileHeader * wmfPlaceableFileHeader,

    GpMetafile **metafile

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateMetafileFromWmf ( _

    BYVAL hWmf AS DWORD, _

    BYVAL deleteWmf AS LONG, _

    BYREF WmfPlaceableFlHdr AS WmfPlaceableFileHeader, _

    BYREF metafile AS DWORD _

) AS LONG

Parameters

 

hWmf

[in] Windows handle to a metafile.

deleteWmf

[in] Boolean value that specifies whether the Windows handle to a metafile is deleted when the metafile is deleted. TRUE specifies that the hWmf Windows handle is deleted, and FALSE specifies that the hWmf Windows handle is not deleted. The default value is FALSE.

wmfPlaceableFileHeader

[in] Pointer to a WmfPlaceableFileHeader structure that specifies a preheader preceding the metafile header.

metafile

[out] Pointer to a variable that receives a pointer to the new created Metafile object.

Remarks

Placeable metafiles are WMF files that contain a preheader preceding the metafile header. The preheader contains additional information for the metafile header of the metafile.

 

GdipCreateMetafileFromWmfFile

 

Description

Creates a Microsoft Windows GDI+Metafile object for playback.

Syntax

GpStatus WINGDIPAPI GdipCreateMetafileFromWmfFile(

    GDIPCONST WCHAR* file,

    GDIPCONST WmfPlaceableFileHeader * wmfPlaceableFileHeader,

    GpMetafile **metafile

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateMetafileFromWmfFile ( _

    BYVAL file AS STRING, _

    BYREF WmfPlaceableFlHdr AS WmfPlaceableFileHeader, _

    BYREF metafile AS DWORD _

) AS LONG

Parameters

 

file

[in] Pointer to a null-terminated unicode string that specifies the name of an existing disk file used to create the Metafile object for playback.

wmfPlaceableFileHeader

[in] Pointer to a WmfPlaceableFileHeader structure that specifies a preheader preceding the metafile header.

metafile

[out] Pointer to a variable that receives a pointer to the new created Metafile object.

Remarks

Placeable metafiles are WMF files that contain a preheader preceding the metafile header. The preheader contains additional information for the metafile header of the metafile.

 

GdipCreateStreamOnFile

 

Description

Returns a pointer to an IStream interface based on a file. The filename parameter specifies the file. The access parameter is a set of flags that must include GENERIC_READ or GENERIC_WRITE. The stream parameter receives a pointer to the IStream interface.

Syntax

GpStatus WINGDIPAPI GdipCreateStreamOnFile(

    GDIPCONST WCHAR * filename,

    UINT access,

    IStream **stream

);

PowerBASIC Syntax

DECLARE FUNCTION GdipCreateStreamOnFile ( _

    BYVAL pFilename AS STRING, _

    BYVAL pAccess AS DWORD, _

    BYREF pStream AS DWORD _

) AS LONG

Parameters

 

filename

[in] Pointer to a null-terminated unicode string that specifies the name of a file.

access

[in] Set of flags that must include GENERIC_READ or GENERIC_WRITE.

stream

[out] Pointer to a variable that receives a pointer to the IStream interface.

 

Page last updated on Monday, 11 December 2006 11:11:39 +0100