Jump to content

GpiQueryDeviceBitmapFormats: Difference between revisions

From EDM2
Created page with "This function returns the formats of bit maps supported internally by the device driver. ==Syntax== <PRE> rc = GpiQueryDeviceBitmapFormats(hps, lCount, alArray); </PRE> ==Par..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 2: Line 2:


==Syntax==
==Syntax==
<PRE>
GpiQueryDeviceBitmapFormats(hps, lCount, alArray)
rc = GpiQueryDeviceBitmapFormats(hps, lCount, alArray);
 
</PRE>
==Parameters==
==Parameters==
; hps (HPS) - input : Presentation-space handle.
;hps (HPS) - input : Presentation-space handle.
: The associated device context defines the class of device for which formats are required. This must be either a memory device
:The associated device context defines the class of device for which formats are required. This must be either a memory device
context or a device context for a device that supports raster operations.
context or a device context for a device that supports raster operations.
 
;lCount (LONG) - input : Number of elements.
; lCount (LONG) - input : Number of elements.
:Number of elements in alArray (must be a positive even number). For the complete set of formats returned, the value of this
: Number of elements in alArray (must be a positive even number). For the complete set of formats returned, the value of this
parameter must be at least double the number of device formats returned by DevQueryCaps
parameter must be at least double the number of device formats returned by DevQueryCaps
 
;alArray (PLONG) - output : Data array.
; alArray (PLONG) - output : Data array.
Array of elements that, on return, is set to pairs of (cPlanes, cBitCount) elements (see BITMAPINFOHEADER) for each supported
: Array of elements that, on return, is set to pairs of (cPlanes , cBitCount )elements (see BITMAPINFOHEADER) for each supported
format in turn. Any unused elements are set to 0.
format in turn. Any unused elements are set to 0.


Line 24: Line 21:


==Errors==  
==Errors==  
Possible returns from WinGetLastError  
Possible returns from WinGetLastError
 
; PMERR_INV_HPS (0x207F) : An invalid presentation-space handle was specified.
; PMERR_INV_HPS (0x207F) : An invalid presentation-space handle was specified.
; PMERR_PS_BUSY (0x20F4) : An attempt was made to access the presentation space from more than one thread simultaneously.
; PMERR_PS_BUSY (0x20F4) : An attempt was made to access the presentation space from more than one thread simultaneously.

Latest revision as of 01:36, 9 November 2022

This function returns the formats of bit maps supported internally by the device driver.

Syntax

GpiQueryDeviceBitmapFormats(hps, lCount, alArray)

Parameters

hps (HPS) - input
Presentation-space handle.
The associated device context defines the class of device for which formats are required. This must be either a memory device

context or a device context for a device that supports raster operations.

lCount (LONG) - input
Number of elements.
Number of elements in alArray (must be a positive even number). For the complete set of formats returned, the value of this

parameter must be at least double the number of device formats returned by DevQueryCaps

alArray (PLONG) - output
Data array.
Array of elements that, on return, is set to pairs of (cPlanes, cBitCount) elements (see BITMAPINFOHEADER) for each supported

format in turn. Any unused elements are set to 0.

Return Code

rc (BOOL) - returns
Success indicator.
  • TRUE : Successful completion
  • FALSE : Error occurred.

Errors

Possible returns from WinGetLastError

PMERR_INV_HPS (0x207F)
An invalid presentation-space handle was specified.
PMERR_PS_BUSY (0x20F4)
An attempt was made to access the presentation space from more than one thread simultaneously.
PMERR_INV_LENGTH_OR_COUNT (0x2092)
An invalid length or count parameter was specified.

Remarks

An application can create, set, and query bit maps using any of the standard formats. Internally, however, these are converted by the device driver into one of the device internal formats if necessary. This is normally a smaller set than the standard set of bit-map formats.

The number of device bit-map formats can be found with DevQueryCaps (CAPS_BITMAP_FORMATS).

The first pair of (cPlanes , cBitCount ) elements returned most closely matches the device.

This function must not be issued when there is no device context associated with the presentation space.

Example Code

This example uses the GpiQueryDeviceBitmapFormats function to retrieve bit-map formats for the screen and creates a screen-compatible bit map with GpiCreateBitmap.

#define INCL_GPIBITMAPS /* GPI Bit-map functions */
#include <os2.h>

HPS hps; /* Target presentation-space handle */
LONG lFormats[24];/* Formats supported by the device */
HBITMAP hbm; /* Bit-map handle */
PBYTE pb; /* Bit-map image data */
BITMAPINFO2 pbmInfo; /* Bit-map information table */

/* Get screen supportable formats */
GpiQueryDeviceBitmapFormats(hps, 24L, lFormats);

/****************************
* set bitmapinfo structure *
****************************/
pbmInfo.cbFix = 16L;
pbmInfo.cx = 100L;
pbmInfo.cy = 100L;
pbmInfo.cPlanes = (USHORT) lFormats[0] ;
pbmInfo.cBitCount = (USHORT) lFormats[1];

/* create bit map and return handle */
hbm = GpiCreateBitmap(hps,            /* presentation space */
                     (PBITMAPINFOHEADER2)&pbmInfo,
                                      /* bit-map information header */
                      CBM_INIT,       /* initialize the bit map */
                      pb,             /* bit-map data */
                      &pbmInfo);      /* bit-map information table */

Related Functions