游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1216|回复: 0

DDRAW问题 请高手看看 拜托了

[复制链接]

27

主题

79

帖子

87

积分

注册会员

Rank: 2

积分
87
发表于 2004-7-21 10:29:00 | 显示全部楼层 |阅读模式
我有一幅大24位位图  256×512  里面是人物8个方向每个方向4帧动作
第一帧和第三帧动作是一样的
我建了个 64×64 的离屏表面数组(3×8个图片 重复的第三帧没有)
然后我先想BLT一个FLIP一下第一个小图片
发现只有人的帽子显示出来了 其他小图片都是这种情形
我感觉定位不会有错 请看看定位哪有错?
int Scan_Image_Bitmap(BITMAP_FILE bitmap,                          LPDIRECTDRAWSURFACE7 lpdds, // surface to hold data
                      int cx,int cy)             // cell to scan image from
{
DDSURFACEDESC2 ddsd;  
ddsd.dwSize = sizeof(ddsd);
lpdds->Lock(NULL,
            &ddsd,
            DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
            NULL);
dest_ptr = (UCHAR *)ddsd.lpSurface;
DWORD * dest_ptr = (DWORD *)ddsd.lpSurface;      
if(cy==0|cy==1)
{
for (int index_y = 0; index_y <64; index_y++)
    {
    for (int index_x = 0; index_x <64; index_x++)
        { DWORD blue  = (bitmap.buffer[cx*64*256*3 + cy*64*3 + index_y*64*3 + index_x*3 + 0]),
              green = (bitmap.buffer[cx*64*256*3 + cy*64*3 + index_y*64*3 + index_x*3 + 1]),
              red   = (bitmap.buffer[cx*64*256*3 + cy*64*3 + index_y*64*3 + index_x*3 + 2]);
        DWORD pixel = _RGB32BIT(0,red,green,blue);
dest_ptr[index_x + (index_y*ddsd.lPitch>>2)] = pixel;}}}
//如果是2 表明是原来图上第四列 第三列重复不要跳过所以(cy+1)*64*3
if(cy==2)
{
for (int index_y = 0; index_y <64; index_y++)
    {
    for (int index_x = 0; index_x <64; index_x++)
        { DWORD blue  = (bitmap.buffer[cx*64*256*3 + (cy+1)*64*3 + index_y*64*3 + index_x*3 + 0]),
              green = (bitmap.buffer[cx*64*256*3 +( cy+1)*64*3 + index_y*64*3 + index_x*3 + 1]),
              red   = (bitmap.buffer[cx*64*256*3 + (cy+1)*64*3 + index_y*64*3 + index_x*3 + 2]);
        DWORD pixel = _RGB32BIT(0,red,green,blue);
dest_ptr[index_x + (index_y*ddsd.lPitch>>2)] = pixel;}}


}

lpdds->Unlock(NULL);
return(1);
} // end Scan_Image_Bitmap

.....
//some where in the mainloop
if (!Load_Bitmap_File(&bitmap,"sprite.bmp"))  return(0);
for (int index1=0;index1<8;index1++)
{
for (int index =0;index<3;index++)
{
aliens[index1].frames[index] = DDraw_Create_Surface(64,64,0,1);//建立离屏表面
Scan_Image_Bitmap(bitmap,                 
                                        // bitmap file to scan image data from
               aliens[index1].frames[index], // surface to hold data
               index1,index);               // cell to scan image from   
}
}
//aliens.frames[j] 第i层  第j个小图像要摆放的页面 i:0~7  j:0~2 spite.bmp是大图片保存在bitmap中 传递参数index1 为层数 index为所在层的第几个

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-7-3 23:59

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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