1个回答
展开全部
我不知道你说的依次播放是什么意思?动态自己播放吗?那需要添加onTime()函数控制时间,如果是自己点击的话,主要的步骤是:
----------------------------------------
1,在对话框下创建一个picture控件用来显示图片,假设ID为IDC_STATIC_SHOW;
2,读取文件夹的代码为:
CFileDialog dlg(TRUE, "*.BMP", NULL, NULL,"位图文件(*.BMP)|*.bmp;*.BMP|");
CString strFileName;
CFile file;
if (dlg.DoModal() == IDOK)
{
strFileName = dlg.GetPathName();
if(!file.Open(strFileName, CFile::modeRead))
return;
BITMAPFILEHEADER bmfHeader;
nFileLen = file.GetLength();
dwDibSize = nFileLen - sizeof(BITMAPFILEHEADER);
if (m_pDib != NULL)
{
delete[] m_pDib;
m_pDib = NULL;
}
m_pDib = new unsigned char[dwDibSize];
if (file.Read((LPSTR)&bmfHeader, sizeof(bmfHeader)) != sizeof(bmfHeader))
return;
if (bmfHeader.bfType != ((WORD)('M' <<8) | 'B'))
return ;
if (file.Read(m_pDib, dwDibSize) != dwDibSize)
return ;
m_bmpInfoHeader = (BITMAPINFOHEADER*)m_pDib;
lHeight = m_bmpInfoHeader->biHeight; //图像长
lWidth = m_bmpInfoHeader->biWidth; //图像宽
lBitCount = m_bmpInfoHeader->biBitCount; //图像位数
switch(lBitCount)
{
case 1:
NumColor = 2;
break;
case 4:
NumColor = 16;
break;
case 8:
NumColor = 256;
break;
case 24:
NumColor = 0;
break;
default:
return;
}
m_pDibBits = m_pDib + sizeof(BITMAPINFOHEADER) + NumColor * sizeof (RGBQUAD);
3,显示图片的代码为:
CDC *pDC;
CRect rect;
CWnd *pWnd = GetDlgItem(IDC_STATIC_SHOW);
pWnd->GetClientRect(&rect);
pDC = pWnd->GetDC();
SetStretchBltMode(pDC->m_hDC,HALFTONE);//防止自适应窗口图像显示失真
StretchDIBits(pDC->m_hDC,rect.left, rect.top, rect.right, rect.bottom, 0, 0,
lWidth, lHeight, m_pDibBits, (BITMAPINFO*)m_bmpInfoHeader, BI_RGB, SRCCOPY);
===============
这些代码怎么添加你应该知道吧?
----------------------------------------
1,在对话框下创建一个picture控件用来显示图片,假设ID为IDC_STATIC_SHOW;
2,读取文件夹的代码为:
CFileDialog dlg(TRUE, "*.BMP", NULL, NULL,"位图文件(*.BMP)|*.bmp;*.BMP|");
CString strFileName;
CFile file;
if (dlg.DoModal() == IDOK)
{
strFileName = dlg.GetPathName();
if(!file.Open(strFileName, CFile::modeRead))
return;
BITMAPFILEHEADER bmfHeader;
nFileLen = file.GetLength();
dwDibSize = nFileLen - sizeof(BITMAPFILEHEADER);
if (m_pDib != NULL)
{
delete[] m_pDib;
m_pDib = NULL;
}
m_pDib = new unsigned char[dwDibSize];
if (file.Read((LPSTR)&bmfHeader, sizeof(bmfHeader)) != sizeof(bmfHeader))
return;
if (bmfHeader.bfType != ((WORD)('M' <<8) | 'B'))
return ;
if (file.Read(m_pDib, dwDibSize) != dwDibSize)
return ;
m_bmpInfoHeader = (BITMAPINFOHEADER*)m_pDib;
lHeight = m_bmpInfoHeader->biHeight; //图像长
lWidth = m_bmpInfoHeader->biWidth; //图像宽
lBitCount = m_bmpInfoHeader->biBitCount; //图像位数
switch(lBitCount)
{
case 1:
NumColor = 2;
break;
case 4:
NumColor = 16;
break;
case 8:
NumColor = 256;
break;
case 24:
NumColor = 0;
break;
default:
return;
}
m_pDibBits = m_pDib + sizeof(BITMAPINFOHEADER) + NumColor * sizeof (RGBQUAD);
3,显示图片的代码为:
CDC *pDC;
CRect rect;
CWnd *pWnd = GetDlgItem(IDC_STATIC_SHOW);
pWnd->GetClientRect(&rect);
pDC = pWnd->GetDC();
SetStretchBltMode(pDC->m_hDC,HALFTONE);//防止自适应窗口图像显示失真
StretchDIBits(pDC->m_hDC,rect.left, rect.top, rect.right, rect.bottom, 0, 0,
lWidth, lHeight, m_pDibBits, (BITMAPINFO*)m_bmpInfoHeader, BI_RGB, SRCCOPY);
===============
这些代码怎么添加你应该知道吧?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询