高分救解,在C#中使用GDI+如果使一行文字沿一条曲线路径进行排列
比如曲线是椭圆,或者是个半圆,文字就沿曲线路径的下面进行有序的排列,就象印章文字沿圆形排列一样,如能提供现成的代码最好,有解决思路和参考资料也不错,谢谢各位高手和坛友了 --------------------编程问答--------------------
--------------------编程问答-------------------- 顶1楼
private void DrawSeal()
{
RetrieveAll();
if(this.SealType == SealType.OfficeSeal)
{
DrawOfficeSeal();
}
else
{
DrawPersonalSeal();
}
panelDisplayResultBitmap.AutoScroll = true;
panelDisplayResultBitmap.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
panelDisplayResultBitmap.Invalidate();
}
//得到相关参数:
private void RetrieveAll()
{
int diameter = 220;
try
{
diameter = int.Parse(this.txtBoxDiameter.Text);
}
catch(Exception exc)
{
MessageBox.Show("输入错误的公章直径!\n请确保是整数");
}
if(diameter>1000 || diameter < 100 )
{
MessageBox.Show("公章直径输入太大或太小了!");
diameter = 220;
}
this.OfficeSealDiameter = diameter;
string fontName = this.FontlistBox.Text;
if(fontName == string.Empty)
{
fontName = "Times New Roman";
}
this.SelectedFontName = fontName;
this.SelectedFontColorFromArgb = Color.FromArgb((int)this.FontColor_A.Value,(int)this.FontColor_R.Value,
(int)this.FontColor_G.Value,(int)this.FontColor_B.Value);
}
// 画公章:
private void DrawOfficeSeal()
{
try
{
OfficeSealMaker osm = new OfficeSealMaker();
osm.FamilyName = this.SelectedFontName;
osm.IsBold = false;
osm.IsEmbedNotice = false; //是否保留“勿作他用”的提示信息
osm.Diameter = this.OfficeSealDiameter;
osm.Style = Style.PentagonalStars;//设置中间LOGO
osm.OfficeName = this.txtBoxCompanyName.Text;
osm.IsDrawInnerRect = false;
osm.WordsColor = this.SelectedFontColorFromArgb;
osm.BorderColor = this.SelectedFontColorFromArgb;
//osm.TextVerHeight = (float)this.numericUpDownFontHeight.Value;
osm.RatioX = (float)numericUpDownFontRatioX.Value / 100f;
m_Bitmap = osm.Draw();
}
catch(Exception exc)
{
MessageBox.Show(exc.Message,"发生错误");
}
}
//画私章:
private void DrawPersonalSeal()
{
//int stampWidth = int.Parse(this.txtBoxDiameter.Text);
PersonalSeal personalSeal = new PersonalSeal();
personalSeal.SealColor = this.SelectedFontColorFromArgb;
bool isYinSeal = false;
if(this.cmbBoxYinYang.SelectedItem != null && this.cmbBoxYinYang.SelectedItem.ToString() == "阴章")
{
isYinSeal = true;
}
personalSeal.IsYinSeal = isYinSeal;
string sealWords = this.txtBoxPersonalSealWords.Text.Trim();
if(sealWords.Length != 4)
{
sealWords = "美中印章";
}
personalSeal.SealWords = sealWords;
personalSeal.FontFamilyName = this.SelectedFontName;
personalSeal.IsDrawInnerBorder = false;
personalSeal.BorderWidth = 10;
personalSeal.Celling = 0;
int personalSealWidth = 100;
try
{
personalSealWidth = int.Parse(this.txtBoxWidth.Text);
}
catch(Exception exc)
{
MessageBox.Show("输入有误,请输入整数!");
}
int personalSealHeight = 100;
try
{
personalSealHeight = int.Parse(this.txtBoxHeight.Text);
}
catch(Exception exc)
{
MessageBox.Show("输入有误,请输入整数!");
}
personalSeal.Width = personalSealWidth;
personalSeal.Height = personalSealHeight;
m_Bitmap = (Bitmap)personalSeal.Draw();
}
//私人印章的画法:
public System.Drawing.Image Draw()
{
Bitmap m_Bitmap;
Color sealColor = Color.Red;
int sealWidth = this.Width;
int sealHeight = this.Height;
int celling = this.Celling;
int penWidth = this.BorderWidth;
int cornerRadius = this.CornerRadius;
Rectangle rect = new Rectangle(0, 0, sealWidth, sealHeight);
Rectangle rectInner = new Rectangle(penWidth + celling, penWidth + celling, sealWidth - (penWidth + celling) * 2, sealHeight - (penWidth + celling) * 2);
m_Bitmap = new Bitmap(sealWidth, sealHeight);
Graphics g = Graphics.FromImage(m_Bitmap);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
//g.Clear(Color.White);
Pen pen = new Pen(sealColor, penWidth);
pen.Alignment = PenAlignment.Inset;
//画个人印章的外部圆角矩形
RoundRectangeHelper.DrawRoundRectangle(g, pen, rect, cornerRadius);
pen = new Pen(this.SealColor, this.InnerBorderWidth);
if(this.IsDrawInnerBorder)
{
g.DrawRectangle(pen, rectInner);
}
//画字
Font font;
try
{
font = new Font(this.FontFamilyName, 20f);
}
catch(Exception exc)
{
font = new Font("Times New Roman",20f);
}
Color fillColor;
if(this.IsYinSeal)
{
fillColor = Color.White;
g.FillRectangle(new SolidBrush(this.SealColor), rectInner);
}
else
{
fillColor = this.SealColor;
}
string word = this.SealWords;
int[] orderSrc = {1,2,3,4};
int[] orderDest = {2,4,1,3};
char[] words = word.ToCharArray();
char[] wordsTmp = new char[words.Length];
words.CopyTo(wordsTmp, 0);
for(int i = 0; i < orderSrc.Length; i++)
{
words[orderDest[i] - 1] = wordsTmp[orderSrc[i] - 1];
}
Rectangle rect1 = new Rectangle(rectInner.X, rectInner.Y, rectInner.Width/2, rectInner.Height/2);
Rectangle rect2 = new Rectangle(rectInner.X + rectInner.Width/2, rectInner.Y, rectInner.Width/2, rectInner.Height/2);
Rectangle rect3 = new Rectangle(rectInner.X, rectInner.Y + rectInner.Height/2, rectInner.Width/2, rectInner.Height/2);
Rectangle rect4 = new Rectangle(rectInner.X + rectInner.Width/2, rectInner.Y + rectInner.Height/2, rectInner.Width/2, rectInner.Height/2);
Rectangle[] rects = new Rectangle[]
{
rect1, rect2, rect3, rect4
};
for(int i = 0; i < 4; i++)
{
DrawWordIntoRectangle(g, words[i].ToString(), font, fillColor, rects[i]);
}
pen.Dispose();
g.Dispose();
return m_Bitmap;
}
继续关注 --------------------编程问答-------------------- 顶1楼
--------------------编程问答-------------------- 看得有点晕呀
--------------------编程问答-------------------- 2楼的朋友能和我联系吗,我的QQ:1602808073 --------------------编程问答-------------------- 1楼的朋友能和我联系吗,我的QQ:1602808073 --------------------编程问答-------------------- 学习一下阿 --------------------编程问答-------------------- 不会吧难道是高手吗
补充:.NET技术 , C#