如何对图片进行放大或缩小

xf_pan xf_pan 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我有一个函数,功能是显示程序里用到的画图,现在需要加一个放大或是缩小功能,没做过这方面的,没思路了,有谁做个吗,大家讨论下吧,

_VOID Canvas_Flip(_HANDLE hCanvas, _INT nX, _INT nY, _INT nWidth, _INT nHeight)
{
HDC hDC = (HDC)::SendMessage(SimulatorData.m_hMainFrame, UM_GetDrawDevices, NULL, NULL);
_CANVASOBJECT* pCanvas = (_CANVASOBJECT*)hCanvas;
if (hDC && pCanvas)
{
_RECT rect;
GetScreenRect(&rect);

if ((MediaPlayerRect.nWidth <= 0) || (MediaPlayerRect.nHeight <= 0))
BitBlt(hDC, rect.nLeft + nX, rect.nTop + nY, nWidth, nHeight, pCanvas->hMemDC, nX, nY, SRCCOPY);
else
{

_INT x1 = nX, x2 = MediaPlayerRect.nLeft, x3 = MediaPlayerRect.nLeft + MediaPlayerRect.nWidth, x4 = nX + nWidth;
_INT y1 = nY, y2 = MediaPlayerRect.nTop, y3 = MediaPlayerRect.nTop + MediaPlayerRect.nHeight, y4 = nY + nHeight;
if (x4 > x1 > 0 && y2 > y1)
BitBlt(hDC, rect.nLeft + x1, rect.nTop + y1, x4 - x1, y2 - y1, pCanvas->hMemDC, x1, y1, SRCCOPY);
if (x2 > x1 > 0 && y3 > y2)
BitBlt(hDC, rect.nLeft + x1, rect.nTop + y2, x2 - x1, y3 - y2, pCanvas->hMemDC, x1, y2, SRCCOPY);
if (x4 > x3 > 0 && y3 > y2)
BitBlt(hDC, rect.nLeft + x3, rect.nTop + y2, x4 - x3, y3 - y2, pCanvas->hMemDC, x3, y2, SRCCOPY);
if (x4 > x1 > 0 && y4 > y3)
BitBlt(hDC, rect.nLeft + x1, rect.nTop + y3, x4 - x1, y4 - y3, pCanvas->hMemDC, x1, y3, SRCCOPY);
}

}
::SendMessage(SimulatorData.m_hMainFrame, UM_ReleaseDrawDevices, (WPARAM)hDC, NULL);
}
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
xf_pan
C++ 语言 65,214 成员 250,514 内容