1.

//_lseek(file_handle, -(int)pbitmap->bitmapinfoheader.biSizeImage, SEEK_END);
SetFilePointer((HANDLE)file_handle, -(int)(pbitmap->bitmapinfoheader.biSizeImage), NULL, FILE_END);

http://bbs.csdn.net/topics/270065223

http://blog.csdn.net/aloneone/article/details/21245443

2.

windows游戏编程大师基本都是使用DIRECTDRAW全屏,8位模式。

读BMP文件存放到自定义的机构体,那么显示图片时就是进行内存拷贝了。而window api基本讲的都是DC。

typedef struct BITMAP_FILE_TAG
{
BITMAPFILEHEADER bitmapfileheader; // this contains the bitmapfile header
BITMAPINFOHEADER bitmapinfoheader; // this is all the info including the palette
PALETTEENTRY palette[]; // we will store the palette here
UCHAR *buffer; // this is a pointer to the data } BITMAP_FILE, *BITMAP_FILE_PTR; int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename)
。。。

DEMO7_12.CPP 24-bit bitmap loading demo

bitmap是24位,lpddsprimary是32位,将bitmap的一个像素点(占3位),放到DWORD(占4位),拷贝到primary_buffer。就可以显示图片了。

#define SCREEN_BPP      32   // bits per pixel
// process each line and copy it into the primary buffer
for (int index_y = ; index_y < SCREEN_HEIGHT; index_y++)
{
for (int index_x = ; index_x < SCREEN_WIDTH; index_x++)
{
// get BGR values
UCHAR blue = (bitmap.buffer[index_y*SCREEN_WIDTH* + index_x* + ]),
green = (bitmap.buffer[index_y*SCREEN_WIDTH* + index_x* + ]),
red = (bitmap.buffer[index_y*SCREEN_WIDTH* + index_x* + ]); // this builds a 32 bit color value in A.8.8.8 format (8-bit alpha mode)
DWORD pixel = _RGB32BIT(,red,green,blue); // write the pixel
primary_buffer[index_x + (index_y*ddsd.lPitch >> )] = pixel; } // end for index_x } // end for index_y

windows dc

BOOL CDDraw::LoadBMPSurface(LPDIRECTDRAWSURFACE7 &lpSurf,  //要载入图像的表面指针
LPCSTR BitmapFile )//源图像的路径
{
HDC hdcImage;
HDC hdc;
HBITMAP hbm;
BITMAP bm;
HRESULT ddrval; if( lpSurf == NULL )
return FALSE;
// 将位图作为文件来读取
hbm = (HBITMAP)LoadImage(NULL,
BitmapFile,
IMAGE_BITMAP,
, ,
LR_LOADFROMFILE |
LR_CREATEDIBSECTION);
if (hbm == NULL){
//载入图像失败时进到这里来
//在这里可以记录载入图像失败的信息
return FALSE;
}
//函数功能:创建一个与指定设备兼容的内存设备上下文环境(Device Context)
//创建一个与应用程序的当前显示器兼容的内存设备上下文环境
hdcImage = CreateCompatibleDC(NULL);
if (!hdcImage){
//创建设备上下文出错
return FALSE;
}
//选择位图对象到刚刚创建的内存设备上下文环境(DC)
SelectObject(hdcImage, hbm); //获取位图宽与高
GetObject(hbm, sizeof(bm), &bm); //获取表面的宽与高
DDSURFACEDESC2 ddsd;
ddsd.dwSize = sizeof(ddsd);
lpSurf->GetSurfaceDesc(&ddsd);
if( BitmapFile!=NULL )
{
if ((ddrval = lpSurf->GetDC(&hdc)) == DD_OK)
{
//将源位图复制到表面,可以进行拉伸或收缩
StretchBlt( hdc,
, , ddsd.dwWidth, ddsd.dwHeight,
hdcImage,
, , bm.bmWidth, bm.bmHeight,
SRCCOPY);
lpSurf->ReleaseDC(hdc);
}
} DeleteDC(hdcImage); if( ddrval != DD_OK ) {
//复制矩形块失败
return FALSE;
} return TRUE;
}

第16月第6天 vs2005 lseek directdraw的更多相关文章

  1. 第3月第11天 vs2005调试 ace编译

    1.vs2005调试 http://blog.csdn.net/u010797208/article/details/40452797 2.macbook ace编译 小坑: 源代码clockid_t ...

  2. 第16月第31天 mongo

    1. 94  brew install  mongodb 95  cd ~ 96  cd Desktop/web/ 97  ls 98  mkdir mongo 99  cd mongo/ 100  ...

  3. 第16月第27天 pip install virtualenv ipython sip brew search

    1. pip install virtualenv virtualenv testvir cd testvir cd Scripts activate pip https://zhuanlan.zhi ...

  4. 第16月第26天 /bin/bash^M: bad interpreter: 没有那个文件或目录

    1. 运行脚本时出现了这样一个错误,打开之后并没有找到所谓的^M,查了之后才知道原来是文件格式的问题,也就是linux和windows之间的不完全兼容...具体细节不管,如果验证: vim test. ...

  5. 第16月第25天 tableView设置UITableViewStyleGrouped顶部有空余高度

    1. 正确的处理方法 1)设置标头的高度为特小值 (不能为零 为零的话苹果会取默认值就无法消除头部间距了) UIView *view = [[UIView alloc]initWithFrame:CG ...

  6. 第16月第24天 find iconv sublime utf-8

    1. find . -type f -exec echo {} \; find src -type f -exec sh -c "iconv -f GB18030 -t UTF8 {} &g ...

  7. 第16月第23天 atos

    1. grep --after-context=2 "Binary Images:" *crash xcrun atos -o zhiniao_adhoc_stg1.app.dSY ...

  8. 第16月第17天 contentMode

    1. self.contentMode = UIViewContentModeScaleAspectFill; self.clipsToBounds = YES; http://blog.csdn.n ...

  9. 第16月第15天 glut

    1. https://tokoik.github.io/opengl/libglut.html https://github.com/wistaria/wxtest/tree/master/C htt ...

随机推荐

  1. jquery 動畫

    animate({param},speed,callback)/animate({param},speed)/animate({param}) param表示css屬性:屬性名必須是camel標識法: ...

  2. 如何在Vue项目中引入jQuery?

    假设你的项目由vue-cli初始化 (e.g. vue init webpack my-project). 在你的vue项目目录下执行: npm install jquery --save-dev 打 ...

  3. 洛谷P4088 [USACO18FEB]Slingshot

    题面 大意:给出n个弹弓,可以用ti的时间把xi位置运到yi,在给出m组询问,求xj到yj最小时间. sol:首先如果不用弹弓,时间应为abs(xj-yj).否则时间就是abs(xi-xj)+abs( ...

  4. Uva1001-floyd算法-建图

    给出一些球,球内的时间为零,球之间的速度为10每单位. 给两个点,求最短时间. 把每一个球当做点,球间的距离就是floyd的d数组.之后跑一遍floyd wa了两发因为d数组定义成int了 #incl ...

  5. Json Self referencing loop detected

    Self referencing loop detected......的错误 解决方案: 1 增加  [JsonIgnore]  过滤关联,使其不参与序列化. 这个方法简单粗暴.但是你就没办法获取关 ...

  6. mysql 免安装版 启动服务马上关闭

    在my.ini 加入这一句 1.直接在后面加上一下的参数 [mysqld] port=3306 basedir=D:\mysql-5.7.17-win32 datadir=D:\mysql-5.7.1 ...

  7. servlet表单中get和post方法的区别

    Form中的get和post方法,在数据传输过程中分别对应了HTTP协议中的GET和POST方法.二者主要区别如下: 1.Get是用来从服务器上获得数据,而Post是用来向服务器上传递数据. 2.Ge ...

  8. 【POI 每日题解 #4】 [POI2008]MAF-Mafia

    [POI2008]MAF-Mafia 很容易看出是拓扑 但不容易想出来怎么做[可能是我太菜 首先 入度为零的人是肯定死不了的 接着 我们分成环和链分析 对于一个链 最多的情况就是顺着一个个开枪 最后剩 ...

  9. Leetcode 28.实现strStr() By Python

    实现 strStr() 函数. 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始).如果不存在,则返 ...

  10. 使用“DiskGenius”精确隐藏硬盘坏道

    现在大家手中可能都有些有坏道的硬盘,也可能现在机器上的硬盘也出问题了.硬盘有坏道,肯定不会全部都是坏道,不能使用了.但我们因此而不能使用了,那么就太可惜了.所以,只要把有坏道的区域隐藏起来,就如同使用 ...