[转载]gdi+ 裁剪圆形图片 - 逍楚客

时间:2024-03-11 17:43:39

[转载]gdi+ 裁剪圆形图片

2018-01-29 22:20  逍楚客  阅读(169)  评论(0编辑  收藏  举报

原文链接:http://blog.csdn.net/ckkyjtqlt/article/details/50633559

Image image(strPath);
RECT pos = GetPos();
RECT padding = GetPadding();
HRGN rgn = CreateEllipticRgn(pos.left,pos.top,pos.right,pos.bottom);
Region region(rgn);
Graphics graph(hDC);

SolidBrush greenBrush(Color(255,255,255,255)); ;
Rect rc2(pos.left,pos.top,pos.right-pos.left-2,pos.bottom-pos.top-2);

graph.SetClip(&region,CombineModeReplace);
graph.DrawImage(&image,padding.left,padding.top);

Graphics graph1(hDC);
graph1.SetSmoothingMode(SmoothingModeHighQuality);
graph1.DrawEllipse(&Pen(Color::White,2),rc2);