第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 ...
随机推荐
- 【Mysql】—— 索引的分类
注意:索引是在存储引擎中实现的,也就是说不同的存储引擎,会使用不同的索引.MyISAM和InnoDB存储引擎:只支持BTREE索引,也就是说默认使用BTREE,不能够更换.MEMORY/HEAP存储引 ...
- appium学习记录1
xpath定位: 语法 driver.find_element_by_xpath("//android.widget.EditText[@index="登陆"/../pr ...
- java List 根据属性排序
Collections.sort(fileItems, new Comparator<FileItem>() { public int compare(FileItem arg0, Fil ...
- HDU-2087-KMP-水题
纯KMP #include <cstdio> #include <algorithm> #include <cstring> #include <ctype. ...
- matplotlib极坐标方法详解
一.极坐标 在平面内取一个定点O,叫极点,引一条射线Ox,叫做极轴,再选定一个长度单位和角度的正方向(通常取逆时针方向).对于平面内任何一点M,用ρ表示线段OM的长度(有时也用r表示),θ表示从Ox到 ...
- 洛谷 P1691 有重复元素的排列问题 解题报告
P1691 有重复元素的排列问题 题目描述 设\(R={r_1,r_2,--,r_n}\)是要进行排列的\(n\)个元素.其中元素\(r_1,r_2,--,r_n\)可能相同.使设计一个算法,列出\( ...
- 安装Prometheus-Opeartor
一.下载git clone clone https://github.com/coreos/prometheus-operator.git或:wget https://github.com/coreo ...
- c++11 条件变量 生产者-消费者 并发线程
http://baptiste-wicht.com/posts/2012/04/c11-concurrency-tutorial-advanced-locking-and-condition-vari ...
- Python基础-简介一
一.Python介绍 1. Python的应用领域及流行程度 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间, ...
- 迭代器_iter_,生成器yeild,三元运算,列表解析(十三)
迭代器: l = [1, 2, 3, 4] iter = l.__iter__() print(iter) print(iter.__next__()) print(iter.__next__()) ...