利用GDI书写汉字的笔画顺序

Graphics graphics(*pDC); CString str = "菈"; // CString fname = L"楷体_GB2312"; int fsize = 32; int x=0; int y=0; int spx = 5; int spy = 5; int dx=0; int dy=0; // int order[7]={1,3,2,6,4,7,5}; Pen tmppen1(Color(255,0,0)),tmppen2(Color(0,255,0)),tmppen3(Color(0,0,255)); SolidBrush tmpbrush(Color(0,255,0)); //幼圆 楷体_GB2312 FontFamily tmpfontFamily(L"仿宋_GB2312"); Font tmpfont(&tmpfontFamily,fsize,FontStyleRegular); Unit unit = tmpfont.GetUnit(); graphics.SetPageUnit(unit); graphics.SetSmoothingMode(SmoothingModeHighQuality); GraphicsPath tmppath; WCHAR *strSrc; // LPSTR szRes; //获得临时变量的大小 int i = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); strSrc = new WCHAR[i+1]; MultiByteToWideChar(CP_ACP, 0, str, -1, strSrc, i); tmppath.AddString(strSrc,-1,&tmpfontFamily,FontStyleRegular,fsize,PointF(x,y),NULL); delete []strSrc; GraphicsPathIterator iterator(&tmppath); Rect tmprect; tmppath.GetBounds(&tmprect); dx = tmprect.Width+spx; int count = iterator.GetSubpathCount(); GraphicsPath subpath; BOOL isClosed = FALSE; for (int i=0;i<count;i++) { if (i%10==0&&i!=0) { graphics.ResetTransform(); graphics.TranslateTransform(0,(tmprect.Height+spy)*i/10); } graphics.DrawPath(&tmppen1,&tmppath); // iterator.Rewind(); // for (int j=0;j<i+1;j++) { iterator.NextSubpath(&subpath,&isClosed); } // graphics.DrawPath(&tmppen2,&subpath); graphics.FillPath(&tmpbrush,&subpath); graphics.TranslateTransform(dx,dy); }

 

利用GDI+实现汉字的笔画笔顺,以上是实现的代码。

你可能感兴趣的:(null,delete,iterator,GDI+)