zoukankan      html  css  js  c++  java
  • C#在图片上添加文字代码

    创建.NET WinForm程序设置项目的默认命名空间为Keleyi.Com,在窗体上添加一个PictureBox控件pictureBox_keleyi_com和一个Button控件button_AddStringToImage_keleyi_com。

    using System;
    using System.Drawing;
    using System.IO;
    using System.Net;
    using System.Windows.Forms;

    namespace Keleyi.Com
    {
    public partial class KeleyiImageForm : Form
    {
    public KeleyiImageForm()
    {
    InitializeComponent();
    }
    //按钮点击事件 jihua.cnblogs.com
    private void button_AddStringToImage_keleyi_com_Click(object sender, EventArgs e)
    {

    HttpWebRequest request_keleyi_com = (HttpWebRequest)WebRequest.Create(@"http://keleyi.com/image/a/q9e4nvb3.jpg");
    WebResponse response_keleyi = null;
    Stream keleyi_com_stream = null;
    response_keleyi = request_keleyi_com.GetResponse();
    keleyi_com_stream = response_keleyi.GetResponseStream();

    Bitmap bmp = new Bitmap(keleyi_com_stream);
    Graphics g = Graphics.FromImage(bmp);
    String str = "柯乐义 keleyi.com";
    Font font = new Font("宋体", 16);
    SolidBrush sbrush = new SolidBrush(Color.Black);
    g.DrawString(str, font, sbrush, new PointF(10, 30));
    MemoryStream ms = new MemoryStream();
    bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
    if (pictureBox_keleyi_com.Name == "pictureBox_ke"+"leyi_com")
    pictureBox_keleyi_com.Image = Image.FromStream(ms);


    }
    }
    }


    程序实现在网上的图片(http://keleyi.com/image/a/q9e4nvb3.jpg)上加上字符串“柯乐义 keleyi.com”,在窗体上显示出来。

    本文:http://www.cnblogs.com/jihua/p/imgaddstring.html

    原文:http://keleyi.com/a/bjac/xtxyoei0.htm

  • 相关阅读:
    站立会议第七天
    站立会议第六天
    站立会议第五天
    站立会议第四天
    inotify简题
    搭建企业版yum仓
    ssh及ssh-key
    shell变量
    如何下载scp、wget、inotify及如何偷包
    rsync
  • 原文地址:https://www.cnblogs.com/jihua/p/imgAddString.html
Copyright © 2011-2022 走看看