码迷,mamicode.com
首页 > Windows程序 > 详细

14.Windows绘图

时间:2016-06-29 23:27:51      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:

1.绘图相关

  绘图设备DC(Device Context),绘图上下文/绘图描述表

  HDC - DC句柄,表示绘图设备

  GDI - Windows Graphics Device Interface,win32提供绘图的API

2.颜色

  (1)颜色的表示

     电脑使用红、绿、蓝:R - 0 ~ 255

                                          G - 0 ~ 255

                                          B - 0 ~ 255

     每一个颜色点是3个字节24位,保存0 - 2^24-1

       16位:5, 5, 6 - 红、绿、蓝

       32位:8, 8, 8, 8  - 红、绿、蓝、透明度

  (2)颜色的使用

     COLORREF - 实际为DWORD,例如:COLORREF nColor = 0;

     赋值使用RGB宏,例如:nColor = RGB(0, 0, 255);

     获取RGB值,GetRValue/GetGValue/GetBValue,例如:BYTE nRed = GetRValue(nColor);

3.点的使用

  (1)GetPixel获取指定点的颜色

     COLORREF GetPixel( HDC  hdc,        //

                                            int    nXPos,    //

                                            int    nYPos);   //

  (2)SetPixel设置指定的颜色

     COLORREF SetPixel( HDC           hdc,          //

                                            int              X,            //

                                            int              Y,            //

                                            COLORREF  crColor);   //

     返回点原来的颜色

4.线的使用(直线、弧线)

  移动当前点到指定点:BOOL MoveToEx(HDC       hdc,

                                                           int          X,

                                                           int          Y,

                                                           LPPOINT  lpPoint);

  从当前点到指定点绘制一条直线:BOOL LineTo( HDC  hdc,

                                                                    int     nXEnd,

                                                                    int     nYEnd);

14.Windows绘图

标签:

原文地址:http://www.cnblogs.com/csqtech/p/5628454.html

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