0

我正在创建应用程序,如snapchat.How 在图像上添加文本,如 snapchat 文本。喜欢这个

这是我的代码:

private void button1_Click(object sender, EventArgs e)
    {
        FileStream fs = new FileStream(@"path\images.png", FileMode.Open, FileAccess.Read);
        Image image = Image.FromStream(fs);


        SolidBrush drawBrush = new SolidBrush(Color.Black);
        fs.Close();

        Bitmap b = new Bitmap(image);
        Graphics graphics = Graphics.FromImage(b);
        graphics.FillRectangle(Brushes.Red, new Rectangle(10, 10, 2, 2));

        graphics.DrawString("Hello", this.Font, Brushes.Red, 100, 100);


        b.Save(@"path\images.png", image.RawFormat);

        image.Dispose();
        b.Dispose();
    }

文字在图像上写得很好,但我不知道在像 snapchat 这样的图像上写文字。我的想法是先计算字符串大小,然后设置字符串的背景颜色和不透明度等。但我不知道怎么做,请帮忙我谢谢你。

4

0 回答 0