游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1741|回复: 2

请教有观位图透明色的问题(位图资源是1945)?

[复制链接]

11

主题

33

帖子

36

积分

注册会员

Rank: 2

积分
36
发表于 2004-3-19 13:50:00 | 显示全部楼层 |阅读模式
LPDIRECTDRAWSURFACE4 DDraw_Create_Surface(int width, int height, int mem_flags, int color_key = 0)
{
// this function creates an offscreen plain surface

DDSURFACEDESC2 ddsd;         // working description
LPDIRECTDRAWSURFACE4 lpdds;  // temporary surface
   
// set to access caps, width, and height
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize  = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CKSRCBLT;

// set dimensions of the new bitmap surface
ddsd.dwWidth  =  width;
ddsd.dwHeight =  height;

// set surface to offscreen plain
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | mem_flags;

// create the surface
if (FAILED(lpdd->CreateSurface(&ddsd,&lpdds,NULL)))
   return(NULL);

// test if user wants a color key
if (color_key >= 0)
   {
   // set color key to color 0
   DDCOLORKEY color_key; // used to set color key
   color_key.dwColorSpaceLowValue  = RGB (0, 0, 191);
   color_key.dwColorSpaceHighValue = RGB (0, 0, 191);
   //想去掉1945位图的那个蓝色背景色这样对吗?
   // now set the color key for source blitting
   lpdds->SetColorKey(DDCKEY_SRCBLT, &color_key);
   } // end if

// return surface
return(lpdds);
} // end DDraw_Create_Surface

11

主题

33

帖子

36

积分

注册会员

Rank: 2

积分
36
 楼主| 发表于 2004-3-19 18:30:00 | 显示全部楼层

Re: 请教有观位图透明色的问题(位图资源是1945)?

为什么我的贴子没人回答?请高手帮帮忙。(先谢谢了)
补充以上代码。dest是主缓冲区面的。
dest->Blt(&dest_rect, source,
                     &source_rect,(DDBLT_WAIT | DDBLT_KEYSRC),
                     NULL)

30

主题

298

帖子

299

积分

中级会员

Rank: 3Rank: 3

积分
299
QQ
发表于 2004-3-19 23:03:00 | 显示全部楼层

Re:请教有观位图透明色的问题(位图资源是1945)?

你的代码并没有什么问题。只是在设置COLORKEY的时候需要注意在不同的色深下的COLORKEY的转换就可以了。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-29 10:58

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表