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. face detection,landmark, recognition with deeplearning

    人脸特征点定位 Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Neural Networks c ...

  2. Beyond Compare 4过期

    试用期到期操作:找到beyond Compare 4文件夹下面的BCUnrar.dll,将其删掉或者重命名,再重新打开接着使用!

  3. Js 百分比进度条

    [构想] CSS3 + JS CSS3控制进度 利用CSS3中的 @keyframes JS实现百分比 根据CSS来调整,时间 [页面代码] 第一种: 默认直接进入就是下载 CSS代码 body { ...

  4. 浅析python日志重复输出问题

    浅析python日志重复输出问题 问题起源: ​ 在学习了python的函数式编程后,又接触到了logging这样一个强大的日志模块.为了减少重复代码,应该不少同学和我一样便迫不及待的写了一个自己的日 ...

  5. Food HDU - 4292 (结点容量 拆点) Dinic

    You, a part-time dining service worker in your college’s dining hall, are now confused with a new pr ...

  6. 【转】linux环境内存分配原理 malloc info

    Linux的虚拟内存管理有几个关键概念: Linux 虚拟地址空间如何分布?malloc和free是如何分配和释放内存?如何查看堆内内存的碎片情况?既然堆内内存brk和sbrk不能直接释放,为什么不全 ...

  7. suoi63 树与路径 (倍增lca)

    发现对于某一个点它向上发的一条边,它被经过的次数就是这个点子树数量*不是它子树的数量 那就维护一个前缀和,然后每次拿两个端点和它们的lca的值加一加减一减,再乘上加上的值,就是这次修改后答案的增量 ( ...

  8. 【翻译】go memory model

    https://studygolang.com/articles/819 原文链接 Introduction The Go memory model specifies the conditions ...

  9. 面试 -- fragment生命周期

    Android 3.0 (Api 11)引入: Fragment具有重用,易适配(平板和手机之间的)优点: 依赖Activity,生命周期受到Activity的生命周期影响: fragment生命周期 ...

  10. ECMAScript 6 -- let和const命令

    ES6新增了let命令,用来声明变量.它的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效. for (let i = 0; i ; i++) {console.log(i);} ...