将宽度设置为若干份,开始显示时若干个起始线,每个起始线间隔相同的距离。显示过程中,每次各个起始线同时向下(或向右)显示一行(或一列)图像,直到图像显示完毕。
void CMy1_showbitmapView::OnDraw(CDC* pDC)
{
CMy1_showbitmapDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: add draw code for native data here
//this->StretchBitMap(pDC);
//控制缩放比例
int m_scale = 1;
//CDib类指针对象
BYTE* pBitmapData = _cdib.GetData();
LPBITMAPINFO pBitmapInfo = _cdib.GetInfo();
int bitmapHeight = _cdib.GetHeight();
int bitmapWidth = _cdib.GetWidth();
int scaledWidth = (int)(bitmapWidth * m_scale);
int scaledHeight = (int)(bitmapHeight * m_scale);
bool bGetRGB = _cdib.GetRGB();
if (!bGetRGB)
{return;
}CPalette* hPalette = CreateBitmapPalette(&_cdib);
//将已创建的调色板调用到设备上下文中
CPalette* hOldPalette = pDC->SelectPalette(hPalette, true);
//实现调色板
pDC->RealizePalette();for (int i = 0; i <= bitmapWidth/10; i++)
{for (int j = 0; j <= 10; j++){::StretchDIBits(pDC->GetSafeHdc(), j* bitmapWidth / 10, 0,i, bitmapHeight,j * bitmapWidth /10, 0,i , bitmapHeight,pBitmapData, pBitmapInfo,DIB_RGB_COLORS,SRCCOPY);Sleep(15);}
}pDC->SelectPalette(hOldPalette, true);
::DeleteObject(hPalette);
}
同样替代下,
#if 1
for (int j = 0; j <= bitmapHeight / 10; j++)
{
for (int i = 0; i <= 10; i++)
{
::StretchDIBits(pDC->GetSafeHdc(), 0,i* bitmapHeight / 10, bitmapWidth, j,0,(9-i) * bitmapHeight / 10,bitmapWidth, j,pBitmapData, pBitmapInfo,DIB_RGB_COLORS,SRCCOPY);Sleep(10);}
}
#endif