Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Char To Image
/* https://github.com/XuPeiYao 使用星號顯示「靠」字 */ using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Rextester { public class Program { public static void Main(string[] args) { String input = "莊王嫩"; var chars = input.ToCharArray(); for (int ctr = 0; ctr < chars.Length; ctr++){ Console.WriteLine("{0}", chars[ctr]); var image = CharToImage(chars[ctr]); for (int h = 0; h < image.Height; h++) { string line = string.Empty; for (int w = 0; w < image.Width; w++) { var color = image.GetPixel(w, h); if (color.A != 0) { line += "*"; } else { line += " "; } } Console.WriteLine(line); } } } static Bitmap CharToImage(char inputChar) { var image = new Bitmap(64, 64); var rectf = new RectangleF(0, 0, 64, 64); using (Graphics g = Graphics.FromImage(image)) { g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; g.DrawString(inputChar.ToString(), new Font(SystemFonts.DefaultFont.FontFamily, 36, FontStyle.Regular), Brushes.Black, rectf, sf); } return image; } } }
run
|
edit
|
history
|
help
0
ObjectPool
sadfghjklö
Hzzz
5
4.3 Static typing: benefits, drawbacks and ways to minimise them
problem 2
asxsdf
6.3 Parallelism: job-pattern
f
dict