欢迎访问!
您的支持是我们不断前行的动力!

C# 在图片上写字,在图片上画线

以下代码实现在图片上写字,在图片上画线:

/// <summary>
/// 在图片上写字
/// </summary>
/// <param name="img">原图</param>
/// <param name="words">要写的内容</param>
/// <param name="font">字体</param>
/// <param name="brush">笔刷</param>
/// <param name="x">横坐标</param>
/// <param name="y">纵坐标</param>
/// <returns></returns>
public static Image DrawWordsOnPicture(Image img,string words,Font font,Brush brush,int x,int y)
{
    Graphics g = Graphics.FromImage(img);
    PointF p = new PointF(x, y);
    g.DrawString(words, font, brush, p);
    return img;
}
/// <summary>
/// 在图片上画线
/// </summary>
/// <param name="img">原图</param>
/// <param name="color">颜色</param>
/// <param name="brushWidth">笔刷宽度</param>
/// <param name="startX">起始横坐标</param>
/// <param name="startY">起始纵坐标</param>
/// <param name="endX">结束横坐标</param>
/// <param name="endY">结束纵坐标</param>
/// <returns></returns>
public static Image DrawLineOnPicture(Image img,Color color,int brushWidth,int startX,int startY,int endX,int endY)
{
    Graphics g = Graphics.FromImage(img);
    Pen pen = new Pen(color, brushWidth);
    g.DrawLine(pen, startX, startY, endX, endY);
    return img;
}
赞(0) 打赏
转载请注明出处,未注明出处不得转载,蜘蛛侠 » C# 在图片上写字,在图片上画线
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

蜘蛛侠,您身边的爬虫专家!

觉得文章有用就打赏一下文章作者吧

支付宝扫一扫打赏

微信扫一扫打赏