1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
The blit classes
----------------
This example contains classes which implement fast blits using the
CDIB framework. A short description follows.
The blit classes allow output of 32-bit DIBs. They support scaling,
varying opacity, and a full 8-bit alpha channel. The class hierarchy
is as follows (CObject and CObArray are MFC classes):
CObject
|
----------------------------
| |
CGrItem CObArray
| |
----------------- ----
| | |
CDIBGrItem CShadowItem CGrItemArray
Sample code which blits several bitmaps:
#include "grarray.h"
#include "dibgrit.h"
CDIB Canvas;
void UpdateCanvas
( CRect * pUpdateRect
)
{
CGrItemArray GrArray;
CDIBGrItem * pDIBItem;
for (i=0; i<NumberOfDIBs; i++)
{
pDIBItem = new CDIBGrItem (...);
GrArray.AddItem (pDIBItem);
}
GrArray.Draw (&Canvas, pUpdateRect);
}
The constructor of CDIBGrItem needs a bitmap and its position, size,
position in z-order, and opacity. The drawing order used by the
Draw() function is in ascending z position. The blit functions are
optimized to recognize special cases, so blitting without resizing
and/or without using opacity is considerably faster.
In addition to CDIBGrItems, you can also insert CShadowItems into the
array. These objects represent areas where the background is tinted
with a color. CShadowItems can use alpha channel and opacity
information.
Blits with only one source bitmap can be accomplished by simply
calling DrawOnDIB().
Ulrich von Zadow, 2/8/1997
|