第16月第6天 vs2005 lseek directdraw
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的更多相关文章
- 第3月第11天 vs2005调试 ace编译
1.vs2005调试 http://blog.csdn.net/u010797208/article/details/40452797 2.macbook ace编译 小坑: 源代码clockid_t ...
- 第16月第31天 mongo
1. 94 brew install mongodb 95 cd ~ 96 cd Desktop/web/ 97 ls 98 mkdir mongo 99 cd mongo/ 100 ...
- 第16月第27天 pip install virtualenv ipython sip brew search
1. pip install virtualenv virtualenv testvir cd testvir cd Scripts activate pip https://zhuanlan.zhi ...
- 第16月第26天 /bin/bash^M: bad interpreter: 没有那个文件或目录
1. 运行脚本时出现了这样一个错误,打开之后并没有找到所谓的^M,查了之后才知道原来是文件格式的问题,也就是linux和windows之间的不完全兼容...具体细节不管,如果验证: vim test. ...
- 第16月第25天 tableView设置UITableViewStyleGrouped顶部有空余高度
1. 正确的处理方法 1)设置标头的高度为特小值 (不能为零 为零的话苹果会取默认值就无法消除头部间距了) UIView *view = [[UIView alloc]initWithFrame:CG ...
- 第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 ...
- 第16月第23天 atos
1. grep --after-context=2 "Binary Images:" *crash xcrun atos -o zhiniao_adhoc_stg1.app.dSY ...
- 第16月第17天 contentMode
1. self.contentMode = UIViewContentModeScaleAspectFill; self.clipsToBounds = YES; http://blog.csdn.n ...
- 第16月第15天 glut
1. https://tokoik.github.io/opengl/libglut.html https://github.com/wistaria/wxtest/tree/master/C htt ...
随机推荐
- 为Bootstrap模态对话框添加拖拽移动功能
请自行下载使用到的Bootstrap库及jQuery库 <!DOCTYPE html> <html> <head lang="en"> < ...
- codeforces369A
Valera and Plates CodeForces - 369A Valera is a lazy student. He has m clean bowls and k clean plate ...
- golang的interface剖析
背景: golang的interface是一种satisfied式的.A类只要实现了IA interface定义的方法,A就satisfied了接口IA.更抽象一层,如果某些设计上需要一些更抽象的 ...
- BUPT2017 wintertraining(15) #3 题解
我觉得好多套路我都不会ヘ(;´Д`ヘ) 题解拖到情人节后一天才完成,还有三场没补完,真想打死自己.( ˙-˙ ) A - 温泉旅店 UESTC - 878 题意 有n张牌,两人都可以从中拿出任意 ...
- [luogu4264][USACO18FEB]Teleportation
题解 先吐槽一波题目:便便传送门,出题人还真的有一点厉害的滑稽. 废话不多说. 首先问题的本质就是求如果当这个传送门的端点位于\(y\)的时候,最小的求出总代价,我们设为函数\(f(y)\). 因为这 ...
- 【转】IAR for STM8介绍、下载、安装与注册
Ⅰ.写在前面 本文讲述的内容是IAR for STM8(EWSTM8)的介绍.下载.安装与注册,其安装.注册过程和IAR for ARM类似,如果需要了解IAR for ARM相关的文章,可以到我博客 ...
- nowcoder172C 保护 (倍增lca+dfs序+主席树)
https://www.nowcoder.com/acm/contest/172/C (sbw大佬太强啦 orz) 先把每一个路径(x,y)分成(x,lca),(y,lca)两个路径,然后就能发现,对 ...
- 【更新】搭建 Zookeeper-3.4.11 集群
先准备好三台linux(虚拟机). 1. 先把Java环境配好.我CentOS-7-x86_64-DVD-1708 + jdk1.8.0_161 1.1 先把jdk上传到系统里面(我利用的Filezi ...
- 在kubernetes中运行单节点有状态MySQL应用
Deploy MySQL https://kubernetes.io/docs/tasks/run-application/run-single-instance-stateful-applicati ...
- 安装Cloudera manager Server步骤详解
安装Cloudera manager Server步骤详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客主要是针对:https://www.cnblogs.com/yin ...