SoFunction
Updated on 2025-03-01

C# realizes the conversion of Chinese characters into a background of lattice characters by field character jpg picture


using System;
using ;
using ;
using ;
using ;
using ;
using ;

namespace text image generation program
{
    static class Program
    {
        /// <summary>
/// The main entry point of the application.
        /// </summary>
       static void checkdir()
        {
            string path="C:\\Users\\Default\\tran";
if (!(path))//Judge whether the directory exists
            {
                (path);
            }
        }
        [STAThread]
        static void Main()
        {
            ();
            ();
            (false);
            (new Form1());

        }


    }
    class Program1
    {
        private float hor=0.46f;//
        public static string src = null;
        public void setting(float[] z)
        {
= z[5];//Text ratio


//Line proportions
//Dashed line ratio
//Shape and thickness ratio
//Up and down position
//Left and left positions
//Border border bool
        }
        public void CreateImage(string lf,string content,int w,Color gezi,Color bg,Color ziti_a,Color ziti_b,string ziti,bool flag_b)
        {

            Font font;
//Create a bitmap object
            Bitmap image = new Bitmap(w, w);
//Create Graphics
            Graphics g = (image);
            try
            {
//Clear the background color of the picture
                (bg);
                if (!flag_b)
                    font = new Font(ziti, w * 0.65f);
                else
                    font = new Font(ziti, w * 0.65f, ());
                . brush = new .(new Rectangle(0, 0, , ), ziti_a, ziti_b, 4.0f, true);
//Draw the border line of the picture
                (new Pen(gezi, w * 0.007f), w * 0.03f, w * 0.03f, w * 0.94f, w * 0.94f);
//Draw a dotted line
                Pen pen1 = new Pen(gezi, w * 0.007f);
                = .;
                = new float[] { w * 0.012f, w * 0.008f };
                (pen1, w * 0.03f, w * 0.03f, w * 0.97f, w * 0.97f);
                (pen1, w * 0.97f, w * 0.03f, w * 0.03f, w * 0.97f);
                (pen1, w * 0.03f, w * 0.5f, w * 0.97f, w * 0.5f);
                (pen1, w * 0.5f, w * 0.03f, w * 0.5f, w * 0.97f);
                StringFormat sf = new StringFormat();
                = ;
                = ;

                (content, font, brush, w*hor, w * 0.63f, sf);
                src = lf + content + ".jpg";

                (src);

              
            }
            finally
            {
                ();
                ();
            }
        }

    }

}