当前位置:C++技术网 > 资讯 > GDI+实现油画滤镜

GDI+实现油画滤镜

更新时间:2015-12-18 23:57:38浏览次数:1+次

油画的绘制过程可以理解成“堆”颜料的过程。上代码:

void C油表View::OnGdiCanvas()
{
	// TODO: 在此添加命令处理程序代码
	this->RedrawWindow();
	CDC *pDC = GetDC();
	Graphics graphics(pDC->m_hDC);
	Bitmap image(L"cos.bmp");
	INT Width = image.GetWidth();
	INT Height = image.GetHeight();
	Color colorTemp, color2, color;
	graphics.DrawImage(&image, Rect(0, 0, Width, Height));
	int avg;
	for(int i = 0; i < Width-5; i++)
	{
		for (int j = 0; j < Height - 3; j++)
		{
			int a = rand() % 5;
			image.GetPixel(i+a,j+a,&color);
			image.SetPixel(i, j, color);
		}
		graphics.DrawImage(&image, Rect(Width, 0, Width, Height));
	}
}
代码实现: