WinDrawBitmap: Difference between revisions
Created page with "This function draws a bit map using the current image colors and mixes. ==Syntax== WinDrawBitmap(hpsDst, hbm, pwrcSrc, pptlDst, clrFore, clrBack, fl) ==Parameters== ;hpsDst..." |
mNo edit summary |
||
Line 5: | Line 5: | ||
==Parameters== | ==Parameters== | ||
;hpsDst (HPS) - input | ;hpsDst (HPS) - input:Handle of presentation space in which the bit map is drawn. | ||
:Handle of presentation space in which the bit map is drawn. | ;hbm ([[HBITMAP]]) - input:Bit-map handle. | ||
;pwrcSrc ([[PRECTL]]) - input:Subrectangle of bit map to be drawn. | |||
;hbm (HBITMAP) - input | |||
:Bit-map handle. | |||
;pwrcSrc (PRECTL) - input | |||
:Subrectangle of bit map to be drawn. | |||
:Note: The value of each field in this structure must be in the range -32 768 through The data type WRECT can also be used, if supported by the language. | :Note: The value of each field in this structure must be in the range -32 768 through The data type WRECT can also be used, if supported by the language. | ||
: | ::NULL - The whole of the bit map is drawn | ||
::Other - The whole of the bit map is not drawn. | |||
;pptlDst (PPOINTL) - input:Bit-map destination. | |||
;pptlDst (PPOINTL) - input | |||
:Bit-map destination. | |||
:The bottom left corner of the bit-map destination is specified in device coordinates. | :The bottom left corner of the bit-map destination is specified in device coordinates. | ||
:If DBM_STRETCH is set in fl, this parameter is used as a pointer to a RECTL data structure that contains the coordinates of the rectangle into which the source bit map is to be drawn. In this situation, pptlDst should be treated as a PRECTL datatype. | :If DBM_STRETCH is set in fl, this parameter is used as a pointer to a RECTL data structure that contains the coordinates of the rectangle into which the source bit map is to be drawn. In this situation, pptlDst should be treated as a PRECTL datatype. | ||
;clrFore (LONG) - input:Foreground color. | |||
;clrFore (LONG) - input | :This is used if hbm refers to a monochrome bit map. In this instance, bit-map bits that are set to 1 are drawn using clrFore. Ignored if DBM_IMAGEATTRS is specified. | ||
:Foreground color. | |||
:This is used if hbm refers to a monochrome bit map. In this instance, bit-map bits that are set to 1 are drawn using clrFore. Ignored if DBM_IMAGEATTRS is specified. | |||
;clrBack (LONG) - input | ;clrBack (LONG) - input | ||
:Background color. | :Background color. | ||
:This is used if hbm refers to a monochrome bit map. In this instance, bit-map bits that are set to zero are drawn using clrBack. Ignored if DBM_IMAGEATTRS is specified. | :This is used if hbm refers to a monochrome bit map. In this instance, bit-map bits that are set to zero are drawn using clrBack. Ignored if DBM_IMAGEATTRS is specified. | ||
;fl (ULONG) - input:Flags that determine how the bit map is drawn. | |||
;fl (ULONG) - input | ::DBM_NORMAL - Draw the bit map normally using ROP_SRCCOPY, as defined in GpiBitBlt. | ||
:Flags that determine how the bit map is drawn. | ::DBM_INVERT - Draw the bit map inverted using ROP_NOTSRCCOPY, as defined in GpiBitBlt. | ||
: | ::DBM_STRETCH - pptlDst is used to point to a RECTL data structure representing a rectangle in the destination presentation space, into which the bit map will be stretched or - compressed. If compression is required, some rows and columns of the bit map are eliminated. | ||
::DBM_HALFTONE - Use the OR operator to combine the bit map with an alternating pattern of ones or zeros before drawing it. It can be used with either | |||
: | :;DBM_NORMAL or DBM_INVERT. DBM_IMAGEATTRS | ||
: | |||
: | |||
:;DBM_NORMAL or DBM_INVERT. DBM_IMAGEATTRS | |||
::If this is specified, color conversion of monochrome bit maps is done by using the image attributes. | ::If this is specified, color conversion of monochrome bit maps is done by using the image attributes. | ||
Line 66: | Line 49: | ||
==Example Code== | ==Example Code== | ||
This example uses WinDrawBitmap to draw the system-defined menu check mark bit map in response to the user selecting a menu item (WM_MENUSELECT), using the bit-map handle returned by WinGetSysBitmap. | This example uses WinDrawBitmap to draw the system-defined menu check mark bit map in response to the user selecting a menu item (WM_MENUSELECT), using the bit-map handle returned by WinGetSysBitmap. | ||
<pre> | <pre> | ||
#define INCL_WINWINDOWMGR /* Window Manager Functions */ | #define INCL_WINWINDOWMGR /* Window Manager Functions */ | ||
#define INCL_WINPOINTERS /* Window Pointer Functions */ | #define INCL_WINPOINTERS /* Window Pointer Functions */ | ||
Line 110: | Line 91: | ||
DBM_NORMAL); /* draw normal size */ | DBM_NORMAL); /* draw normal size */ | ||
} | } | ||
</pre> | </pre> | ||
Latest revision as of 01:34, 12 December 2023
This function draws a bit map using the current image colors and mixes.
Syntax
WinDrawBitmap(hpsDst, hbm, pwrcSrc, pptlDst, clrFore, clrBack, fl)
Parameters
- hpsDst (HPS) - input
- Handle of presentation space in which the bit map is drawn.
- hbm (HBITMAP) - input
- Bit-map handle.
- pwrcSrc (PRECTL) - input
- Subrectangle of bit map to be drawn.
- Note: The value of each field in this structure must be in the range -32 768 through The data type WRECT can also be used, if supported by the language.
- NULL - The whole of the bit map is drawn
- Other - The whole of the bit map is not drawn.
- pptlDst (PPOINTL) - input
- Bit-map destination.
- The bottom left corner of the bit-map destination is specified in device coordinates.
- If DBM_STRETCH is set in fl, this parameter is used as a pointer to a RECTL data structure that contains the coordinates of the rectangle into which the source bit map is to be drawn. In this situation, pptlDst should be treated as a PRECTL datatype.
- clrFore (LONG) - input
- Foreground color.
- This is used if hbm refers to a monochrome bit map. In this instance, bit-map bits that are set to 1 are drawn using clrFore. Ignored if DBM_IMAGEATTRS is specified.
- clrBack (LONG) - input
- Background color.
- This is used if hbm refers to a monochrome bit map. In this instance, bit-map bits that are set to zero are drawn using clrBack. Ignored if DBM_IMAGEATTRS is specified.
- fl (ULONG) - input
- Flags that determine how the bit map is drawn.
- DBM_NORMAL - Draw the bit map normally using ROP_SRCCOPY, as defined in GpiBitBlt.
- DBM_INVERT - Draw the bit map inverted using ROP_NOTSRCCOPY, as defined in GpiBitBlt.
- DBM_STRETCH - pptlDst is used to point to a RECTL data structure representing a rectangle in the destination presentation space, into which the bit map will be stretched or - compressed. If compression is required, some rows and columns of the bit map are eliminated.
- DBM_HALFTONE - Use the OR operator to combine the bit map with an alternating pattern of ones or zeros before drawing it. It can be used with either
- DBM_NORMAL or DBM_INVERT. DBM_IMAGEATTRS
- If this is specified, color conversion of monochrome bit maps is done by using the image attributes.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE
- Successful completion
- FALSE
- Error occurred.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_FLAG (0x1019)
.:An invalid bit was set for a parameter. Use constants defined by PM for options, and do not set any reserved bits.
- PMERR_HBITMAP_BUSY (0x2032)
-
- An internal bit map busy error was detected. The bit map was locked by one thread during an attempt to access it from another thread.
Remarks
This function should only be used in draw mode (DM_DRAW) to a screen device context (see "GpiSetDrawingMode" in the Graphics Programming Interface Programming Reference). The presentation space handle can be to either a micro-presentation space or a normal presentation space (see "GpiCreatePS" in the Graphics Programming Interface Programming Reference).
If hbm refers to a color bit map, no color conversion is performed.
The current position in the presentation space is not changed by this function.
Example Code
This example uses WinDrawBitmap to draw the system-defined menu check mark bit map in response to the user selecting a menu item (WM_MENUSELECT), using the bit-map handle returned by WinGetSysBitmap.
#define INCL_WINWINDOWMGR /* Window Manager Functions */ #define INCL_WINPOINTERS /* Window Pointer Functions */ #define INCL_WINMESSAGEMGR /* Window Message Functions */ #define INCL_WINMENUS /* Window Menu Functions */ #include <os2.h> HPS hps; /* presentation-space handle */ HBITMAP hbmCheck; /* check mark bit-map handle */ HWND hwndMenu; /* menu handle */ USHORT usItemId; /* menu item id */ RECTL rclItem; /* item border rectangle */ MPARAM mpParam1; /* Parameter 1 (menu item id) */ MPARAM mpParam2; /* Parameter 2 (menu handle) */ case WM_CREATE: /* obtain check mark bit-map handle */ hbmCheck = WinGetSysBitmap(HWND_DESKTOP, SBMP_MENUCHECK); case WM_MENUSELECT: usItemId = SHORT1FROMMP(mpParam1); hwndMenu = HWNDFROMMP(mpParam2); /* get rectangle of selected item */ WinSendMsg(hwndMenu, MM_QUERYITEMRECT, MPFROM2SHORT(usItemId, TRUE), MPFROMP(&rclItem)); /* draw the check mark in the lower left corner of item's rectangle */ if (hbmCheck != NULL) { WinDrawBitmap(hps, hbmCheck, /* check mark */ NULL, /* draw whole bit map */ (PPOINTL)&rclItem,/* bit-map destination */ 0L, /* ignored since color */ 0L, /* bit map */ DBM_NORMAL); /* draw normal size */ }
Definition
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HPS hpsDst; /* Handle of presentation space in which the bit map is drawn. */ HBITMAP hbm; /* Bit-map handle. */ PRECTL pwrcSrc; /* Subrectangle of bit map to be drawn. */ PPOINTL pptlDst; /* Bit-map destination. */ LONG clrFore; /* Foreground color. */ LONG clrBack; /* Background color. */ ULONG fl; /* Flags that determine how the bit map is drawn. */ BOOL rc; /* Success indicator. */ rc = WinDrawBitmap(hpsDst, hbm, pwrcSrc, pptlDst, clrFore, clrBack, fl);
Related Functions
- WinDrawBorder
- WinDrawPointer
- WinDrawText
- WinFillRect
- WinGetSysBitmap
- WinInvertRect
- WinQueryPresParam
- WinRemovePresParam
- WinScrollWindow
- WinSetPresParam