백왕 아저씨가 맨날 쓰는 페페티콘


일단 이렇게만 해놓고 공부 끝내고 색칠해야지


2016.10.23 C# 버전(GUI) 추가



일베충 + 페페개구리



10월 24일 코드 추가

핵심
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Drawing;
using System.Text;
namespace TextArt
{
    public partial class ImageToText
    {
        public string[] CharForDrawing = { "#""#""@""%""=""+""*"":""-""."" " };
        public string content;
 
        public string Convert(Bitmap image)
        {
            Boolean _switch = false;
            StringBuilder sb = new StringBuilder();
            for (int h = 0; h < image.Height; h++)
            {
                for (int w = 0; w < image.Width; w++)
                {
                    Color pixelColor = image.GetPixel(w, h);
                    int red = (pixelColor.R + pixelColor.G + pixelColor.B) / 3;
                    int green = (pixelColor.R + pixelColor.G + pixelColor.B) / 3;
                    int blue = (pixelColor.R + pixelColor.G + pixelColor.B) / 3;
                    Color grayColor = Color.FromArgb(red, green, blue);
                    if (!_switch)
                    {
                        int index = (grayColor.R * 10/ 255;
                        sb.Append(CharForDrawing[index]);
                    }
                }
                if (!_switch)
                {
                    sb.Append("<BR>");
                    _switch = true;
                }
                else
                {
                    _switch = false;
                }
            }
 
            return sb.ToString();
        }
        public Bitmap ReSizeImage(Bitmap inputBitmap, int w) // width
        {
            
            int h = 0// height
            h = (int)Math.Ceiling((double)inputBitmap.Height * w / inputBitmap.Width);
            Bitmap result = new Bitmap(w, h);
            Graphics g = Graphics.FromImage((Image)result); // graphic
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.DrawImage(inputBitmap, 00, w, h);
            g.Dispose();
            return result;
        }
    }
}
 
cs

프로젝트 파일