最近一直困扰我的问题
来源:互联网 发布:计算机算法流程图 编辑:程序博客网 时间:2024/05/01 15:00
在vc2005中做在对话框中显示bmp图像的程序,以下是源码:有些大的图像只能显示下面1/3,而用mfc 的CFile 和C语言的FILE都没有问题不知道怎么回事,现在不敢用STL的流了。
//全局变量
BITMAPFILEHEADER header;
BITMAPINFOHEADER infoheader;
ifstream inf;
int iLineByteCnt ;
int m_iImageDataSize;
int m_iImageWidth;
int m_iImageHeight;
int m_iBitsPerPixel;
char* m_pImageData;
char*pDib;
//文件处理函数
void CBMPDlg::OnBnClickedButton1()
{
inf.open("E://yang.bmp");
memset(&header, 0, sizeof(header));
inf.read((char*)&header, sizeof(header));
if(header.bfType != 0x4D42)
return ;
BITMAPINFOHEADER *infoheader;
pDib=new char[ header.bfSize-sizeof(header)];
inf.read(pDib, header.bfSize-sizeof(header));
infoheader=(BITMAPINFOHEADER*)pDib;//关于语法
m_iImageWidth = infoheader->biWidth;
m_iImageHeight = infoheader->biHeight;
m_iBitsPerPixel = infoheader->biBitCount;
iLineByteCnt =(((m_iImageWidth*m_iBitsPerPixel) + 31) >> 5) < < 2;
m_iImageDataSize = header.bfSize-header.bfOffBits;
iLineByteCnt=m_iImageDataSize/m_iImageHeight;
if(m_pImageData) delete []m_pImageData;
m_pImageData =pDib+infoheader->biSize;
inf.close();
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
bmi.bmiHeader.biWidth = m_iImageWidth;
bmi.bmiHeader.biHeight = m_iImageHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = m_iImageDataSize;
StretchDIBits(this->GetDC()->GetSafeHdc(), 0, 0, m_iImageWidth, m_iImageHeight,
0, 0, m_iImageWidth, m_iImageHeight, m_pImageData,&bmi, DIB_RGB_COLORS, SRCCOPY);
}
- 最近一直困扰我的问题
- 一直困扰我的事!!!
- zeromq一直困扰我的问题和自我反省
- 今天解决了一直困扰我很久的两个问题
- jbpm一直困扰的一个问题
- jbpm一直困扰的一个问题(解决)
- [VB.NET]困扰我几天的问题..一直想不出~~关于VB.NET的Event~~~~急~~~~~~~~!!!
- 一直困扰我的问题终于解决了,感谢Amanda2007博主
- 转一个一直困扰我的问题:Unicode下CString转char* 用下面的办法可以解决
- 最近一直在搞我的网站
- 一个困扰了我三天的SQL优化问题。(多条数据取最近的数据)
- 最近一直困扰的一件事,powerShell里面运行python脚本不成功
- 困扰我多时的500错误问题
- 又一个困扰我的简单问题。
- 困扰我一个小时的问题 SetToolTip
- 困扰我几天的BPEL问题--soap
- 困扰我多天的问题
- 困扰我多年的数据库索引问题
- 网站性能优化实践-cms性能优化之动态页面静态化、减少http请求和js压缩
- OutputDebugString的用法
- 如何写综述
- mysql在ubuntu下的使用
- 转:研究人员发现:手机辐射或可治疗老年痴呆症
- 最近一直困扰我的问题
- 使用性能监控工具-Perfmon监控windows服务器性能
- 使用性能测试工具JMeter来测试网站性能1
- steam.pl
- 预加载
- 使用性能测试工具JMeter系列2-运行JUnit Request测试Java API
- 在QTP中使用Dictionary对象来替代环境变量
- name1.pl
- 使用性能测试工具Grinder做性能测试