MG_EXPORT HGRAPHICS MGPlusGraphicCreateFromDC(HDC hdc);
MG_EXPORT HGRAPHICS MGPlusGraphicCreate(int width, int height); MG_EXPORT MPStatus MGPlusGraphicSave(HGRAPHICS graphics, HDC hdc, int sx, int sy, int sw, int sh, int dx, int dy);
HGRAPHICS MGPlusGraphicCreateWithoutCanvas (HDC hdc);
MPStatus MGPlusGraphicDelete (HGRAPHICS graphics);
MGPlusGraphicClear (graphics, 0); hdc = GetClientDC (hWnd); FillBox (hdc, 0, 0, 1024, 768); MGPlusGraphicCopyFromDC (graphics, hdc, 0, 0, 0, 0, 0, 0); ReleaseDC (hdc);
MPStatus MGPlusGraphicCopy (HGRAPHICS src_gs, HGRAPHICS dst_gs);
MP_COMP_OP_CLEAR = 0, //目标色和目标 alpha 值都被清除(Porter-Duff Clear 规则)。源色和目标色都不被用作输入 MP_COMP_OP_SRC, //将源色复制到目标色(Porter-Duff Source 规则)。目标色不被用作输入 MP_COMP_OP_DST, //未涉及到目标色(Porter-Duff Destination 规则) MP_COMP_OP_SRC_OVER, //在目标色之上合成源色(Porter-Duff Source Over Destination 规则) MP_COMP_OP_DST_OVER, //在源色之上合成目标色,产生的结果将替代目标色(Porter-Duff Destination Over Source 规则) MP_COMP_OP_SRC_IN, //目标色中的源色部分将替换目标色(Porter-Duff Source In Destination 规则) MP_COMP_OP_DST_IN, //源色中的目标色部分将替换目标色(Porter-Duff Destination In Source 规则) MP_COMP_OP_SRC_OUT, //目标色以外的源色部分将替换目标色(Porter-Duff Source Held Out By Destination 规则) MP_COMP_OP_DST_OUT, //源色以外的目标色部分将替换目标色(Porter-Duff Destination Held Out By Source 规则) MP_COMP_OP_SRC_ATOP, //目标色中的源色部分将被合成到目标色中(Porter-Duff Source Atop Destination 规则) MP_COMP_OP_DST_ATOP, //在源色之上合成源色中的目标色部分,并且将替换目标色(Porter-Duff Destination Atop Source 规则) MP_COMP_OP_XOR, //将目标色之外的源色部分与源色之外的目标色部分结合到一起(Porter-Duff Source Xor Destination 规则)
MPStatus MGPlusSetCompositingMode( HGRAPHICS graphics, CompositingMode compositingMode);
MPStatus MGPlusGetCompositingMode(HGRAPHICS graphics, CompositingMode *compositingMode);
MPStatus MGPlusGraphicLoadBitmapFromFile (HGRAPHICS graphics, int n_index, char* file);
MPStatus MGPlusDrawImage (HGRAPHICS graphics, int n_index,int x, int y, int w, int h);
MPStatus MGPlusGraphicLoadBitmap (HGRAPHICS graphics, int n_index, PBITMAP p_bitmap);
MPStatus MGPlusGraphicBlend (HGRAPHICS src_gs, HGRAPHICS dst_gs);
#define COMP_CLEAR 310
#define COMP_SRC 311
#define COMP_DST 312
#define COMP_SRC_OVER 313
#define COMP_DST_OVER 314
#define COMP_SRC_IN 315
#define COMP_DST_IN 316
#define COMP_SRC_OUT 317
#define COMP_DST_OUT 318
#define COMP_SRC_ATOP 319
#define COMP_DST_ATOP 320
#define COMP_XOR 321
static BITMAP bmp_butterfly;
static int comp_mode = MP_COMP_OP_SRC_OVER;
static void GetCompMode(HWND hWnd, WPARAM wParam)
{
switch (wParam) {
case COMP_CLEAR:
comp_mode = MP_COMP_OP_CLEAR;
break;
case COMP_SRC:
comp_mode = MP_COMP_OP_SRC;
break;
case COMP_DST:
comp_mode = MP_COMP_OP_DST;
break;
case COMP_SRC_OVER:
comp_mode = MP_COMP_OP_SRC_OVER;
break;
case COMP_DST_OVER:
comp_mode = MP_COMP_OP_DST_OVER;
break;
case COMP_SRC_IN:
comp_mode = MP_COMP_OP_SRC_IN;
break;
case COMP_DST_IN:
comp_mode = MP_COMP_OP_DST_IN;
break;
case COMP_SRC_OUT:
comp_mode = MP_COMP_OP_SRC_OUT;
break;
case COMP_DST_OUT:
comp_mode = MP_COMP_OP_DST_OUT;
break;
case COMP_SRC_ATOP:
comp_mode = MP_COMP_OP_SRC_ATOP;
break;
case COMP_DST_ATOP:
comp_mode = MP_COMP_OP_DST_ATOP;
break;
case COMP_XOR:
comp_mode = MP_COMP_OP_XOR;
break;
default:
return;
}
}
#define C_POS 600
#define C_W 170
static CTRLDATA CtrlYourTaste[] =
{
{
"static",
WS_VISIBLE | SS_GROUPBOX,
16+C_POS, 0, 200, 160+200,
IDC_STATIC,
"Composite_Mode",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,
36+C_POS, 38, C_W, 20,
COMP_CLEAR,
"Composite_Clear",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 64, C_W, 20,
COMP_SRC,
"Composite_Source",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 90, C_W, 20,
COMP_DST,
"Composite_Dst",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON| BS_CHECKED ,
36+C_POS, 116, C_W, 20,
COMP_SRC_OVER,
"Composite_SourceOver",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 142, C_W, 20,
COMP_DST_OVER,
"Composite_DstOver",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 142+1*26, C_W, 20,
COMP_SRC_IN,
"Composite_SourceIn",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 142+2*26, C_W, 20,
COMP_DST_IN,
"Composite_DstIn",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 142+3*26, C_W, 20,
COMP_SRC_OUT,
"Composite_SourceOut",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 142+4*26, C_W, 20,
COMP_DST_OUT,
"Composite_DstOut",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 142+5*26, C_W, 20,
COMP_SRC_ATOP,
"Composite_SourceAtop",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 142+6*26, C_W, 20,
COMP_DST_ATOP,
"Composite_DestAtop",
0
},
{
"button",
WS_VISIBLE | BS_AUTORADIOBUTTON,
36+C_POS, 142+7*26, C_W, 20,
COMP_XOR,
"Composite_Xor",
0
},
};
static DLGTEMPLATE DlgYourTaste =
{
WS_BORDER | WS_CAPTION,
WS_EX_AUTOSECONDARYDC,
0, 0, 370+420, 300+290,
"CompositeDemo(press F1,F2,F3...)",
0, 0,
TABLESIZE(CtrlYourTaste),
NULL,
0
};
void CompositeDrawBmpBlend(HWND hDlg)
{
RECT rect = {20, 20, 200, 200};
HBRUSH hbrush = 0;
HGRAPHICS hgs_comp;
HGRAPHICS hgs;
RECT cl_rc = {0};
HDC hdc = BeginPaint(hDlg);
// 创建路径的模式
HPATH hpath = MGPlusPathCreate (MP_PATH_FILL_MODE_WINDING);
/* first Clear the output_area that have draw last time.*/
GetClientRect(hDlg, &cl_rc);
FillBox (hdc, 0, 0, RECTW(cl_rc), RECTH(cl_rc));
//创建两个MGPlusGraphics
hgs_comp = MGPlusGraphicCreateFromDC(hdc);
hgs = MGPlusGraphicCreateFromDC(hdc);
//创建画刷
hbrush = MGPlusBrushCreate(MP_BRUSH_TYPE_SOLIDCOLOR);
//添加一个圆路径
MGPlusPathAddArc (hpath, rect.left+RECTW(rect)/2,
rect.top+RECTH(rect)/2, RECTW(rect)/2, RECTH(rect)/2, 0, 360);
//清除两个MGPlusGraphics中其他颜色
MGPlusGraphicClear(hgs_comp, 0x00000000);
MGPlusGraphicClear(hgs, 0x00ffffff);
//加载并绘制图片
MGPlusGraphicLoadBitmapFromFile (hgs_comp, 1, "res/butterfly.png");
MGPlusDrawImage(hgs_comp, 1, 220, 35, -1, -1);
//设置画笔的颜色
MGPlusSetSolidBrushColor (hbrush, 0xDF6FF0FD);
//设置图片与图形组合的模式
MGPlusSetCompositingMode (hgs_comp, (MPCompositingMode)MP_COMP_OP_SRC);
//填充路径
MGPlusFillPath(hgs_comp, hbrush, hpath);
//重设路径
MGPlusPathReset(hpath);
//添加新的的图形
OffsetRect(&rect, 80, 0);
MGPlusPathAddRoundRect(hpath, rect.left, rect.top, RECTW(rect), RECTH(rect), 50);
//设置画笔的颜色
MGPlusSetSolidBrushColor (hbrush, 0xBFFFC17F);
//设置图形颜色组合的模式
MGPlusSetCompositingMode (hgs_comp, (MPCompositingMode)comp_mode);
MGPlusFillPath(hgs_comp, hbrush, hpath);
//混合两个MGPlusGraphics
MGPlusGraphicBlend(hgs_comp, hgs);
//保存MGPlusGraphics
if (MGPlusGraphicSave(hgs, hdc, 0, 0, 0, 0, 0, 0) != MP_OK)
printf("save graphic failed!\n");
//释放内存空间
MGPlusPathDelete (hpath);
MGPlusBrushDelete (hbrush)
MGPlusGraphicDelete(hgs_comp);
MGPlusGraphicDelete(hgs);
EndPaint(hDlg, hdc);
}
static int DialogBoxProc2 (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case MSG_INITDIALOG:
SetWindowBkColor(hDlg, COLOR_lightwhite);
return 1;
case MSG_COMMAND:
GetCompMode(hDlg, wParam);
if(wParam >= COMP_CLEAR && wParam <= COMP_XOR) {
RECT rc = {0, 0, 400, 300};
InvalidateRect(hDlg, &rc, FALSE);
}
break;
case MSG_PAINT:
CompositeDrawBmpBlend(hDlg);
return 0;
case MSG_CLOSE:
EndDialog(hDlg, 0);
break;
}
return DefaultDialogProc (hDlg, message, wParam, lParam);
}
int MiniGUIMain (int argc, const char* argv[])
{
#ifdef _MGRM_PROCESSES
JoinLayer(NAME_DEF_LAYER , "composite" , 0 , 0);
#endif
if (LoadBitmap (HDC_SCREEN, &bmp_butterfly, "res/butterfly.png"))
return 1;
DlgYourTaste.controls = CtrlYourTaste;
DialogBoxIndirectParam (&DlgYourTaste, HWND_DESKTOP, DialogBoxProc2, 0L);
UnloadBitmap (&bmp_butterfly);
return 0;
}
#ifndef _MGRM_PROCESSES
#include <minigui/dti.c>
#endif
/* Smoothing mode with speed.*/ MP_SMOOTHING_SPEED = 0, /* Smoothing mode with quality.*/ MP_SMOOTHING_QUALITY = 1,
HPEN pen = MGPlusPenCreate (2, 0xFF505050); MGPlusSetSmoothingMode (hgraphics, MP_SMOOTHING_QUALITY); MGPlusDrawEllipse (hgraphics, pen, 0, 0, 200, 100);
MPStatus MGPlusGetSmoothingMode (HGRAPHICS graphics, MPSmoothingMode* value);
MP_PATH_RENDER_HINT_ANTIALIAS_ON = 0, MP_PATH_RENDER_HINT_ANTIALIAS_OFF = 1,
HPEN pen = MGPlusPenCreate (2, 0xFF505050); MGPlusSetPathRenderingHint (hgraphics, MP_PATH_RENDER_HINT_ANTIALIAS_ON); MGPlusDrawEllipse (hgraphics, pen, 0, 0, 200, 100);
MPStatus MGPlusGetTextRenderingHint (HGRAPHICS graphics,MPTextRenderingHint* value);
MP_TEXT_RENDER_HINT_ANTIALIAS_ON = 0, MP_TEXT_RENDER_HINT_ANTIALIAS_OFF = 1,
static GLYPHMETRICS metrics;
char* test_text = "~!@#$%^&*(_)QWERTYUIOASDFGHJKL:ZXCVBNM<ertfgyubhnjgi>.";
char text[512] = {0};
GLYPHDATA data_size={0};
HFONT hfont = MGPlusCreateFont("timesi.ttf", 0, MP_GLYPH_REN_OUTLINE,60,60,true);
strcpy (text, ren_str[2]);
strcat (text, test_text);
MGPlusSetTextRenderingHint (hgraphics, MP_TEXT_RENDER_HINT_ANTIALIAS_ON);
for (i = 0; i < strlen(text); i++)
{
MGPlusGetGlyphOutline(hfont,text[i],&metrics,&data_size);
MGPlusDrawGlyph (hgraphics, hfont, x, y, &data_size, 0xff908070);
x += metrics.adv_x;
y += metrics.adv_y;
}MPStatus MGPlusGetTextRenderingHint (HGRAPHICS graphics,MPTextRenderingHint* value);
MPStatus MGPlusSetWorldTransform(HGRAPHICS graphics, MGPlusMatrix *matrix);
/*
*[ sx, shy, 0 ]
*| shx, sy , 0 |
*[ tx, ty , 0 ]
*/
struct MgPlusMatrix
{
double sx, shy, shx, sy, tx, ty;; //transformation matrix
};MGPlus MGPlusResetWorldTransform(HGRAPHICS graphics);
MPStatus MGPlusTranslateWorldTransform (HGRAPHICS graphics, float dx, float dy);
MGPlus MGPlusScaleWorldTransform(HGRAPHICS graphics, float sx, float sy);
MPStatus MGPlusRotateWorldTransform(HGRAPHICS graphics, float angle);
......
static ARGB b [3] = {0xFFFF0000, 0xFF00FF00, 0xFFFF00FF};
static MPPOINT zeropoint = {70,105};
static RECT zerorect = {50,50,200,200};
HWND hWnd;
HDC hdc;
......
HGRAPHICS hGraphics;
HPATH hPath;
HBRUSH hBrush;
......
hdc = BeginPaint(hWnd);
//创建graphics、路径和画刷
hGraphics = MGPlusGraphicCreateFromDC(hdc);
hPath = MGPlusPathCreate(0);
hBrush = MGPlusBrushCreate(MP_BRUSH_TYPE_PATHGRADIENT);
//设置画刷
MGPlusSetPathGradientBrushCenterPoint (hBrush, &zeropoint);
MGPlusSetPathGradientBrushCenterColor (hBrush, 0xFF0000FF);
MGPlusSetPathGradientBrushSurroundColors (hBrush,b,3);
MGPlusSetPathGradientBrushSurroundRect (hBrush, &zerorect);
//绘制图形并填充
MGPlusPathAddRectangle(hPath, 100, 100, 100, 100);
MGPlusFillPath (hGraphics, hBrush, hPath);
//世界坐标系的转换(平移、缩放和旋转)
MGPlusTranslateWorldTransform (hGraphics, -100, -100);
MGPlusScaleWorldTransform(hGraphics, 2, 1);
MGPlusRotateWorldTransform (hGraphics, 70);
MGPlusTranslateWorldTransform (hGraphics, 100, 100);
//重新填充转换后的图形
MGPlusFillPath (hGraphics, hBrush, hPath);
//保存graphics
MGPlusGraphicSave (hGraphics, hdc, 0, 0, 0, 0, 0, 0);
//释放内存空间
MGPlusBrushDelete(hBrush);
MGPlusPathDelete(hPath);
MGPlusGraphicDelete(hGraphics);
EndPaint(hWnd,hdc);
......
HFONT MGPlusCreateFont (const char* font_name, unsigned face_index, MPGlyphRendering ren_type, unsigned int width, unsigned int height, BOOL flip_y)
/* retrieves the glyph bitmap direct from ft2. */ MP_GLYPH_REN_NATIVE_MONO, MP_GLYPH_REN_NATIVE_GRAY8, /* retrieves the curve data points in the rasterizer's native * format and uses the font's design units. */ MP_GLYPH_REN_OUTLINE, /* retrieves the glyph bitmap from agg render. */ MP_GLYPH_REN_AGG_MONO, MP_GLYPH_REN_AGG_GRAY8, /* only retrieves the GLYPHMETRICS structure specified by lpgm.*/ MP_GLYPH_REN_METRICS,
MPStatus MGPlusGetGlyphOutline (HFONT hfont, unsigned uchar,LPGLYPHMETRICS lpgm, LPGLYPHDATA lpdata);
typedef struct _GLYPHMETRICS {
/* Specifies the x- and y-coordinates of the upper left
* corner of the smallest rectangle that completely encloses the glyph.
*/
unsigned char bbox_x;
unsigned char bbox_y;
/* Specifies the width or height of the smallest rectangle that
* completely encloses the glyph (its box).
*/
unsigned char bbox_w;
unsigned char bbox_h;
/* Specifies the horizontal/vertical distance from the origin of the current
* character cell to the origin of the next character cell.
*/
short adv_x;
short adv_y;
} GLYPHMETRICS, *LPGLYPHMETRICS;MPStatus MGPlusDrawGlyph (HGRAPHICS graphics, HFONT hfont,int x, int y, LPGLYPHDATA lpdata, ARGB color);
HPATH MGPlusGetGlyphPath (int x, int y, LPGLYPHDATA lpdata)
MGPlusDeleteFont (HFONT hfont);
......
HDC hdc;
HWND hMainhWnd;
......
hdc = GetClientDC(hMainhWnd);
HGRAPHICS hgraphics = MGPlusGraphicCreateFromDC(hdc);
int i = 0;
float x =200;
float y = 116;
float angle = 5;
GLYPHMETRICS metrics;
char* text = "GLYPH OUTLINE: ABCDEFG HIJKLMNOPQRSTUVWXYZ,abcdefghijklmnopqrstuvwxyz.";
GLYPHDATA glyph_data = {0};
int orig_x = x, orig_y = y;
//创建矢量字体
HFONT hfont = MGPlusCreateFont ("timesi.ttf", 0, MP_GLYPH_REN_OUTLINE, 18, 18, TRUE);
//创建画刷,以及颜色的设置
hbrush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR);
MGPlusSetSolidBrushColor (hbrush, 0xFF009000);
for (i = 0; i < strlen(text); i++) {
//获取字体的轮廓
MGPlusGetGlyphOutline (hfont, text[i], &metrics, &glyph_data)
//获取字体的轮廓的路径结构
hpath = MGPlusGetGlyphPath (x, y, &glyph_data);
if (hpath != NULL){
/* Transform used path Martix.*/
//路径的转换
MGPlusPathTranslate (hpath, -orig_x, -orig_y) ;
MGPlusPathRotate (hpath, angle);
MGPlusPathTranslate (hpath, orig_x, orig_y) ;
MGPlusPathTransform (hpath);
//填充路径
MGPlusFillPath(hgs, hbrush, hpath);
//重设路径
MGPlusPathReset(hpath);
MGPlusPathDelete(hpath);
}
x += metrics.adv_x;
y += metrics.adv_y;
}
MGPlusBrushDelete(hbrush);
MGPlusGraphicSave(hgraphics, hdc, 0, 0, 0, 0, 0, 0);
MGPlusDeleteFont (hfont);
MGPlusGraphicDelete(hgraphics);
ReleaseDC(hdc);
......
HPATH path; path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE);//path为奇偶规则填充
MPStatus MGPlusPathDelete(HPATH path);
MPStatus MGPlusPathReset(HPATH path);
MPStatus MGPlusFillPath (HGRAPHICS graphics, HBRUSH brush, HPATH path)
MPStatus MGPlusAddPathLine(HPATH path, float x1, float y1, float x2, float y2); MPStatus MGPlusAddPathLineI(HPATH path, int x1, int y1, int x2, int y2);
MGState MGPlusPathAddLines (HPATH path, const Point* points, int count);
//定义HDC
HDC hdc ;
hdc = GetClientDC (hWnd);
//传入 HDC 创建graphics
HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc);
//创建画刷,填充模式为单色。
HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR);
//设置画刷的颜色为蓝色
MGPlusSetSolidBrushColor (brush, 0xFF0000FF);
//创建路径选择奇偶缠绕规则
HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE);
//创建一组顶点
MPPOINT point_lines[] = {{0, 0},{100, 0},{100,100},{0, 100}};
//将lines添加到路径path,并且通知顶点的数目为4。
MGPlusPathAddLines ( path, point_lines, 4);
//填充路径
MGPlusFillPath (graphics, brush, path);
//将Graphics画布中的内容输出到指定设备DC上
MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0);
// .
// .
// .
// .
// .
// .
// .
// Destroy....释放内存
MPStatus MGPlusPathAddArc(HPATH path, float cx, float cy, float rx, float ry,float startAngle, float sweepAngle); MPStatus MGPlusPathAddArcI(HPATH path, int cx, int cy, int rx, int ry,float startAngle, float sweepAngle);
//定义HDC HDC hdc ; hdc = GetClientDC (hWnd); //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷,填充模式为单色。 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷的颜色为蓝色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //创建路径选择奇偶缠绕规则 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE); //(200, 200)为椭圆的圆心,(100, 100)为半径, 90为弧线开始角度,180为开始角和结束角之间的弧度。 MGPlusPathAddArc (path , 200,200,100,100,90, 180); //填充路径 MGPlusFillPath (graphics, brush, path); //将Graphics画布中的内容输出到指定设备DC上 MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusPathAddBezier(HPATH path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); MPStatus MGPlusPathAddBezierI(HPATH path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
//定义HDC
HDC hdc ;
hdc = GetClientDC (hWnd);
//传入 HDC 创建graphics
HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc);
//创建画刷,填充模式为单色。
HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR);
//设置画刷的颜色为蓝色
MGPlusSetSolidBrushColor (brush, 0xFF0000FF);
//创建路径选择奇偶缠绕规则
HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE);
//创建一组顶点
MPPOINT point_lines[] = {{0, 0},{100, 0},{100,100},{0, 100}};
//将Bezier添加到路径path,(11, 11) 为起点,(88, 333)为第一控制点,(99, 0)为第二控制点,(222, 111)为结束点。
MGPlusPathAddBezier(path, 11,11, 88,333, 99,0, 222,111);
//将Graphics画布中的内容输出到指定设备DC上
MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0);
// .
// .
// .
// .
// .
// .
// .
// Destroy....释放内存
MPStatus MGPlusPathAddRectangle(HPATH path, float x, float y, float width, float height); MPStatus MGPlusPathAddRectangleI(HPATH path, int x, int y, int width, int height);
//定义HDC HDC hdc ; hdc = GetClientDC (hWnd); //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷,填充模式为单色。 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷的颜色为蓝色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //创建路径选择奇偶缠绕规则 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE); //添加3个矩形到路径path MGPlusPathAddRectangle( path, 50, 100, 100, 100); MGPlusPathAddRectangle( path, 75, 150, 100, 100); MGPlusPathAddRectangle( path, 100, 175, 100, 100); //填充路径 MGPlusFillPath (graphics, brush, path); //将Graphics画布中的内容输出到指定设备DC上 MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0); // . // . // . // . // . // . // . // Destroy....释放内存

MGPlusPathAddRoundRectEx (HPATH path, int x, int y, int width, int height, int rx, int ry)
//定义HDC HDC hdc ; hdc = GetClientDC (hWnd); //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷,填充模式为单色。 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷的颜色为蓝色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //创建路径选择奇偶缠绕规则 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE); //添加圆角矩形到路径path MGPlusPathAddRoundRectEx(path, 100, 375, 100 ,100 ,10,10); //填充路径 MGPlusFillPath (graphics, brush, path); //将Graphics画布中的内容输出到指定设备DC上 MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusPathAddEllipse(HPATH path, float cx, float cy, float rx, float ry, BOOL clockwise); MPStatus MGPlusPathAddEllipseI(HPATH path, int cx, int cy, int rx, int ry, BOOL clockwise);
//定义HDC HDC hdc ; hdc = GetClientDC (hWnd); //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷,填充模式为单色。 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷的颜色为蓝色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //创建路径选择非零缠绕规则 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_WINDING); //添加矩形 MGPlusPathAddRectangle( path, 625, 350, 200, 75); //添加圆到路径path,(675, 425)为椭圆圆心, (25 ,25)为椭圆的x-radius、y-radiusTRUE为顺时针、FALSE为逆时针。 MGPlusPathAddEllipse( path, 675, 425,25 ,25, FALSE ); MGPlusPathAddEllipse( path,775, 425,25 ,25, TRUE); //填充路径 MGPlusFillPath (graphics, brush, path); //将Graphics画布中的内容输出到指定设备DC上 MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0); // . // . // . // . // . // . // . // Destroy....释放内存

MGPStatus MGPlusPathAddCurve (HPATH path, const POINT* points, int count);
//定义HDC HDC hdc ; hdc = GetClientDC (hWnd); //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷,填充模式为单色。 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷的颜色为蓝色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //创建路径选择非零缠绕规则 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_WINDING); //添加矩形 MPPOINT point [4]; point [0].x = 25.6; point [0].y = 128.0; point [1].x = 102.4; point [1].y = 230.4; pointe [2].x = 153.6; pointe [2].y = 25.6; point [3].x = 230.4; point [3].y = 128; MGPlusPathAddCurve (path, point, 4); //填充路径 MGPlusFillPath (graphics, brush, path); //将Graphics画布中的内容输出到指定设备DC上 MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusPathAddPath (HPATH path, HPATH add_path);
//定义HDC HDC hdc ; hdc = GetClientDC (hWnd); //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷,填充模式为单色。 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷的颜色为蓝色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //创建路径选择非零缠绕规则 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_WINDING); //在path中添加路径 MGPlusPathAddRectangle( path, 625, 350, 200, 75); MGPlusPathAddEllipse( path, 675, 425,25 ,25, FALSE ); MGPlusPathAddEllipse( path,775, 425,25 ,25, TRUE); //创建目标路径 HPATH add_path = MGPlusPathCreate (MP_PATH_FILL_MODE_WINDING); //将path中的内容添加到add_path中 MPStatus MGPlusPathAddPath (add_path, path); //填充路径 MGPlusFillPath (graphics, brush, add_path); //将Graphics画布中的内容输出到指定设备DC上 MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0); // . // . // . // . // . // . // . // Destroy....释放内存
MPStatus MGPlusDrawPath (HGRAPHICS graphics, HPEN pen, HPATH path);
//定义HDC HDC hdc ; hdc = GetClientDC (hWnd); //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画笔,画笔宽度为9,颜色为蓝色。 HPEN pen = MGPlusPenCreate (9, 0xFF0000FF); //创建路径选择非零缠绕规则 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_WINDING); //添加矩形 MGPlusPathAddRectangle( path, 625, 350, 200, 75); //添加圆到路径path,(675, 425)为椭圆圆心, (25 ,25)为椭圆的x-radius、y-radiusTRUE为顺时针、FALSE为逆时针。 MGPlusPathAddEllipse( path, 675, 425,25 ,25, FALSE ); MGPlusPathAddEllipse( path,775, 425,25 ,25, TRUE); //绘制路径 MGPlusDrawPath (graphics, pen, path); //将Graphics画布中的内容输出到指定设备DC上 MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0); // . // . // . // . // . // . // . // Destroy....释放内存

MGPStatus MGPlusPathStartFigure (HPATH path);
MGPStatus MGPlusPathCloseFigure (HPATH paht);
//定义HDC HDC hdc ; hdc = GetClientDC (hWnd); //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画笔 HPEN pen = MGPlusPenCreate(9, 0xFF0000FF); //创建路径 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE); //开建一个新的路径图形。 MGPlusPathStartFigure(path); //添加两条直线 MGPlusPathAddLine (path, 100, 100, 200, 10); MGPlusPathAddLine (path, 200, 10, 300, 100); //闭合路径 MGPlusPathCloseFigure(path); //绘制路径 MGPlusDrawPath (graphics, pen, path); //将Graphics画布中的内容输出到指定设备DC上 MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusPathMoveto (HPATH path, float x, float y); MPStatus MGPlusPathMovetoI (HPATH path, int x, int y);
MPStatus MGPlusPathLineto (HPATH path, float x, float y); MPStatus MGPlusPathLinetoI (HPATH path, int x, int y);
//定义HDC HDC hdc ; hdc = GetClientDC (hWnd); //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画笔 HPEN pen = MGPlusPenCreate(9, 0xFF0000FF); //创建路径 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE); //设置 MGPlusPathMoveto (path, 100,100); MGPlusPathLineto (path, 200,100); MGPlusPathLineto (path, 200,200); MGPlusPathMoveto (path, 100,200); //绘制路径 MGPlusDrawPath (graphics, pen, path); //将Graphics画布中的内容输出到指定设备DC上 MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0); // . // . // . // . // . // . // . // Destroy....释放内存

//获取路径顶点 MPStatus MGPlusPathGetPointCount(HPATH path, int* count); //获取路径顶点个数 MPStatus MGPlusPathGetPoints (HPATH path, int* count, MPPOINT** pt); //获取指定序号的顶点,并读取顶点类型。 MPStatus MGPlusPathGetVertex (HPATH path, int idx, double* x, double* y, int* cmd); //设置一个点,以这个顶点为中心进行旋转路径 MGPlusPathRotateAroundPoint(HPATH path, const MPPOINT* pt, float angle); //设置路径的绘制方向 MPStatus MGPlusPathSetAllOrientation (HPATH path, MPOrientation orientation);
//定义HDC
HDC hdc ;
hdc = GetClientDC (hWnd);
//传入 HDC 创建graphics
HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc);
//创建画笔
HPEN pen = MGPlusPenCreate(9, 0xFF0000FF);
//创建路径
HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE);
//添加一个矩形
MGPlusPathAddRectangleI (path, 100, 100, 200, 100);
int i = 0, count=0;
MPPOINT* pt = NULL;
MPPOINT center = {100.0, 50.0};
//获取路径顶点个数
MGPlusPathGetPointCount (path ,&count);
//获取路径顶点
MGPlusPathGetPoints (path, &count, &pt);
double x = 0;
double y = 0;
int cmd = 0;
////获取第2的顶点,并读取顶点类型。
MGPlusPathGetVertex (path, 2, &x, &y, &cmd);
//设置一个点,一这个顶点为中心进行旋转
MGPlusPathRotateAroundPoint (path, ¢er, -10);
//应用矩阵转换
MGPlusPathTransform (path) ;
//设置路径的绘制方向
MGPlusPathSetAllOrientation (path, MP_ORIENTATION_CW);
//填充路径
MGPlusDrawPath(graphics, brush, pen);
//将Graphics画布中的内容输出到指定设备DC上
MGPlusGraphicSave(graphics, hdc, 0, 0, 0, 0, 0, 0);
// .
// .
// .
// .
// .
// .
// .
// Destroy....释放内存
MPStatus MGPlusPathSetTransform (HPATH path, MPMatrix *matrix);
/*
*[ sx, shy, 0 ]
*| shx, sy , 0 |
*[ tx, ty , 0 ]
*/
struct MgPlusMatrix
{
double sx, shy, shx, sy, tx, ty;; //transformation matrix
};MPStatus MGPlusPathResetTransform(HPATH path);
MPStatus MGPlusPathTranslate(HPATH path, float dx, float dy);
MPStatus MGPlusPathScale(HPATH path, float sx, float sy);
MPStatus MGPlusPathRotate(HPATH path, float angle);
MGPLUS_EXPORT MPStatus MGPlusPathTransform (HPATH path);
...... HWND hWnd; HDC hdc; ...... HGRAPHICS hgs; HPATH hpath; HBRUSH hbrush; ...... hdc = BeginPaint(hWnd); //创建graphics,画刷和路径 hgs = MGPlusGraphicCreateFromDC(hdc); hbrush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); hpath = MGPlusPathCreate (MP_PATH_FILL_MODE_WINDING); //设置画刷的颜色 MGPlusSetSolidBrushColor (hbrush, 0xFF009000); //绘制并填充图形 MGPlusPathAddRectangle (hpath, 50, 50, 100, 100); MGPlusFillPath(hgs, hbrush, hpath); //平移 MGPlusPathTranslate (hpath, 50, 50); //缩放 MGPlusPathScale (hpath, 2, 1); //旋转 MGPlusPathRotate (hpath, 30); //应用矩阵转换 MGPlusPathTransform (hpath); //重新填充图形,并应用了转换 MGPlusFillPath(hgs, hbrush, hpath); //保存 MGPlusGraphicSave(hgs, hdc, 0,0,0,0,0,0); //释放内存空间 MGPlusBrushDelete(hbrush); MGPlusPathDelete(hpath); MGPlusGraphicDelete(hgs); EndPaint(hWnd,hdc); ......
HPEN MGPlusPenCreate (int width, ARGB argb);
MPStatus MGPlusPenDelete (HPEN pen);
MPStatus MGPlusPenSetColor (HPEN pen, ARGB rgba)
MPStatus MGPlusPenSetWidth (HPEN pen, int width)
MPStatus MGPlusPenSetDashes (HPEN pen, int dash_phase, const unsigned char* dash_list, int dash_len)
/* * Indicates a mitered line join style. See the class overview for an * illustration. */ JOIN_MITER = 0, /* * Indicates a rounded line join style. See the class overview for an * illustration. */ JOIN_ROUND = 1, /* * Indicates a bevelled line join style. See the class overview for an * illustration. */ JOIN_BEVEL = 2, /* reseverd,not used now, but surport by mgplus.*/ JOIN_MILTER_REVERT = 3, JOIN_MILTER_ROUND = 4
MPStatus MGPlusPenSetJoinStyle (HPEN pen, LINE_JOIN_E line_join);
/* * Indicates a flat line cap style. See the class overview for an * illustration. */ CAP_BUTT = 0, /* * Indicates a rounded line cap style. See the class overview for an * illustration. */ CAP_ROUND = 1, /* * Indicates a square line cap style. See the class overview for an * illustration. */ CAP_SQUARE = 2,
MPStatus MGPlusPenSetCapStyle (HPEN pen, LINE_CAP_E line_cap);
static int joinstyle ;
static int capstyle ;
static int radius = 10;
static RECT rcCircle = {0, 60, 400, 300};
static const char *mode[] =
{
"JOIN_MITER",
"JOIN_ROUND",
"JOIN_BEVEL",
"JOIN_MILTER_REVERT",
"JOIN_MILTER_ROUND",
/*
"CAP_BUTT",
"CAP_ROUND",
"CAP_SQUARE",
*/
};
static void mode_notif_proc (HWND hwnd, int id, int nc, DWORD add_data)
{
if (nc == CBN_SELCHANGE) {
int cur_sel = SendMessage (hwnd, CB_GETCURSEL, 0, 0);
if (cur_sel >= 0) {
joinstyle = cur_sel;
//capstyle = cur_sel;
InvalidateRect (GetParent (hwnd), &rcCircle, TRUE);
}
}
}
static void my_notif_proc (HWND hwnd, int id, int nc, DWORD add_data)
{
if (nc == TBN_CHANGE) {
radius = SendMessage (hwnd, TBM_GETPOS, 0, 0);
InvalidateRect (GetParent (hwnd), &rcCircle, TRUE);
}
}
int PenProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
HWND hwnd1, hwnd2;
HDC hdc;
int i ;
ARGB color = 0xFF00FF00;
switch (message)
{
case MSG_CREATE:
{
hwnd1 = CreateWindow (CTRL_TRACKBAR, "",
WS_VISIBLE | TBS_NOTIFY,
100,
10, 10, 210, 50, hWnd, 0);
SendMessage (hwnd1, TBM_SETRANGE, 0, 80);
SendMessage (hwnd1, TBM_SETLINESIZE, 1, 0);
SendMessage (hwnd1, TBM_SETPAGESIZE, 10, 0);
SendMessage (hwnd1, TBM_SETTICKFREQ, 10, 0);
SendMessage (hwnd1, TBM_SETPOS, radius, 0);
SetNotificationCallback (hwnd1, my_notif_proc);
SetFocus (hwnd1);
hwnd2 = CreateWindow (CTRL_COMBOBOX,"",
WS_VISIBLE | CBS_DROPDOWNLIST | CBS_NOTIFY,
120,
250, 10, 150, 40, hWnd, 0 );
// for (i = 0; i < 3 ; i++) {
for (i = 0; i < 5 ; i++) {
SendMessage(hwnd2, CB_ADDSTRING, 0, (LPARAM)mode[i]);
}
SetNotificationCallback (hwnd2, mode_notif_proc);
SendMessage(hwnd2, CB_SETCURSEL, 0, 0);
}
break;
case MSG_PAINT:
{
hdc = BeginPaint(hWnd);
//创建MGPlusGraphics和画笔
HGRAPHICS gpc = MGPlusGraphicCreateFromDC(hdc);
HPEN pen = MGPlusPenCreate (radius,color);
//capstyle
/*
MGPlusPenSetCapStyle (pen, capstyle);
MGPlusDrawLine(gpc, pen, 50, 150, 300, 150);
*/
//joinstyle
MGPlusPenSetJoinStyle (pen, joinstyle);
MGPlusDrawRectangle(gpc, pen, 100, 100, 200, 180);
//保存
MGPlusGraphicSave (gpc, hdc, 0, 0, 0, 0, 0, 0);
MGPlusPenDelete (pen);
MGPlusGraphicDelete (gpc);
EndPaint (hWnd, hdc);
}
break;
case MSG_CLOSE:
DestroyMainWindow(hWnd);
PostQuitMessage(hWnd);
return 0;
}
return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
......MPStatus MGPlusDrawLine(HGRAPHICS graphics, HPEN pen, float x1, float y1, float x2, float y2); MPStatus MGPlusDrawLineI(HGRAPHICS *graphics, HPEN pen, int x1, int y1, int x2, int y2);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画笔,画笔宽度为9,颜色为蓝色。 HPEN pen = MGPlusPenCreate (9, 0xFF0000FF); //绘制3条直线 MGPlusDrawLine (graphics, pen, 100, 100, 100, 200); MGPlusDrawLine (graphics, pen, 100, 200, 200, 200); MGPlusDrawLine (graphics, pen, 200, 200, 200, 100); MGPlusDrawLine (graphics, pen, 200, 100, 100, 100); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusDrawArc(HGRAPHICS graphics, HPEN pen, float cx, float cy, float rx, float ry, float startAngle, float sweepAngle); MPStatus MGPlusDrawArcI(HGRAPHICS graphics, HPEN pen, int cx, int cy, int rx, int ry, float startAngle, float sweepAngle);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画笔,画笔宽度为9,颜色为蓝色。 HPEN pen = MGPlusPenCreate (9, 0xFF0000FF); //绘制弧线椭圆圆心为(100, 100)半径(50, 25)开始角度90,结束角度345,绘制出的结果就是椭圆90-345之间的距离 MGPlusDrawArc (graphics, pen, 100, 100, 50, 25, 90, 345); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusDrawBezier(HGRAPHICS graphics, HPEN pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); MPStatus MGPlusDrawBezierI(HGRAPHICS graphics, HPEN pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画笔,画笔宽度为9,颜色为蓝色。 HPEN pen = MGPlusPenCreate (9, 0xFF0000FF); //绘制贝塞尔曲线 MGPlusDrawBezier(graphics, pen ,11,11, 88,333, 99,0, 222,111); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusDrawRectangle(HGRAPHICS graphics, HPEN pen, float x, float y, float width, float height); MPStatus MGPlusDrawRectangleI(HGRAPHICS graphics, HPEN pen, int x, int y, int width, int height);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画笔,画笔宽度为9,颜色为蓝色。 HPEN pen = MGPlusPenCreate (9, 0xFF0000FF); //绘制矩形 MGPlusDrawRectangle(graphics, pen, 50, 100, 100, 100); MGPlusDrawRectangle(graphics, pen, 75, 150, 100, 100); MGPlusDrawRectangle(graphics, pen, 100, 175, 100, 100); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusDrawRoundRectIEx (HGRAPHICS graphics, HPEN pen, int x, int y, int width, int height, int rx, int ry); MPStatus MGPlusDrawRoundRectEx (HGRAPHICS graphics, HPEN pen, float x, float y, float width, float height, float rx, float ry);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画笔,画笔宽度为9,颜色为蓝色。 HPEN pen = MGPlusPenCreate (9, 0xFF0000FF); //绘制圆角矩形 MGPlusDrawRoundRectEx(graphics, pen, 100, 375, 100 ,100 ,10,10); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusDrawEllipse(HGRAPHICS graphics, HPEN pen, float cx, float cy,float rx, float ry, BOOL b_clock); MPStatus MGPlusDrawEllipseI(HGRAPHICS graphics, HPEN pen, int cx, int cy, int rx, int ry, BOOL b_clock);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画笔,画笔宽度为9,颜色为蓝色。 HPEN pen = MGPlusPenCreate (9, 0xFF0000FF); //绘制椭圆 MGPlusDrawEllipse(graphics, pen, 100, 100, 50 , 25); // . // . // . // . // . // . // . // Destroy....释放内存

//从文件加载一个设备相关位图 LoadBitmap (HDC hdc, PBITMAP bmp, const char* file_name); //转换为graphic兼容格式的位图 MPStatus MGPlusGraphicLoadBitmap (HGRAPHICS graphics, int n_index, PBITMAP p_bitmap);
//直接转换为graphic兼容格式的位图 MPStatus MGPlusGraphicLoadBitmapFromFile(HGRAPHICS graphics, int n_index, char* file);
//n_index 图片索引值, (x, y)起始位置 ,(w, h)图片的宽高。 MPStatus MGPlusDrawImage (HGRAPHICS graphics, int n_index, int x, int y, int w, int h);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //加载图片 MGPlusGraphicLoadBitmapFromFile (graphics, 0,"File.bmp" ); //绘制图片 MGPlusDrawImage (graphics, 0, 100, 100, 200, 200); // . // . // . // . // . // . // . // Destroy....释放内存

//n_index 图片索引值, point 一组顶点,count顶点数目。 MPStatus MGPlusDrawImageWithPoints (HGRAPHICS graphics, int n_index, const Point& point, int count);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //加载图片 static BITMAP Bitmap; LoadBitmap (HDC_SCREEN, &Bitmap, "./res/wede.bmp"); MGPlusGraphicLoadBitmap (graphics, 1, &Bitmap); //绘制图片 MPPOINT points [4]; points [0].x = 100; points [0].y = 50; points [1].x = 200; points [1].y = 50; points [2].x = 300; points [2].y = 200; points [3].x = 0; points [3].y = 200; MGPlusDrawImageWithPoints (graphics, 1, points, 4); // . // . // . // . // . // . // . // Destroy....释放内存

//n_index 图片索引值, path 目标路径。 MGPlusDrawImageWithPath(HGRAPHICS graphics, int n_index, HPATH path);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //加载图片 MGPlusGraphicLoadBitmapFromFile (graphics, 0,"./res/wede.bmp" ); //必须有路径存在才能绘制出图像,所以首先创建一个路径。 HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE); MGPlusPathAddRoundRect (path, 100, 100, 200, 200, 20); //在路径中绘制图像 MGPlusDrawImageWithPath (graphics, 0, path); // . // . // . // . // . // . // . // Destroy....释放内存

typedef enum _MPBrushType
{
/* Brush the path with the single color.*/
MP_BRUSH_TYPE_SOLIDCOLOR = 0,
/* Brush the path with the hatchfill.*/
MP_BRUSH_TYPE_HATCHFILL = 1,
/* Brush the path with the texturefill.*/
MP_BRUSH_TYPE_TEXTUREFILL = 2,
/* Brush the path with the path gradient.*/
MP_BRUSH_TYPE_PATHGRADIENT = 3,
/* Brush the path with linear gradient.*/
MP_BRUSH_TYPE_LINEARGRADIENT
}MPBrushType;
HBRUSH MGPlusBrushCreate (MGPlusBrushType type);MPStatus MGPlusBrushDelete (HBRUSH brush);
MPStatus MGPlusSetSolidBrushColor (HBRUSH brush, RGBA* rgba);
MPStatus MGPlusSetPathGradientBrushCenterPoint (HBRUSH brush, POINT* point);
MPStatus MGPlusSetPathGradientBrushCenterColor (HBRUSH brush, RGBA* rgba);
MPStatus MGPlusSetPathGradientBrushSurroundColor (HBRUSH brush, RGBA rgba);
MPStatus MGPlusSetPathGradientBrushSurroundRect (HBRUSH brush, RECT* rect);
//创建 MP_BRUSH_TYPE_PATHGRADIENT 风格的画刷
HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_PATHGRADIENT);
//创建一个路径
HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE);
//在路径中添加图形
MGPlusPathAddRectangle (path, 25, 150, 300, 100);
MGPlusPathAddEllipse (path, 100, 250, 50, 50, TRUE);
MGPlusPathAddEllipse (path,250, 250, 50, 50, TRUE);
//设置中心点
MPPOINT point = {170,225};
MGPlusSetPathGradientBrushCenterPoint (brush, &point);
//设置中心点的颜色
MGPlusSetPathGradientBrushCenterColor (brush, 0xFF0000FF);
//设置缠绕颜色
static ARGB SurroundColors [3] = {0xFFFF00FF, 0xFF00FF00, 0xFFFF0000};
MGPlusSetPathGradientBrushSurroundColors (brush, SurroundColors, 3);
//设置弧形渐变的范围
RECT rect = {25,150,325,250};
MGPlusSetPathGradientBrushSurroundRect (brush, &rect);
//填充路径
MGPlusFillPath (graphics, brush, path);
//保存到DC
MGPlusGraphicSave (graphics, hdc, 0, 0, 0, 0, 0, 0);
typedef enum _MPLinearGradientMode
{
/* gradient horizontal.*/
MP_LINEAR_GRADIENT_MODE_HORIZONTAL = 0,
/* gradient vertica.*/
MP_LINEAR_GRADIENT_MODE_VERTICAL,
/* gradient forwarddiagonal.*/
MP_LINEAR_GRADIENT_MODE_FORWARDDIAGONAL,
/* gradient backwarddiagonal.*/
MP_LINEAR_GRADIENT_MODE_BACKWARDDIAGONAL
}MPLinearGradientMode;
MPStatus MGPlusSetLinearGradientBrushMode (HBRUSH brush, MGPlusLinearGradientMode mode);MPStatus MGPlusGetLinearGradientBrushMode (HBRUSH brush, MGPlusLinearGradientMode* mode);
MPStatus MGPlusSetLinearGradientBrushRect (HBRUSH brush, RECT* rect);
MPStatus MGPlusSetLinearGradientBrushColor (HBRUSH brush, RGBA* start_color, RGBA* end_color);
//创建 MP_BRUSH_TYPE_LINEARGRADIENT 风格的画刷
HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_LINEARGRADIENT);
//创建一个路径
HPATH path = MGPlusPathCreate (MP_PATH_FILL_MODE_ALTERNATE);
//在路径中添加图形
MGPlusPathAddRectangle (path, 25, 150, 300, 100);
MGPlusPathAddEllipse (path, 100, 250, 50, 50, TRUE);
MGPlusPathAddEllipse (path,250, 250, 50, 50, TRUE);
//设置画刷为MP_LINEAR_GRADIENT_MODE_HORIZONTAL 模式
MGPlusSetLinearGradientBrushMode (brush, MP_LINEAR_GRADIENT_MODE_HORIZONTAL);
//设置LinearGradientBrush区域
static RECT rect = {25,150,325,250};
MGPlusSetLinearGradientBrushRect (brush, &rect);
// 设置LinearGradientBrush渐变颜色
static ARGB color [6] = {0xFFFF0000, 0xFF0000FF,0xFFFF00FF, 0xff00FFFF,0xff00FF00, 0xFF00FF00};
MGPlusSetLinearGradientBrushColors (brush, color, 6);
//填充路径
MGPlusFillPath (graphics, brush, path);
//保存到DC
MGPlusGraphicSave (graphics, hdc, 0, 0, 0, 0, 0, 0);



MPStatus MGPlusFillArc (HGRAPHICS graphics, HBRUSH brush, float cx, float cy, float rx, float ry, float startAngle, float sweepAngle); MPStatus MGPlusFillArcI (HGRAPHICS graphics, HBRUSH brush, int cx, int cy, int rx, int ry, float startAngle, float sweepAngle);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷颜色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //填充弧线 MGPlusFillArc (graphics, brush, 100, 100, 50, 50, 90, 180); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusFillBezier (HGRAPHICS graphics, HBRUSH brush, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); MPStatus MGPlusFillBezierI (HGRAPHICS graphics, HBRUSH brush, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷颜色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //填充贝塞尔曲线 MGPlusFillBezier (graphics, brush, 11,11, 88,333, 99,0, 222,111); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusFillRectangle (HGRAPHICS graphics, HBRUSH brush, float x, float y, float width, float height); MPStatus MGPlusFillRectangleI (HGRAPHICS graphics, HBRUSH brush, int x, int y, int width, int height);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷颜 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //填充矩形 MGPlusFillRectangleI (graphics, brush, 100, 175, 100, 100); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusFillRoundRectIEx (HGRAPHICS graphics, HBRUSH brush, int x, int y, int width, int height, int rx, int ry); MPStatus MGPlusFillRoundRectEx (HGRAPHICS graphics, HBRUSH brush, float x, float y, float width, float height, float rx, float ry);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷颜色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //填充圆角矩形 MGPlusFillRoundRectIEx ( graphics, brush, 100, 375, 100 ,100 ,10,10); // . // . // . // . // . // . // . // Destroy....释放内存

MPStatus MGPlusFillEllipse (HGRAPHICS graphics, HBRUSH brush, float cx, float cy, float rx, float ry); MPStatus MGPlusFillEllipseI (HGRAPHICS graphics, HBRUSH brush, int cx, int cy, int rx, int ry);
//定义HDC HDC hdc ; //传入 HDC 创建graphics HGRAPHICS graphics= MGPlusGraphicCreateFromDC(hdc); //创建画刷 HBRUSH brush = MGPlusBrushCreate (MP_BRUSH_TYPE_SOLIDCOLOR); //设置画刷颜色 MGPlusSetSolidBrushColor (brush, 0xFF0000FF); //填充椭圆 MGPlusFillEllipse (graphics, brush, 100, 100, 50 , 25); // . // . // . // . // . // . // . // Destroy....释放内存

| I | Attachment | Action | Size | Date | Who | Comment |
|---|---|---|---|---|---|---|
| | 3.png | manage | 5.9 K | 18 Jun 2009 - 17:49 | XiaodanChen | |
| | CloseFigure.png | manage | 2.3 K | 23 Jun 2009 - 18:17 | QiJinrong | |
| | Curve.png | manage | 3.9 K | 23 Jun 2009 - 15:07 | QiJinrong | |
| | DrawArc.png | manage | 3.6 K | 20 Jun 2009 - 15:00 | QiJinrong | |
| | DrawBezier.png | manage | 5.0 K | 20 Jun 2009 - 15:11 | QiJinrong | |
| | DrawEllipse.png | manage | 3.7 K | 20 Jun 2009 - 17:43 | QiJinrong | |
| | DrawImage.png | manage | 63.5 K | 22 Jun 2009 - 14:18 | QiJinrong | |
| | DrawImagePoints.png | manage | 55.7 K | 22 Jun 2009 - 14:32 | QiJinrong | |
| | DrawImageWithPath.png | manage | 63.8 K | 22 Jun 2009 - 17:50 | QiJinrong | |
| | DrawLine.png | manage | 1.2 K | 22 Jun 2009 - 17:13 | QiJinrong | |
| | DrawPath.png | manage | 3.0 K | 20 Jun 2009 - 10:01 | QiJinrong | |
| | DrawRectangle.png | manage | 1.6 K | 20 Jun 2009 - 15:28 | QiJinrong | |
| | DrawRoundRect.png | manage | 2.0 K | 20 Jun 2009 - 17:29 | QiJinrong | |
| | Ellipse.png | manage | 2.1 K | 19 Jun 2009 - 19:26 | QiJinrong | |
| | FillArc.png | manage | 1.9 K | 23 Jun 2009 - 08:59 | QiJinrong | |
| | FillBezier.png | manage | 4.1 K | 23 Jun 2009 - 09:10 | QiJinrong | |
| | FillEllipse.png | manage | 2.3 K | 23 Jun 2009 - 09:11 | QiJinrong | |
| | FillRectangle.png | manage | 1.2 K | 23 Jun 2009 - 09:11 | QiJinrong | |
| | FillRoundRect.png | manage | 1.5 K | 23 Jun 2009 - 09:11 | QiJinrong | |
| | GetPathPoints.png | manage | 3.6 K | 24 Jun 2009 - 18:46 | QiJinrong | |
| | MP_LINEAR_GRADIENT_MODE_BACKWARDDIAGONAL.png | manage | 6.9 K | 23 Jun 2009 - 13:08 | QiJinrong | |
| | MP_LINEAR_GRADIENT_MODE_FORWARDDIAGONAL.png | manage | 6.1 K | 23 Jun 2009 - 13:09 | QiJinrong | |
| | MP_LINEAR_GRADIENT_MODE_HORIZONTAL.png | manage | 4.9 K | 23 Jun 2009 - 13:11 | QiJinrong | |
| | MP_LINEAR_GRADIENT_MODE_VERTICAL.png | manage | 3.4 K | 23 Jun 2009 - 13:09 | QiJinrong | |
| | Moveto.png | manage | 1.1 K | 24 Jun 2009 - 11:52 | QiJinrong | |
| | PathGradientBrush.png | manage | 19.0 K | 23 Jun 2009 - 11:43 | QiJinrong | |
| | PathTransform.png | manage | 5.7 K | 23 Jun 2009 - 18:29 | XiaodanChen | |
| | Rectangle.png | manage | 1.5 K | 19 Jun 2009 - 19:18 | QiJinrong | |
| | arc.png | manage | 2.9 K | 19 Jun 2009 - 18:48 | QiJinrong | |
| | bezier.png | manage | 4.1 K | 19 Jun 2009 - 18:58 | QiJinrong | |
| | butterfly.png | manage | 36.0 K | 23 Jun 2009 - 10:39 | XiaodanChen | 程序中用到的图片 |
| | cap1.png | manage | 2.1 K | 24 Jun 2009 - 17:39 | XiaodanChen | |
| | cap2.png | manage | 2.2 K | 24 Jun 2009 - 17:39 | XiaodanChen | |
| | cap3.png | manage | 1.9 K | 24 Jun 2009 - 17:40 | XiaodanChen | |
| | composite.png | manage | 45.0 K | 19 Jun 2009 - 16:05 | XiaodanChen | |
| | dash.png | manage | 1.7 K | 25 Jun 2009 - 10:20 | XiaodanChen | |
| | join1.png | manage | 2.3 K | 24 Jun 2009 - 17:33 | XiaodanChen | |
| | join2.png | manage | 2.4 K | 24 Jun 2009 - 17:33 | XiaodanChen | |
| | join3.png | manage | 2.1 K | 24 Jun 2009 - 17:34 | XiaodanChen | |
| | lines.png | manage | 1.1 K | 19 Jun 2009 - 18:06 | QiJinrong | |
| | path1.png | manage | 2.9 K | 25 Jun 2009 - 10:51 | XiaodanChen | |
| | path2.png | manage | 7.7 K | 25 Jun 2009 - 10:51 | XiaodanChen | |
| | rect.png | manage | 1.1 K | 19 Jun 2009 - 19:18 | QiJinrong | |
| | text1.png | manage | 13.4 K | 25 Jun 2009 - 10:50 | XiaodanChen | |
| | text2.png | manage | 3.9 K | 25 Jun 2009 - 10:50 | XiaodanChen | |
| | width.png | manage | 1.6 K | 25 Jun 2009 - 10:20 | XiaodanChen | |
| | worldtransform.png | manage | 16.1 K | 23 Jun 2009 - 17:51 | XiaodanChen |