本文主要是介绍4,图像中间扩张,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
其实就是分成两部分,再用sleep(),类似于动画效果
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/2; i++)
{::StretchDIBits(pDC->GetSafeHdc(), bitmapWidth/2-i, bitmapHeight/2-i,i*2, i,bitmapWidth / 2 - i, bitmapHeight / 2 - i,i*2, i,pBitmapData, pBitmapInfo,DIB_RGB_COLORS,SRCCOPY);::StretchDIBits(pDC->GetSafeHdc(), bitmapWidth / 2 - i, bitmapHeight / 2 - i,i * 2, i*2,bitmapWidth / 2 - i, bitmapHeight / 2 - i,i * 2, i*2,pBitmapData, pBitmapInfo,DIB_RGB_COLORS,SRCCOPY);Sleep(300);
}
pDC->SelectPalette(hOldPalette, true);
::DeleteObject(hPalette);
}
这篇关于4,图像中间扩张的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!