Device-Dependent Bitmaps

特别声明:部分文章为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!

摘要:Device-dependent bitmaps (DDBs...

Device-dependent bitmaps (DDBs) are described by using a single structure, the BITMAP structure. The members of this structure specify the width and height of a rectangular region, in pixels; the width of the array that maps entries from the device palette to pixels; and the device's color format, in terms of color planes and bits per pixel. An application can retrieve the color format of a device by calling the GetDeviceCaps function and specifying the appropriate constants. Note that a DDB does not contain color values; instead, the colors are in a device-dependent format. For more information, see Color in Bitmaps. Because each device can have its own set of colors, a DDB created for one device may not display well on a different device.

To use a DDB in a device context, it must have the color organization of that device context. Thus, a DDB is often called a compatible bitmap and it usually has better GDI performance than a DIB. For example, to create a bitmap for video memory, it is best to use a compatible bitmap with the same color format as the primary display. Once in video memory, rendering to the bitmap and displaying it to the screen are significantly faster than from a system memory surface or directly from a DIB.

In addition to enabling better GDI performance, compatible bitmaps are used to capture images (see Capturing an Image ) and to create bitmaps at run time for menus see "Creating the Bitmap" in (see Using Menus ).

To transfer a bitmap between devices with different color organization, use GetDIBits to convert the compatible bitmap to a DIB and call SetDIBits or StretchDIBits to display the DIB to the second device.

There are two types of DDBs: discardable and nondiscardable. A discardable DDB is a bitmap that the system discards if the bitmap is not selected into a DC and if system memory is low. The CreateDiscardableBitmap function creates discardable bitmaps. The CreateBitmapCreateCompatibleBitmap, and CreateBitmapIndirect functions create nondiscardable bitmaps.

An application can create a DDB from a DIB by initializing the required structures and calling the CreateDIBitmap function. Specifying CBM_INIT in the call to CreateDIBitmap is equivalent to calling the CreateCompatibleBitmap function to create a DDB in the format of the device and then calling the SetDIBits function to translate the DIB bits to the DDB. To determine whether a device supports the SetDIBits function, call the GetDeviceCaps function, specifying RC_DI_BITMAP as the RASTERCAPS flag.

未经允许不得转载:作者:吾爱网络, 转载或复制请以 超链接形式 并注明出处 吾爱博客
原文地址:《Device-Dependent Bitmaps》 发布于2018-11-15

分享到:
赞(0) 打赏

评论 抢沙发

6 + 2 =


觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

Vieu3.3主题
专业打造轻量级个人企业风格博客主题!专注于前端开发,全站响应式布局自适应模板。
切换注册

登录

忘记密码 ?

切换登录

注册