油画的绘制过程可以理解成“堆”颜料的过程。上代码:
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));
}
}
代码实现: