支持缩放的浏览器
我用StretchBlt函数做了一个DC缩放的函数,现在还没有限定缩放极限就是试了一下速度,代码如下。
void PictureZoom(HDC hdc, float fZoomRatio)
{
if (fZoomRatio == 1)
return ;
static float fCurRatio = 0;
HDC BufferDC = CreateCompatibleDC(hdc);
HBITMAP BufferDCBmp = CreateCompatibleBitmap(hdc, g_dwScreenWidth, g_dwScreenHeight);
SelectObject(BufferDC, BufferDCBmp);
if (!g_hSrcPicDC)//当一张新图片进行缩放时
{
RECT rc;
HDC tempDC = CreateCompatibleDC(hdc);
HBITMAP tempDCBmp = SHLoadImageFile(g_cDlist.m_pCurNode->szFilePath);
SelectObject(tempDC, tempDCBmp);
g_hSrcPicDC = CreateCompatibleDC(hdc);
g_hSrcPicDCBmp = CreateCompatibleBitmap(hdc, g_dwScreenWidth, g_dwScreenHeight);
SelectObject(g_hSrcPicDC, g_hSrcPicDCBmp);
BitBltByScale(g_hSrcPicDC, g_dwScreenWidth, g_dwScreenHeight, tempDC, g_cDlist.m_pCurNode->Width, g_cDlist.m_pCurNode->Height, &rc);
//初始化当前显示区域
g_drawRc.left = 0;
g_drawRc.top = 0;
g_drawRc.right = g_dwScreenWidth;
g_drawRc.bottom = g_dwScreenHeight;
if (tempDC)
DeleteDC(tempDC);
if (tempDCBmp)
DeleteObject(tempDCBmp);
}
//计算缩放后的显示区域, 放大时显示区域是缩小,缩小时显示区域是放大
RECT tempRc = {g_drawRc.left, g_drawRc.top, g_drawRc.right, g_drawRc.bottom};
tempRc.right = tempRc.right / fZoomRatio;
tempRc.bottom = tempRc.bottom / fZoomRatio;
tempRc.left = g_dwScreenWidth / 2 - tempRc.right / 2;
tempRc.top = g_dwScreenHeight / 2 - tempRc.bottom / 2;
CopyRect(&g_drawRc, &tempRc);
StretchBlt(BufferDC, 0, 0, g_dwScreenWidth, g_dwScreenHeight,
g_hSrcPicDC, g_drawRc.left, g_drawRc.top, g_drawRc.right, g_drawRc.bottom, SRCCOPY);
if (g_dwFlags & STATE_MENU_BTN)
DrawMenuBtn(BufferDC);
BitBlt(hdc, 0, 0, g_dwScreenWidth, g_dwScreenHeight, BufferDC, 0, 0, SRCCOPY);
g_dwFlags |= STATE_ZOOM;
CLEAN:
if (BufferDC)
DeleteDC(BufferDC);
if (BufferDCBmp)
DeleteObject(BufferDCBmp);
}
速度不是很流畅,请问有其它比较快速 流畅的方式吗
(WIN32)
[解决办法]
要使用快的算法,你的自己写缩放算法,而不是使用API,并且的使用ASM优化