97爱亚洲综合成人,丰满少妇被猛烈进av毛片,欧美精品18videos性欧美,欧美成年视频在线观看,国产97成人亚洲综合在线观看

首頁 > 軟件下載> 圖片轉(zhuǎn)換 > C#將圖片轉(zhuǎn)換為ASCii字符
C#將圖片轉(zhuǎn)換為ASCii字符
  • 軟件大?。?span itemprop="fileSize">71.00KB
  • 更新日期:2020/09/14
  • 軟件語言:簡體中文
  • 軟件類別:圖片轉(zhuǎn)換
  • 軟件授權(quán):免費軟件
  • 軟件官網(wǎng):
  • 適用平臺:WinAll
10
軟件評分
69 5

91本地下載文件大小:71.00KB

  • 軟件介紹
  • 人氣軟件
  • 相關(guān)文章
  • 精品推薦

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

使用說明

長寬是設(shè)置 要替換成字符的像素塊大小 越小 越精細(xì)。

輸出的是文本文件,保存路徑為D:⁄test.txt,開txt文件 如太大 把 txt字體設(shè)定成最小 即可看到效果了。

代碼說明

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();

        }

        ///


        /// 生成string

        ///

        ///照片

        ///行大小

        ///列大小

        ///模式

        ///

        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();        }

猜你喜歡

  • 圖片轉(zhuǎn)換軟件那個好用

​圖片轉(zhuǎn)換軟件那個好用 查看更多

圖片轉(zhuǎn)換器能夠?qū)崿F(xiàn)批量圖片格式轉(zhuǎn)換,它支持各種常用圖片格式,支持對圖片的顏色、畫質(zhì)、亮度等屬性的修改。圖片轉(zhuǎn)換器可以按照比例或者自定的數(shù)值調(diào)整圖片的尺寸,旋轉(zhuǎn)圖片,功能也非常強(qiáng)大,用戶操作起來也是非常方便的,是非常實用的一款軟件。