2024年6月11日发(作者:)

修改驱动让DDRAW支持ColorKey

刘启明

2010-1-26

DirectDraw是DirectX应用程序编程接口(API)的一个部件.它使

得你可以直接地对显存操作,

硬件位图映射(hardware blitter).支

持硬件覆盖及

换页技术(flipping surface). DirectDraw 提供这些

功能的同时保证了对现有基于 Microsoft Windows 的应用程序及设

备驱动程序的兼容.

DirectDraw 为你提供了一个直接访问显示设备的软件接口,并

同时保证了与 Windows 图形设备接口(GDI)的兼容. DirectDraw 并

不是一种高层的图形程序编程接口(API).它为游戏和 Windows 子系

统软件,例如 3D 图形包和数字视频

编码(codecs),提供了一种设备

无关的路径,以获得访问特定的显示设备的某些高级特性的能力。

应用在使用DirectDraw时,首先会通过DirectDrawCreate()函

数调用驱动中的buildDDHALInfo()函数,在6410驱动中在如下路径:

D:WINCE600PLATFORMSMDK6410SRCDRIVERSDISPLA

YDISPLAY_DRV

.

其目的就是查看底层驱动所支持的硬件属性。在驱动不支持时通

过上层强行调用该属性,执行UpdateOverlay()函数时将会报错。该

函数会通过API调用驱动中的HalUpdateOverlay()函数,在6410驱

动中在如下路径:

D:WINCE600PLATFORMSMDK6410SRCDRIVERSDISPLA

YDISPLAY_DRV

.

三星提供的默认显示驱动无法实现通过DirectDraw调用

ColorKey,需做如下修改:

一:修改文件中的buildDDHALInfo()函数,修改后

的代码如下(蓝色为修改部分):

lpddhi->layCaps =

DDOVERLAYCAPS_FLIP | // Supports surface flipping with overlays.

DDOVERLAYCAPS_FOURCC | // Supports FOURCC pixel formats with overlays.

Use IDirectDraw::GetFourCCCodes to determine which FOURCC formats are supported.

//DDOVERLAYCAPS_ZORDER | // Supports changing Z order of overlays.

//DDOVERLAYCAPS_MIRRORLEFTRIGHT | // Supports surface mirroring in the

left-to-right direction for overlays.

//DDOVERLAYCAPS_MIRRORUPDOWN | // Supports surface mirroring in the up-to-down

direction for overlays.

DDOVERLAYCAPS_CKEYSRC | // Supports source color keying for overlays.

//DDOVERLAYCAPS_CKEYSRCCLRSPACE | // Supports source color-space keying for overlays.

//DDOVERLAYCAPS_CKEYSRCCLRSPACEYUV | // Supports source color-space keying for

overlays with FOURCC pixel formats.

DDOVERLAYCAPS_CKEYDEST | // Supports destination color keying for

overlays.

//DDOVERLAYCAPS_CKEYDESTCLRSPACE | // Supports destination colo-space keying for

overlays.

//DDOVERLAYCAPS_CKEYDESTCLRSPACEYUV |// Supports destination color-space keying for

overlays with FOURCC pixel formats.

//DDOVERLAYCAPS_CKEYBOTH | // Supports simultaneous source and destination

color keying for overlays.

//DDOVERLAYCAPS_ALPHADEST | // Supports destination alpha blending for

overlays.

DDOVERLAYCAPS_ALPHASRC | // Supports source alpha blending for overlays.

//DDOVERLAYCAPS_ALPHADESTNEG | // Supports inverted destination alpha blending for

overlays.

//DDOVERLAYCAPS_ALPHASRCNEG | // Supports inverted source alpha blending for

overlays.