游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1752|回复: 4

新手在看Windows游戏编程大师技巧(第二版)时遇到的问题

[复制链接]

13

主题

24

帖子

24

积分

注册会员

Rank: 2

积分
24
发表于 2004-8-25 16:34:00 | 显示全部楼层 |阅读模式
新手正在看Windows游戏编程大师技巧(第二版)学游戏编程,看到第7章想把演示程序demo7_13.cpp改成在24位模式下运行,可总是不行,估计那个Scan_Image_Bitmap函数改的有问题,希望有看过此书的高手给予帮助,谢谢

6

主题

26

帖子

26

积分

注册会员

Rank: 2

积分
26
发表于 2004-8-26 02:14:00 | 显示全部楼层

Re:新手在看Windows游戏编程大师技巧(第二版)时遇到的问

给个代码我看看

33

主题

445

帖子

446

积分

中级会员

Rank: 3Rank: 3

积分
446
发表于 2004-8-26 02:34:00 | 显示全部楼层

Re:新手在看Windows游戏编程大师技巧(第二版)时遇到的问

没看过,没有发言权

13

主题

24

帖子

24

积分

注册会员

Rank: 2

积分
24
 楼主| 发表于 2004-8-26 10:50:00 | 显示全部楼层

Re:新手在看Windows游戏编程大师技巧(第二版)时遇到的问

书中代码好象已经有人传到ftp上了,以下是Scan_Image_Bitmap函数的代码
int Scan_Image_Bitmap(BITMAP_FILE_PTR bitmap,     // bitmap file to scan image data from
                      LPDIRECTDRAWSURFACE7 lpdds, // surface to hold data
                      int cx, int cy)             // cell to scan image from
{
// this function extracts a bitmap out of a bitmap file

UCHAR *source_ptr,   // working pointers
      *dest_ptr;

DDSURFACEDESC2 ddsd;  //  direct draw surface description

// get the addr to destination surface memory

// set size of the structure
ddsd.dwSize = sizeof(ddsd);

// lock the display surface
lpdds->Lock(NULL,
            &ddsd,
            DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
            NULL);

// compute position to start scanning bits from
cx = cx*(ddsd.dwWidth+1) + 1;
cy = cy*(ddsd.dwHeight+1) + 1;

gwidth  = ddsd.dwWidth;
gheight = ddsd.dwHeight;

// extract bitmap data
source_ptr = bitmap->buffer + cy*bitmap->bitmapinfoheader.biWidth+cx;

// assign a pointer to the memory surface for manipulation
dest_ptr = (UCHAR *)ddsd.lpSurface;

// iterate thru each scanline and copy bitmap
for (int index_y=0; index_y < ddsd.dwHeight; index_y++)
    {
    // copy next line of data to destination
    memcpy(dest_ptr, source_ptr, ddsd.dwWidth);

    // advance pointers
    dest_ptr   += (ddsd.lPitch); // (ddsd.dwWidth);
    source_ptr += bitmap->bitmapinfoheader.biWidth;
    } // end for index_y

// unlock the surface
lpdds->Unlock(NULL);

// return success
return(1);

} // end Scan_Image_Bitmap

36

主题

382

帖子

498

积分

中级会员

Rank: 3Rank: 3

积分
498
发表于 2004-8-26 12:30:00 | 显示全部楼层

Re:新手在看Windows游戏编程大师技巧(第二版)时遇到的问

有的显卡不支持24位
记得好像mx440不支持,
可能还有别的的说
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-8-17 17:05

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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