• <td id="ae6ms"><li id="ae6ms"></li></td>
  • <xmp id="ae6ms"><td id="ae6ms"></td><table id="ae6ms"></table>
  • <table id="ae6ms"></table>
  • <td id="ae6ms"></td>
    <td id="ae6ms"></td>
  • <table id="ae6ms"></table><table id="ae6ms"><td id="ae6ms"></td></table>
  • <td id="ae6ms"></td>
  • <table id="ae6ms"><li id="ae6ms"></li></table>
  • <table id="ae6ms"></table>
    西西軟件園多重安全檢測下載網站、值得信賴的軟件下載站!
    西西首頁 常用軟件 軟件下載 安卓軟件 游戲下載 安卓游戲 MAC應用 驅動下載 安卓電視
    系統工具網絡工具媒體工具圖形圖像聊天工具應用軟件編程開發手機軟件安卓應用電腦安全字體素材

    C#將圖片轉換為ASCii字符

    V1.0綠色版
    • C#將圖片轉換為ASCii字符V1.0綠色版
    • 軟件大小:71KB
    • 更新時間:2020-09-11 14:01
    • 軟件語言:中文
    • 軟件廠商:
    • 軟件類別:國產軟件 / 免費軟件 / 圖像轉換
    • 軟件等級:3級
    • 應用平臺:WinAll
    • 官方網站:暫無
    好評:50%
    壞評:50%

    軟件介紹

    C#將圖片轉換為ASCii字符是一款將圖片轉為ASCII字符畫工具,看別人發出來好玩的圖片上有這樣的代碼照片圖,就在網上查了下源碼,居然有C#的,寫了個小程序。轉出來的效果,個人感覺挺像的。

    使用說明

    長寬是設定 要替換成字符的像素塊大小 越小 越精細。
    輸出的是文本文件,保存路徑為D:\test.txt,開txt文件 如太大 把 txt字體設置成最小 就可以看到效果了。

    代碼說明

    private void button1_Click(object sender, EventArgs e)

            {

                string str = null;

                //上傳照片

                OpenFileDialog op = new OpenFileDialog();

                if (op.ShowDialog() == DialogResult.OK)

                {

                    var image = File.ReadAllBytes(op.FileName);

                    MemoryStream ms1 = new MemoryStream(image);

                    Bitmap bm = (Bitmap)Image.FromStream(ms1);

                    str = Generate.GenerateStr(bm, int.Parse(comboBox2.Text),

                        int.Parse(comboBox1.Text), int.Parse(comboBox3.Text));

                }

                this.btnSave_Click(str);

                textBox1.Text = "已生成,文件位置D:\\test.txt";

            }

            private void btnSave_Click(string s)

            {

                StreamWriter sw = File.AppendText(@"D:\\test.txt"); //保存到指定路徑

                sw.Write(s);

                sw.Flush();

                sw.Close();

            }

            /// <summary>

            /// 生成string

            /// </summary>

            /// <param name="bitmap">照片</param>

            /// <param name="rowSize">行大小</param>

            /// <param name="colSize">列大小</param>

            /// <param name="type">模式</param>

            /// <returns></returns>

            public static string GenerateStr(Bitmap bitmap, int rowSize, int colSize, int type)

            {

                StringBuilder result = new StringBuilder();

                char[] charset = { ' ', '.', ',', ':', ';', 'i', '1', 'r', 's', '5', '3', 'A', 'H', '9', '8', '&', '@', '#' };

                if (type == 1)

                {

                    charset = new char[] { ' ', '.', '1', '2', '0', '7', '5', '3', '4', '6', '9', '8' };

                }

                else if (type == 2)

                {

                    charset = new char[] { '丶', '卜', '乙', '日', '瓦', '車', '馬', '龠', '齱', '龖' };

                }

                int bitmapH = bitmap.Height;

                int bitmapW = bitmap.Width;

                for (int h = 0; h < bitmapH / rowSize; h++)

                {

                    int offsetY = h * rowSize;

                    for (int w = 0; w < bitmapW / colSize; w++)

                    {

                        int offSetX = w * colSize;

                        float averBright = 0;

                        for (int j = 0; j < rowSize; j++)

                        {

                            for (int i = 0; i < colSize; i++)

                            {

                                try

                                {

                                    Color color = bitmap.GetPixel(offSetX + 1, offsetY + j);

                                    averBright += color.GetBrightness();

                                }

                                catch (ArgumentOutOfRangeException)

                                {

                                    averBright += 0;

                                }

                            }

                        }

                        averBright /= (rowSize * colSize);

                        int index = (int)(averBright * charset.Length);

                        if (index == charset.Length)

                            index--;

                        result.Append(charset[charset.Length - 1 - index]);

                    }

                    result.Append("\r\n");

                }

                return result.ToString();        }

    軟件截圖

    C#將圖片轉換為ASCii字符 V1.0綠色版

      熱門評論

      最新評論

      發表評論 查看所有評論(0)

      昵稱:
      表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
      字數: 0/500 (您的評論需要經過審核才能顯示)

      下載幫助下載幫助西西破解版軟件均來自互聯網, 如有侵犯您的版權, 請與我們聯系。

      TOP
      軟件下載
      女人让男人桶30分钟免费视频,女人张开腿让男人桶个爽,一进一出又大又粗爽视频
    • <td id="ae6ms"><li id="ae6ms"></li></td>
    • <xmp id="ae6ms"><td id="ae6ms"></td><table id="ae6ms"></table>
    • <table id="ae6ms"></table>
    • <td id="ae6ms"></td>
      <td id="ae6ms"></td>
    • <table id="ae6ms"></table><table id="ae6ms"><td id="ae6ms"></td></table>
    • <td id="ae6ms"></td>
    • <table id="ae6ms"><li id="ae6ms"></li></table>
    • <table id="ae6ms"></table>