BMP文件的相关操作
来源:互联网 发布:房地产研究数据库 编辑:程序博客网 时间:2024/06/08 05:07
// write out a BMP file,DirectShow中例子截取的 //m_szSnappedName 要生成的BMP文件名字//pBuffer BMP数据 HANDLE hf = CreateFile( m_szSnappedName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL ); if( hf == INVALID_HANDLE_VALUE ) return 0; // write out the file header // BITMAPFILEHEADER bfh; memset( &bfh, 0, sizeof( bfh ) ); bfh.bfType = 'MB'; bfh.bfSize = sizeof( bfh ) + lBufferSize + sizeof( BITMAPINFOHEADER ); bfh.bfOffBits = sizeof( BITMAPINFOHEADER ) + sizeof( BITMAPFILEHEADER ); DWORD dwWritten = 0; WriteFile( hf, &bfh, sizeof( bfh ), &dwWritten, NULL ); // and the bitmap format // BITMAPINFOHEADER bih; memset( &bih, 0, sizeof( bih ) ); bih.biSize = sizeof( bih ); bih.biWidth = lWidth; bih.biHeight = lHeight; bih.biPlanes = 1; bih.biBitCount = 24; dwWritten = 0; WriteFile( hf, &bih, sizeof( bih ), &dwWritten, NULL ); // and the bits themselves // dwWritten = 0; WriteFile( hf, pBuffer, lBufferSize, &dwWritten, NULL ); CloseHandle( hf ); bFileWritten = TRUE; // Display the bitmap bits on the dialog's preview window//显示,下面代码有该函数的定义 DisplayCapturedBits(pBuffer, &bih);
//如果要防止重绘时图片被擦除,可以在OnPaint函数中在调用一次这个函数 BOOL DisplayCapturedBits(BYTE *pBuffer, BITMAPINFOHEADER *pbih) { // If we haven't yet snapped a still, return if (/*!bFileWritten || !pOwner ||*/ !pBuffer) return FALSE; // put bits into the preview window with StretchDIBits // HWND hwndStill = NULL; pOwner->GetDlgItem( IDC_STILL, &hwndStill );//IDC_STILL显示图片的控件ID RECT rc; ::GetWindowRect( hwndStill, &rc ); long lStillWidth = rc.right - rc.left; long lStillHeight = rc.bottom - rc.top; HDC hdcStill = GetDC( hwndStill ); PAINTSTRUCT ps; BeginPaint(hwndStill, &ps); SetStretchBltMode(hdcStill, COLORONCOLOR); StretchDIBits( hdcStill, 0, 0, lStillWidth, lStillHeight, 0, 0, lWidth, lHeight, pBuffer, (BITMAPINFO*) pbih, DIB_RGB_COLORS, SRCCOPY ); EndPaint(hwndStill, &ps); ReleaseDC( hwndStill, hdcStill ); return TRUE; }
0 0
- BMP文件的相关操作
- TC下对BMP文件的操作
- bmp文件操作
- BMP文件像素操作
- C++操作BMP文件
- 文件的相关操作
- 文件的相关操作
- C++ bmp文件读写操作
- BMP文件结构读写操作
- BMP文件操作C语言
- 在VC中自建操作BMP位图文件的类
- 在VC中自建操作BMP位图文件的类
- 在VC中自建操作BMP位图文件的类
- bmp图片文件的操作 旋转、翻转、放大缩小
- OpenGL入门学习[十]OpenGL的像素操作、BMP文件
- bmp图片文件的操作 旋转、翻转、放大缩小
- <MFC笔记>BMP位图文件的格式及其操作
- bmp文件的数据格式
- -------------SQL SERVER与DB2统计信息与索引碎片整理---------------
- eclipse去除所有调试断点
- 禅道安装详解
- 第二章 吸引你的眼球—UI编程(4)
- 我的ubuntu之旅(搜狗输入法的安装)
- BMP文件的相关操作
- JAVA 获取当前时间
- make -C M=
- python错误汇总3:libxslt/xsltconfig.h:没有那个文件或目录
- SQL LIKE
- test
- HashMap报错原因
- Android开发环境搭建(Eclipse4.2)
- SSH免密码登录