常用的API画图形函数

1.设定图素 SetPixel GetPixel 2.画线 LineTo 画直线。 Polyline和PolylineTo 画一系列相连的直线。 PolyPolyline 画多组相连的线。 Arc 画椭圆线。 PolyBezier和PolyBezierTo 画贝塞尔曲线。 ArcTo和AngleArc 画椭圆线。 PolyDraw 画一系列相连的线以及贝塞尔曲线 3.既画线也填入所画图形的封闭区域的函数,边界框函数 Rectangle 画矩形。 Ellipse 画椭圆。 RoundRect 画带圆角的矩形。 Pie 画椭圆的一部分,使其看起来像一个扇形。 Chord 画椭圆的一部分,以呈弓形。 SetPixel函数在指定的x和y坐标以特定的颜色设定图素: SetPixel (hdc, x, y, crColor) ;  如同在任何绘图函数中一样,第一个参数是设备内容的句柄。第二个和第三个参数指明了坐标位置。通常要获得窗口显示区域的设备内容,并且x和y相对于该显示区域的左上角。最后一个参数是COLORREF型态指定了颜色。如果在函数中指定的颜色视讯显示器不支持,则函数将图素设定为最接近的纯色并从函数传回该值。 GetPixel函数传回指定坐标处的图素颜色: crColor = GetPixel (hdc, x, y) ; 画一条直线,必须呼叫两个函数。第一个函数指定了线的开始点,第二个函数指定了线的终点: MoveToEx (hdc, xBeg, yBeg, NULL) ; LineTo (hdc, xEnd, yEnd) ; MoveToEx实际上不会画线,它只是设定了设备内容的「目前位置」属性。然后LineTo函数从目前的位置到它所指定的点画一条直线。目前位置只是用于其它几个GDI函数的开始点。在内定的设备内容中,目前位置最初设定在点 (0,0).如果在呼叫LineTo之前没有设定目前位置,那么它将从显示区域的左上角开始画线。 当您要将数组中的点连接成线时,使用Polyline函数要简单得多 Polyline (hdc, apt, 5) ;     最后一个参数是点的数目。我们还可以使用(sizeof (apt) / sizeof (POINT))来表示这个值。Polyline与一个MoveToEx函数后面加几个LineTo函数的效果相同,但是,Polyline既不使用也不改变目前位置。PolylineTo有些不同,这个函数使用目前位置作为开始点,并将目前位置设定为最后一根线的终点 Rectangle (hdc, xLeft, yTop, xRight, yBottom) ; 点(xLeft, yTop)是矩形的左上角,(xRight, yBottom)是矩形的右下角。用函数Rectangle画出的图形如图5-6所示,矩形的边总是平行于显示器的水平和垂直边

// Line-Output Functions  CPoint GetCurrentPosition() const;  CPoint MoveTo(int x, int y);  CPoint MoveTo(POINT point);  BOOL LineTo(int x, int y);  BOOL LineTo(POINT point);  BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);  BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd);  BOOL Polyline(const POINT* lpPoints, int nCount);

 BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle);  BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);  BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd);  int GetArcDirection() const;  int SetArcDirection(int nArcDirection);

 BOOL PolyDraw(const POINT* lpPoints, const BYTE* lpTypes, int nCount);  BOOL PolylineTo(const POINT* lpPoints, int nCount);  BOOL PolyPolyline(const POINT* lpPoints,   const DWORD* lpPolyPoints, int nCount);

 BOOL PolyBezier(const POINT* lpPoints, int nCount);  BOOL PolyBezierTo(const POINT* lpPoints, int nCount);

// Simple Drawing Functions  void FillRect(LPCRECT lpRect, CBrush* pBrush);  void FrameRect(LPCRECT lpRect, CBrush* pBrush);  void InvertRect(LPCRECT lpRect);  BOOL DrawIcon(int x, int y, HICON hIcon);  BOOL DrawIcon(POINT point, HICON hIcon);  BOOL DrawState(CPoint pt, CSize size, HBITMAP hBitmap, UINT nFlags,   HBRUSH hBrush = NULL);  BOOL DrawState(CPoint pt, CSize size, CBitmap* pBitmap, UINT nFlags,   CBrush* pBrush = NULL);  BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags,   HBRUSH hBrush = NULL);  BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags,   CBrush* pBrush = NULL);  BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags,   BOOL bPrefixText = TRUE, int nTextLen = 0, HBRUSH hBrush = NULL);  BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags,   BOOL bPrefixText = TRUE, int nTextLen = 0, CBrush* pBrush = NULL);  BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc,   LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL);  BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc,   LPARAM lData, UINT nFlags, CBrush* pBrush = NULL);

// Ellipse and Polygon Functions  BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3,   int x4, int y4);  BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd);  void DrawFocusRect(LPCRECT lpRect);  BOOL Ellipse(int x1, int y1, int x2, int y2);  BOOL Ellipse(LPCRECT lpRect);  BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);  BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd);  BOOL Polygon(const POINT* lpPoints, int nCount);   BOOL PolyPolygon(const POINT* lpPoints, const INT* lpPolyCounts, int nCount);  BOOL Rectangle(int x1, int y1, int x2, int y2);  BOOL Rectangle(LPCRECT lpRect);  BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3);  BOOL RoundRect(LPCRECT lpRect, POINT point);

// Bitmap Functions  BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop);  BOOL BitBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,   int xSrc, int ySrc, DWORD dwRop);  BOOL StretchBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,   int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop);  COLORREF GetPixel(int x, int y) const;  COLORREF GetPixel(POINT point) const;  COLORREF SetPixel(int x, int y, COLORREF crColor);  COLORREF SetPixel(POINT point, COLORREF crColor);  BOOL FloodFill(int x, int y, COLORREF crColor);  BOOL ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType);  BOOL MaskBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,   int xSrc, int ySrc, CBitmap& maskBitmap, int xMask, int yMask,   DWORD dwRop);  BOOL PlgBlt(LPPOINT lpPoint, CDC* pSrcDC, int xSrc, int ySrc,   int nWidth, int nHeight, CBitmap& maskBitmap, int xMask, int yMask);  BOOL SetPixelV(int x, int y, COLORREF crColor);  BOOL SetPixelV(POINT point, COLORREF crColor);    BOOL GradientFill(TRIVERTEX* pVertices, ULONG nVertices,    void* pMesh, ULONG nMeshElements, DWORD dwMode);    BOOL TransparentBlt(int xDest, int yDest, int nDestWidth, int nDestHeight,    CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight,    UINT clrTransparent);    BOOL AlphaBlend(int xDest, int yDest, int nDestWidth, int nDestHeight,    CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight,    BLENDFUNCTION blend);

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值