利用GDI+制作模糊效果
2008-04-15 12:55
399 查看
在vista下,VS2008已经带了gdiplus1.1的库。
看看下面图片效果,是不是很神奇。
配置好GDIPLUS,你就可以在程序中实现了。
所以我们再也不用找一些算法来实现模糊,锐化,对比度,高亮等效果了
void CCatchScreenDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
Bitmap* pBmp = new Bitmap(L"background.bmp");//打开图片
RECT rc = {0, 0, 100, pBmp->GetHeight()};
Blur m_blur;
BlurParams bp;
bp.expandEdge = false;
bp.radius = 5.0f;
m_blur.SetParameters(&bp);
pBmp->ApplyEffect(&m_blur, &rc);
Graphics g(m_hWnd);
g.DrawImage(pBmp, 0, 0);
CDialog::OnPaint();
}
}
如此简单。
你也来试试吧。
看看下面图片效果,是不是很神奇。
配置好GDIPLUS,你就可以在程序中实现了。
所以我们再也不用找一些算法来实现模糊,锐化,对比度,高亮等效果了
void CCatchScreenDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
Bitmap* pBmp = new Bitmap(L"background.bmp");//打开图片
RECT rc = {0, 0, 100, pBmp->GetHeight()};
Blur m_blur;
BlurParams bp;
bp.expandEdge = false;
bp.radius = 5.0f;
m_blur.SetParameters(&bp);
pBmp->ApplyEffect(&m_blur, &rc);
Graphics g(m_hWnd);
g.DrawImage(pBmp, 0, 0);
CDialog::OnPaint();
}
}
如此简单。
你也来试试吧。
相关文章推荐
- 利用GDI+制作背景颜色淡入淡出效果的按钮
- 利用GDI+制作背景颜色淡入淡出效果的按钮
- [NGUI插件] 利用NGUI制作游戏片头的流光效果
- 前端素材解析—利用linear制作复杂的边框效果
- 如何利用PowerPoint模板制作小球摆动效果
- Android利用RenderScript实现毛玻璃模糊效果示例
- 利用GDI+基于WIN32实现桌面雪花效果(一)
- 利用Viewpager制作滚动游标效果
- 利用属性动画制作下拉显示更多的效果
- GDI+ 在Delphi程序的应用 -- 制作水印效果图片
- 利用WORD制作水印效果
- 利用GDI+制作Flappy Bird
- 利用GDI+基于WIN32实现桌面雪花效果(二)
- 【PS】利用滤镜制作巧克力效果
- 教你如何利用灰度图透明效果制作隐藏图片.Part2
- 如何利用CSS3制作3D文字效果
- 利用JavaScript制作网页中“选项卡”效果。 (二)
- 利用AmChart制作图表信息(效果动态好看,很花哨)
- Span使用之利用系统Span样式实现模糊搜索,匹配变色的特殊UI效果
- VC利用GDI+技术制作基于CWnd类的Spalsh启动画面