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. C++ 日期时间使用

    #include <time.h> #include <stdio.h> #include <iostream> #include <string> # ...

  2. BZOJ2223[Coci 2009]PATULJCI——主席树

    题目描述 输入  先输入一个数n,然后一个数表示这n个数中最大的是多少,接下来一行n个数.然后一个数m,最后m行询问每次两个数l,r. 输出 no或者yes+这个数 样例输入 10 3 1 2 1 2 ...

  3. BZOJ2724 [Violet]蒲公英(分块)

    区间众数.分块,预处理任意两块间所有数的众数,和每块中所有数的出现次数的前缀和.查询时对不是整块的部分暴力,显然只有这里出现的数可能更新答案.于是可以优美地做到O(n√n). #include< ...

  4. BZOJ4870 [六省联考2017] 组合数问题 【快速幂】

    题目分析: 构造f[nk][r]表示题目中要求的东西.容易发现递推公式f[nk][r]=f[nk-1][r]+f[nk-1][(r-1)%k].矩阵快速幂可以优化,时间复杂度O(k^3logn). 代 ...

  5. Java 8 的 Metaspace

    Java 8 的 Metaspace https://www.cnblogs.com/xrq730/p/8688203.html 被废弃的持久代 想起之前面试的时候有面试官问起过我一个问题:Java ...

  6. startSSL 申请免费的SSL证书

    打开网址https://www.startssl.com/?app=12,选择Sign-up注册. 输入个人注册信息 需注意以下几点:(1)地址必须详细,否则你会收到这样的邮件: Please pro ...

  7. 自学Linux Shell7.3-linux共享文件

    点击返回 自学Linux命令行与Shell脚本之路 7.3-linux共享文件 在linux系统中共享文件的方法是通过创建组. 1. linux为每个文件和目录存储了3个额外的信息位: SUID设置用 ...

  8. 洛谷 画栅栏Painting the Fence 解题报告

    P2205 画栅栏Painting the Fence 题目描述 \(Farmer\) \(John\) 想出了一个给牛棚旁的长围墙涂色的好方法.(为了简单起见,我们把围墙看做一维的数轴,每一个单位长 ...

  9. 11:SSM框架下各个层的解释说明

    具体见网址:http://blog.csdn.net/lutianfeiml/article/details/51864160

  10. c++11并发之std::thread

    知识链接: https://www.cnblogs.com/lidabo/p/7852033.html 构造函数如下: ) thread() noexcept; initialization() te ...