|
Compatible Device Contexts
To enable applications to place output in memory rather than sending it to an
actual device, the Win32 API provides a special device context for bitmap
operations called a compatible device context. A compatible DC enables Windows to treat a portion of memory as a virtual
device. It is an array of bits in memory that an application can use temporarily
to store the color data for bitmaps created on a normal drawing surface.
An application creates a compatible DC by calling the CreateCompatibleDC function and receives a handle that identifies a normal device context.
Windows creates a temporary one-bit placeholder for the array. Before performing
drawing operations using the compatible DC handle, the application must increase
the size of this array. To do this, the application can call the CreateBitmap, CreateBitmapIndirect, or CreateCompatibleBitmap function to create a bitmap of the appropriate dimensions and then call the SelectObject function to select the bitmap into the DC. After the bitmap is selected into
the compatible DC, Windows replaces the single-bit array with an array large
enough to store color information for the specified rectangle of pixels.
When an application passes the handle returned by CreateCompatibleDC to one of the GDI drawing functions, the requested output does not appear on
a device's drawing surface. Instead, Windows stores the color information for
the resultant line, curve, text or region in the array of bits. The application
can copy the image stored in memory back onto a drawing surface by calling the BitBlt function, identifying the compatible DC as the source device context and a
window or screen DC as the target device context.
When displaying a DIB or a DDB created from a DIB on a palette device, you can
improve the speed at which the image is drawn by arranging the logical palette
to match the layout of the system palette. To do this, call GetDeviceCaps with the NUMRESERVED value to get the number of reserved colors in the
system. Then call GetSystemPaletteEntries and fill in the first and last NUMRESERVED/2 entries of the logical palette
with the corresponding system colors. For example, if NUMRESERVED is 20, you
would fill in the first and last 10 entries of the logical palette with the system
colors. Then fill in the remaining 256 NUMRESERVED colors of the logical palette (in our example, the remaining 236
colors) with colors from the DIB and set the PC_NOCOLLAPSE flag on each of
these colors. For more information about color and palettes, see Colors.
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|