码迷,mamicode.com
首页 > 其他好文 > 详细

绘图一

时间:2016-08-05 21:22:36      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

1.定义点函数:

SetPixel(hDC,x,y,crColor); hDC为句柄,x,y为点坐标,crColor为颜色。

GetPixel(hDC,x,y)获取该点的像素点;

COLORREF crColor = GetPixel(hDC,x,y);

2.画直线:

a.利用MoveToEx函数和LineTo函数:

MoveToEx(hDC, x, y,NULL);//定义一个点,起点

LineTo(hDC,xEnd,yEnd); //连线到终点

b.利用Polyline函数:

//产生个矩阵

POINT apt[5]={100,100,200,100,200,200,100,200,100,100};

MoveToEx(hDC,apt[0].x,apt[0].y,NULL);

(1).for (int i=1;i<5;i++) LineTo(hDC,apt[i].x,apt[i].y);

(2).Polyline(hDC,apt,5);

(3).MoveToEx(hDC,apt[0].x,apt[0].y,NULL)‘

      PolylineTo(hDC,apt+1,5);

(4).Rectangle(hDC,xLeft,yTop,xRight,yBottom);

//产生圆

Ellipse(hDC,xLeft,yTop,xRight,yBottom);

//圆角矩阵

RoundRect(hDC,xLeft,yTop,xRight,yBottom,xCornerEllipse,yCornerEllipse);

//弧形

Arc(hDC,xLeft,yTop,xRight,yBottom,xStart,yStart,xEnd,yEnd);

//椭圆弓形

Chord(hDC,xLeft,yTop,xRight,yBottom,xStart,yStart,xEnd,yEnd);

//扇形

Pie(hDC,xLeft,yTop,xRight,yBottom,xStart,yStart,xEnd,yEnd);

3.彩图:

case WM_PAINT:

HDC hDC;

PAINTSTRUCT ps;

HPEN hPen;

hDC=BeginPaint(hwnd,&ps);

LOGPEN logpen;

logpen.lopnStyle = PS_SOLID;

logpen.lopnWidth.x = 3;

logpen.lopnColor = RGB(255,0,0);

hPen = CreatePenIndirect(&logpen);

SelectObject(hDC,hPen);

Rectangle(hDC,100,100,300,300);

EndPaint(hwnd,&ps);

DeleteObject(hPen);

break;

绘图一

标签:

原文地址:http://www.cnblogs.com/xy95/p/5742752.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!