GDI(图形设备接口)
来源:百度文库 编辑:神马文学网 时间:2024/04/19 00:03:17
GDI操作函数
绘制文本TextOut和DrawText:
BOOL TextOut(HDC HDC,int nXStart,int nYStart,LPCTSTR lpString,int cbString)
int DrawText(HDC hdc,LPCTSTR lpString,int nCount,LPRECT lpRect,UINT uFormat)
TextOut根据坐标和长度绘制文本,DrawText则是给定一个矩形区域绘制文本。
绘制点SetPixel:
COLORREF SexPixel(HDC hdc,int x,int y,COLORREF crColor);
绘制直线MoveToEx和LineTo
BOOL MoveToEx(HDC hdc,int x,int y,LPPOINT lpPoint)
BOOL LineTo(HDC hdc,int nXEnd,int nYEnd)
绘制椭圆Ellipse
BOOL Ellipse(HDC hdc,int nLeftRect,int nTopRect,int RightRect,int nBottomRect)
绘制矩形FillRect与Rectangle
int FillRect(HDC hdc,CONST RECT *lprc,HBRUSH hbr)
BOOL Rectangle(HDC hdc,int nLeftRect,int nTopRect,int nRightRect,int nBottomRect)
MFC对GDI进行了封装,CDC是最基本的DC类,CClientDC与CWindowDC从CDC派生出来的。
例子:画椭圆
CClientDC *pClientDC = (CClientDC*)this->GetDC();
pClientDC->Ellipse(CRect(0,0,200,300));
字体:
CFont font,*pOldFont;
CClientDC *pClientDC = (CClientDC*)this->GetDC();
font.CreatePointFont(90,"宋体"); //创建字体
pOldFont=pClientDC->SelectObject(&font);//设置字体
pClientDC->TextOut(300,300,"ABC");//输出文本
pClientDC->SelectObject(pOldFont);//将先前字体设置回DC
画笔
BOOL CreatePen(int nPenStyle,int nWidth,COLORREF crColor)
画刷
CBrush()
CBrush(COLORREF crColor)
CBrush(CBitmap *pBitmap)
位图:使用CBitmap类来管理位图
载入:CBitmap::LoadBitmap从资源中载入,CBitmap::LoadImage从磁盘文件中载入。
BOOL LoadBitmap(UINT nIDResource)
HANDLE LoadImage(HINSTANCE hinst,LPCTSTR lpszName,UINT uType,int cxDesired,int cyDesired,UINT fuLoad)
显示:普通显示BitBlt,拉伸显示StretchBlt
BOOL BitBlt(HDC hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,HDC hdcSrc,int nXSrc,int nYSrc,DWORD dwRop)
BOOL StretchBlt(HDC hdcDest,int nXOriginDest,int nYOriginDest,int nWidthDest,int nHeightDest,HDC hdcSrc,int nXOriginSrc,int nYOriginSrc,int nWidthSrc,int nHeightSrcDWORD dwRop)
绘制文本TextOut和DrawText:
BOOL TextOut(HDC HDC,int nXStart,int nYStart,LPCTSTR lpString,int cbString)
int DrawText(HDC hdc,LPCTSTR lpString,int nCount,LPRECT lpRect,UINT uFormat)
TextOut根据坐标和长度绘制文本,DrawText则是给定一个矩形区域绘制文本。
绘制点SetPixel:
COLORREF SexPixel(HDC hdc,int x,int y,COLORREF crColor);
绘制直线MoveToEx和LineTo
BOOL MoveToEx(HDC hdc,int x,int y,LPPOINT lpPoint)
BOOL LineTo(HDC hdc,int nXEnd,int nYEnd)
绘制椭圆Ellipse
BOOL Ellipse(HDC hdc,int nLeftRect,int nTopRect,int RightRect,int nBottomRect)
绘制矩形FillRect与Rectangle
int FillRect(HDC hdc,CONST RECT *lprc,HBRUSH hbr)
BOOL Rectangle(HDC hdc,int nLeftRect,int nTopRect,int nRightRect,int nBottomRect)
MFC对GDI进行了封装,CDC是最基本的DC类,CClientDC与CWindowDC从CDC派生出来的。
例子:画椭圆
CClientDC *pClientDC = (CClientDC*)this->GetDC();
pClientDC->Ellipse(CRect(0,0,200,300));
字体:
CFont font,*pOldFont;
CClientDC *pClientDC = (CClientDC*)this->GetDC();
font.CreatePointFont(90,"宋体"); //创建字体
pOldFont=pClientDC->SelectObject(&font);//设置字体
pClientDC->TextOut(300,300,"ABC");//输出文本
pClientDC->SelectObject(pOldFont);//将先前字体设置回DC
画笔
BOOL CreatePen(int nPenStyle,int nWidth,COLORREF crColor)
画刷
CBrush()
CBrush(COLORREF crColor)
CBrush(CBitmap *pBitmap)
位图:使用CBitmap类来管理位图
载入:CBitmap::LoadBitmap从资源中载入,CBitmap::LoadImage从磁盘文件中载入。
BOOL LoadBitmap(UINT nIDResource)
HANDLE LoadImage(HINSTANCE hinst,LPCTSTR lpszName,UINT uType,int cxDesired,int cyDesired,UINT fuLoad)
显示:普通显示BitBlt,拉伸显示StretchBlt
BOOL BitBlt(HDC hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,HDC hdcSrc,int nXSrc,int nYSrc,DWORD dwRop)
BOOL StretchBlt(HDC hdcDest,int nXOriginDest,int nYOriginDest,int nWidthDest,int nHeightDest,HDC hdcSrc,int nXOriginSrc,int nYOriginSrc,int nWidthSrc,int nHeightSrcDWORD dwRop)
GDI(图形设备接口)
GDI(图形设备接口)
GDI 编程基础(一)GDI Vs GDI
一些关于GDI+的文字——图形容器
DynamipsGUI中各种设备对应接口说明
胡子GDI++.INI配置文件(氦版)
USB Key是一种USB接口的硬件设备-
GDI+ 和 GDI比较
用 GDI 开发矢量图形编辑系统的经验之谈 - 及时消息和ERP系统的集成(Instan...
GDI+中GIF图片的显示(一)
GDI+中GIF图片的显示(二)
GDI+中GIF图片的显示(三)
GDI+中GIF图片的显示(二)
什么是GDI+ ?
GDI编程
自制图形(符号)
QNX推出加快嵌入式设备图形用户界面创建速度的解决方案
QNX推出加快嵌入式设备图形用户界面创建速度的解决方案
工作流管理应用编程接口(接口2&3)规范
USB接口技术(一)【USB接口技术】
工作流管理应用编程接口(接口2&3)规范
USB接口技术(一)【USB接口技术】
USB接口技术(一)
USB接口技术(一)