| 发表于:2007-07-01 17:11:11 楼主 |
老师给我布置一个任务,做一个小软件,在显示图象的部分是这样要求的,打开一个从硬盘里打开一个*.bmp文件,然后显示.但是要用内存映射文件. 在打开位图文件我写了两个函数,一个是 handle readdibfile(handle hfile)就是把dib读入内存里, 一个是handle loaddib(lpctstr lpfilename)从文件中装载dib(它调用上面的函数) 代码如下: handle loaddib(lpctstr lpfilename) { handle hdib; handle hfile; // set the cursor to a hourglass, in case the loading operation // takes more than a sec, the user will know what 's going on. setcursor(loadcursor(null, idc_wait)); if ((hfile = createfile(lpfilename, generic_read, file_share_read, null, open_existing, file_attribute_normal ¦ file_flag_sequential_scan, null)) != invalid_handle_value) { hdib = readdibfile(hfile); closehandle(hfile); setcursor(loadcursor(null, idc_arrow)); return hdib; } else { setcursor(loadcursor(null, idc_arrow)); return null; } } 然后在cprcdoc中重载bool cshowdibdoc::onopendocument(lpctstr lpszpathname) { if (!cdocument::onopendocument(lpszpathname)) return false; m_hdib = loaddib(lpszpathname); if (m_hdib == null) { // may not be dib format return false; } setpathname(lpszpathname); setmodifiedflag(false); // start off with unmodified return true; }实现打开一个位图文件 但是这是不用内存映射, 我要是用到内存映射文件,那么怎么办呢 我知道内存映射的那几个函数,但是我不知道该怎么用,不知道该在什么位置用. 主要是没有接触过内存映射文件. 帮忙谢谢 |
|
|
|
|