Home COM GDI+ WebBrowser Data Access 

GDI+ Structures

 

BitmapData

 

The BitmapData structure is used by the GdpiBitmapLockBits and GdpiBitmapUnlockBits functions. A BitmapData structure stores attributes of a bitmap.

 

 

Syntax

typedef struct BitmapData {

   UINT width;

   UINT height;

   INT Stride;

   PixelFormat PixelFormat;

   void *Scan0;

   UINT_PTR Reserved;

}

PowerBASIC syntax

TYPE BitmapData

   nWidth AS DWORD

   nHeight AS DWORD

   Stride AS LONG

   PixelFormat AS DWORD

   Scan0 AS DWORD

   Reserved AS DWORD

END TYPE

Members

 

nWidth

Number of pixels in one scan line of the bitmap.

nHeight

Number of scan lines in the bitmap.

Stride

Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up.

PixelFormat

Integer that specifies the pixel format of the bitmap.

Scan0

Pointer to the first (index 0) scan line of the bitmap.

Reserved

Reserved for future use.

 

CharacterRange

 

A CharacterRange structure specifies a range of character positions within a string.

 

 

Syntax

 

typedef struct CharacterRange {

   INT First;

   INT Length;

}

PowerBASIC Syntax

TYPE CharacterRange

   First AS DWORD

   Length AS DWORD

END TYPE

First

Specifies the first position of this range.

Length

Specifies the number of positions in this range.

Remarks

A character range is a range of character positions within a string of text. The area of the display that is occupied by a group of characters that are specified by the character range is the bounding region. A character range is set by GdipSetStringFormatMeasurableCharacterRanges. The number of ranges that are currently set can be determined by calling GdipGetStringFormatMeasurableCharacterRangeCount. This number is also the number of regions expected to be obtained by the GdipMeasureCharacterRanges function.

 

ColorMap

 

The ColorMap structure contains two COLORREF values. Several of the  ImageAttributes functions adjust image colors by using a color remap table, which is an array of ColorMap structures.

 

 

Syntax

typedef struct {

    Color oldColor;

    Color newColor;

} ColorMap;

Members

 

oldColor

The original color.

newColor

The new color.

Remarks

 

Defined in WinApi32.inc as follows:

TYPE COLORMAP

  cmFrom AS DWORD

  cmTo AS DWORD

END TYPE

 

ColorMatrix

 

The ColorMatrix structure contains a 55 matrix of real numbers. Several of the ImageAttributes functions adjust image colors by using a color matrix.

 

 

Syntax

typedef struct {

    REAL m[5][5];

} ColorMatrix;

PowerBASIC Syntax

TYPE ColorMatrix

   m (0 TO 4, 0 TO 4) AS SINGLE

END TYPE

Members

 

m

55 array of real numbers.

Remarks

A 55 color matrix is a homogeneous matrix for a 4-space transformation. The element in the fifth row and fifth column of a 55 homogeneous matrix must be 1, and all of the other elements in the fifth column must be 0. Color matrices are used to transform color vectors. The first four components of a color vector hold the red, green, blue, and alpha components (in that order) of a color. The fifth component of a color vector is always 1.

 

ColorPalette

 

The ColorPalette structure defines an array of colors that make up a color palette. The colors are 32-bit ARGB colors.

 

 

Syntax

typedef struct {

    UINT Flags;

    UINT Count;

    ARGB Entries[1];

} ColorPalette;

PowerBASIC Syntax

TYPE ColorPalette

   Flags AS DWORD

   Count AS DWORD

   Entries(255) AS DWORD

END TYPE

Members

 

Flags

Combination of flags from the PaletteFlags enumeration.

Count

Number of elements in the Entries array.

Entries

Array of ARGB colors.

 

EncoderParameter

 

An EncoderParameter structure holds a parameter that can be passed to an image encoder. An EncoderParameter structure can also be used to receive a list of possible values supported by a particular parameter of a particular image encoder.

 

 

Syntax

typedef struct EncoderParameter {

   GUID Guid:

   ULONG NumberOfValues;

   ULONG Type;

   void * Value;

};

PowerBASIC Syntax

TYPE EncoderParameter

   pGuid AS GUID

   NumberOfValues AS DWORD

   dwType AS DWORD

   Value AS DWORD

END TYPE

Members

 

Guid

Identifies the parameter category. GUIDs that represent various parameter categories (EncoderCompression, EncoderColorDepth, and the like) are defined in Gdiplusimaging.h.

NumberOfValues

Number of values in the array pointed to by the Value data member.

Type

Identifies the data type of the parameter. The EncoderParameterValueType enumeration in Gdiplusenums.h defines several possible value types.

Value

Pointer to an array of values. Each value has the type specified by the Type data member.

 

EncoderParameters

 

An EncoderParameters structure is an array of EncoderParameter structures along with a data member that specifies the number of EncoderParameter structures in the array.

 

 

Syntax

typedef struct EncoderParameters {

   UINT Count;

   EncoderParameter Parameter[i];

};

PowerBASIC Syntax

TYPE EncoderParameters

   Count AS DWORD

   Parameter(0) AS EncoderParameter

END TYPE

Members

 

Count

Number of EncoderParameter structures in the array.

Parameter ()

Array of EncoderParameter structures.

Remarks

 

When you create an EncoderParameters structure, you must allocate enough memory to hold all of the EncoderParameter structures that will eventually be placed in the array.

 

ENHMETAHEADER3

 

The ENHMETAHEADER3 structure contains enhanced-metafile data including the dimensions of the metafile image, the number of records in the metafile, and the resolution of the device on which the metafile was created.

 

 

Syntax

typedef struct {

    DWORD iType;

    DWORD nSize;

    RECTL rclBounds;

    RECTL rclFrame;

    DWORD dSignature;

    DWORD nVersion;

    DWORD nBytes;

    DWORD nRecords;

    WORD nHandles;

    WORD sReserved;

    DWORD nDescription;

    DWORD offDescription;

    DWORD nPalEntries;

    SIZEL szlDevice;

    SIZEL szlMillimeters;

} ENHMETAHEADER3;

PowerBASIC Syntax

TYPE ENHMETAHEADER3

   itype AS DWORD

   nSize AS DWORD

   rclBounds AS RECTL

   rclFrame AS RECTL

   dSignature AS DWORD

   nVersion AS DWORD

   nBytes AS DWORD

   nRecords AS DWORD

   nHandles AS WORD

   sReserved AS WORD

   nDescription AS DWORD

   offDescription AS DWORD

   nPalEntries AS DWORD

   szlDevice AS SIZEL

   szlMillimeters AS SIZEL

END TYPE

Members

 

iType

Record type. Value is always EMR_HEADER.

nSize

Structure size, in bytes. This may be greater than the value returned by sizeof(ENHMETAHEADER3).

rclBounds

Bounding rectangle, in device units, for the image stored in the metafile.

rclFrame

Rectangle, in 0.01 millimeter units, that surrounds the image stored in the metafile.

dSignature

Must be ENHMETA_SIGNATURE.

nVersion

Version number of the metafile format. The current version is &H10000.

nBytes

Size, in bytes, of the metafile.

nRecords

Number of records in the metafile.

nHandles

Number of handles in the metafile handle table. Handle index zero is reserved.

sReserved

Reserved. Must be zero.

nDescription

Number of characters in the string that contains the description of the metafile's contents. This member is 0 if the metafile does not have a description string.

offDescription

Offset from the beginning of the ENHMETAHEADER3 structure to the string that contains the description of the metafile's contents. This member is 0 if the metafile does not have a description string.

nPalEntries

Number of entries in the metafile palette.

szlDevice

Resolution, in pixels, of the reference device.

szlMillimeters

Resolution, in millimeters, of the reference device.

 

GdiPlusStartupInput

 

The GdiplusStartupInput structure holds a block of arguments that are required by the GdiplusStartup function.

 

 

Syntax

struct GdiplusStartupInput

{

    UINT32 GdiplusVersion;            

    DebugEventProc DebugEventCallback;

    BOOL SuppressBackgroundThread;

    BOOL SuppressExternalCodecs;

   

    GdiplusStartupInput(

        DebugEventProc debugEventCallback = NULL,

        BOOL suppressBackgroundThread = FALSE,

        BOOL suppressExternalCodecs = FALSE)

    {

        GdiplusVersion = 1;

        DebugEventCallback = debugEventCallback;

        SuppressBackgroundThread = suppressBackgroundThread;

        SuppressExternalCodecs = suppressExternalCodecs;

    }

};

 

typedef VOID (WINAPI *DebugEventProc)(DebugEventLevel level, CHAR *message);

PowerBASIC Syntax

TYPE GdiplusStartupInput

   GdiplusVersion AS DWORD

   DebugEventCallback AS DWORD

   SuppressBackgroundThread AS LONG

   SuppressExternalCodecs AS LONG

END TYPE

Members

 

GdiplusVersion

Specifies the version of Microsoft Windows GDI+. Must be 1.

DebugEventCallback

Pointer to a callback function that GDI+ can call, on debug builds, for assertions and warnings. The default value is NULL.

SuppressBackgroundThread

Boolean value that specifies whether to suppress the GDI+ background thread. If you set this member to TRUE, GdiplusStartup returns (in its output parameter) a pointer to a hook function and a pointer to an unhook function. You must call those functions appropriately to replace the background thread. If you do not want to be responsible for calling the hook and unhook functions, set this member to FALSE. The default value is FALSE.

SuppressExternalCodecs

Boolean value that specifies whether you want GDI+ to suppress external image codecs. GDI+ version 1.0 does not support external image codecs, so this parameter is ignored.

Remarks

The GdiplusStartupInput structure provides a constructor that sets the GdiplusVersion member to 1 and allows you to specify values for the other three members. All of the constructor parameters are optional, so you can declare a variable of type GdiplusStartupInput without passing any arguments to the constructor, and all of the members will be initialized with appropriate default values.

If you set the SuppressBackgroundThread member of the GdiplusStartupinput parameter to TRUE, you must call the hook and unhook functions returned in the output parameter. Call those functions before and after the application's main message loop; that is, a message loop that is active for the lifetime of GDI+. Call the hook function before the loop starts, and call the unhook function after the loop ends.

 

 

GdiPlusStartupOutput

 

The GdiplusStartup function uses the GdiplusStartupOutput structure to return (in its output parameter) a pointer to a hook function and a pointer to an unhook function. If you set the SuppressBackgroundThread member of the input parameter to TRUE, then you are responsible for calling those functions to replace the Microsoft Windows GDI+ background thread.

 

Call the hook and unhook functions before and after the application's main message loop; that is, a message loop that is active for the lifetime of GDI+. Call the hook function before the loop starts, and call the unhook function after the loop ends. The token parameter of the hook function receives an identifier that you should later pass to the unhook function. If you do not pass the proper identifier (the one returned by the hook function) to the unhook function, there will be resource leaks that won't be cleaned up until the process exits.

 

If you do not want to be responsible for calling the hook and unhook functions, set the SuppressBackgroundThread member of the input parameter (passed to GdiplusStartup) to FALSE.

 

 

Syntax

struct GdiplusStartupOutput {

  NotificationHookProc NotificationHook;

  NotificationUnhookProc NotificationUnhook;

};

 

typedef Status (WINAPI *NotificationHookProc)(OUT ULONG_PTR *token);

typedef VOID (WINAPI *NotificationUnhookProc)(ULONG_PTR token);

PowerBASIC Syntax

TYPE GdiplusStartupOutput

   NotificationHook AS DWORD

   NotificationUnhook AS DWORD

END TYPE

Members

 

NotificationHook

Receives a pointer to a hook function.

NotificationUnhook

Receives a pointer to an unhook function.

 

ImageCodecInfo

 

An ImageCodecInfo structure stores information about an image codec (encoder/decoder). GDI+ provides several built-in image codecs. You can obtain information about those codecs by calling the GetImageEncoders function and the GetImageDecoders function. Each of those functions returns an array of ImageCodecInfo structures, one for each available encoder or decoder.

 

 

Syntax

typedef struct ImageCodecInfo {

   CLSID ClassID;

   GUID FormatID;

   WCHAR * CodecName;

   WCHAR * DllName;

   WCHAR * FormatDescription;

   WCHAR * FilenameExtension;

   WCHAR * MimeType;

   DWORD Flags;

   DWORD Version;

   DWORD SigCount;

   DWORD SigSize;

   BYTE * SigPattern;

   BYTE * SigMask;

};

PowerBASIC Syntax

TYPE ImageCodecInfo

   ClassID AS GUID

   FormatID AS GUID

   CodecName AS DWORD

   DllName AS DWORD

   FormatDescription AS DWORD

   FilenameExtension AS DWORD

   MimeType AS DWORD

   Flags AS DWORD

   Version AS DWORD

   SigCount AS DWORD

   SigSize AS DWORD

   SigPattern AS BYTE PTR

   SigMask AS BYTE PTR

END TYPE

Members

 

ClassID

Codec identifier.

FormatID

File format identifier. GUIDs that identify various file formats (ImageFormatBMP, ImageFormatEMF, and the like) are defined in Gdiplusimaging.h.

CodecName

Pointer to a null-terminated wide string that contains the codec name.

DllName

Pointer to a null-terminated wide string that contains the path name of the DLL in which the codec resides. If the codec is not in a DLL, this pointer is NULL.

FormatDescription

Pointer to a null-terminated wide string that contains the name of the file format used by the codec.

FilenameExtension

Pointer to a null-terminated wide string that contains all file-name extensions associated with the codec. The extensions are separated by semicolons.

MimeType

Pointer to a null-terminated wide string that contains the mime type of the codec.

Flags

Combination of flags from the ImageCodecFlags enumeration.

Version

Integer that indicates the version of the codec.

SigCount

Integer that indicates the number of signatures used by the file format associated with the codec.

SigSize

Integer that indicates the number of bytes in each signature.

SigPattern

Pointer to an array of bytes that contains the pattern for each signature.

SigMask

Pointer to an array of bytes that contains the mask for each signature.

 

LOGFONTW

 

Defines the attributes of a font.

 

 

Syntax

typedef struct {

    LONG lfHeight;

    LONG lfWidth;

    LONG lfEscapement;

    LONG lfOrientation;

    LONG lfWeight;

    BYTE lfItalic;

    BYTE lfUnderline;

    BYTE lfStrikeOut;

    BYTE lfCharSet;

    BYTE lfOutPrecision;

    BYTE lfClipPrecision;

    BYTE lfQuality;

    BYTE lfPitchAndFamily;

    WCHAR lfFaceName[LF_FACESIZE];

} LOGFONTW;

PowerBASIC Syntax

TYPE LOGFONTW

   lfHeight AS LONG

   lfWidth AS LONG

   lfEscapement AS LONG

   lfOrientation AS LONG

   lfWeight AS LONG

   lfItalic AS BYTE

   lfUnderline AS BYTE

   lfStrikeOut AS BYTE

   lfCharSet AS BYTE

   lfOutPrecision AS BYTE

   lfClipPrecision AS BYTE

   lfQuality AS BYTE

   lfPitchAndFamily AS BYTE

   lfFaceName AS STRING * 32 * 2

END TYPE

Members

 

lfHeight

Value of type LONG that specifies the height, in logical units, of the font's character cell or character.

lfWidth

Value of type LONG that specifies the width, in logical units, of characters in the font.

lfEscapement

Value of type LONG that contains the angle, in tenths of degrees, between the escapement vector and the x-axis of the device. The escapement vector is parallel to the base line of a row of text.

lfOrientation

Value of type LONG that specifies the angle, in tenths of degrees, between each character's base line and the x-axis of the device.

lfWeight

Value of type LONG that specifies the weight of the font in the range from 0 through 1000.

lfItalic

Value of type BYTE that specifies an italic font if set to TRUE.

lfUnderline

Value of type BYTE that specifies an underlined font if set to TRUE.

lfStrikeOut

Value of type BYTE that specifies a strikeout font if set to TRUE.

lfCharSet

Value of type BYTE that specifies the character set.

lfOutPrecision

Value of type BYTE that specifies the output precision. The output precision defines how closely the output must match the requested font's height, width, character orientation, escapement, pitch, and font type.

lfClipPrecision

Value of type BYTE that specifies the clipping precision. The clipping precision defines how to clip characters that are partially outside the clipping region.

lfQuality

Value of type BYTE that specifies the output quality. The output quality defines how carefully the Microsoft Windows Graphics Device Interface (GDI) must attempt to match the logical-font attributes to those of an actual physical font.

lfPitchAndFamily

Value of type BYTE that specifies the pitch and family of the font.

lfFaceName

Array of wide characters that contains a null-terminated string that specifies the typeface name of the font. The length of the string must not exceed 32 characters, including the NULL terminator.

 

MetafileHeader

 

A MetafileHeader object stores properties of an associated metafile.

 

 

PowerBASIC Syntax

UNION MetafileHeader_UNION

   WmfHeader AS METAHEADER

   EmfHeader AS ENHMETAHEADER3

END UNION

 

TYPE MetafileHeader

   nType AS DWORD            ' // The type of the associated metafile

   nSize AS DWORD            ' // Size of the metafile (in bytes)

   Version AS DWORD          ' // EMF+, EMF, or WMF version

   EmfPlusFlags AS DWORD

   DpiX AS SINGLE

   DpiY AS SINGLE

   X AS LONG                 ' // Bounds in device units

   Y AS LONG

   nWidth AS LONG

   nHeight AS LONG

   MetafileHeader_UNION

   EmfPlusHeaderSize AS LONG ' // size of the EMF+ header in file

   LogicalDpiX AS LONG       ' // Logical Dpi of reference Hdc

   LogicalDpiY AS LONG       ' // usually valid only for EMF+

END TYPE

Remarks

Metafiles provide a device-independent and application-independent way to share pictures. They contain records that describe a sequence of graphics application programming interfaces (APIs) to invoke in a particular order with their associated graphics data. Metafiles can be recorded by an application and later played back by that application or by another one to reproduce a particular picture. They can also be used to send content to a print spooler. Enhanced metafiles support the ability to provide both Microsoft Windows GDI+ and Windows Graphics Device Interface (GDI) descriptions of the same picture so that both GDI+ and down-level GDI applications can render it.

 

PathData

 

The PathData structure is used by the GdipGetPathData function. It has an array of points and an array of types. Each element in the array of types is a byte that specifies the point type and a set of flags for the corresponding element in the array of points. You can use a PathData structure to get or set the data points (and their types) of a path.

 

 

Syntax

typedef struct PathData {

   INT Count;

   PointF * Points;

   BYTE * Types;

};

PowerBASIC Syntax

TYPE PathData

   Count AS LONG

   Points AS PointF PTR

   Types AS BYTE PTR

END TYPE

 

PointF

 

Encapsulates a point in a 2-D coordinate system.

 

 

yntax

typedef struct PointF {

   REAL x;

   REAL y;

};

PowerBASIC Syntax

TYPE PointF

   x AS SINGLE