Conmajia, 2012

Updated on Feb. 18, 2018

What is ASCII art?

It's graphic symbols formed by ASCII characters instead of colorful pixels. ASCII art is an old technique when the network was not that developed as today. Net bandwidth was so limited and expensive those days, that people had to figure out some substitutions for images. Here is an example to show an excited emotion icon \(\rightarrow\) ヾ(≧∇≦*)ゝ.

In this article, I tried to use a brightness-to-character palette to build ASCII art from an pixel-based image.

The core code is less than 50 lines as below.

public static string Generate(Bitmap img, int rowSz, int colSz)
{
StringBuilder sb
= new StringBuilder(
img.Width / colSz * img.Height / rowSz
);
FastBitmap fast
= new FastBitmap(
img
); fast.Lock();
for (int h = 0; h < img.Height / rowSz; h++)
{
int yoffset = h * rowSz;
for (int w = 0; w < img.Width / colSz; w++)
{
int xoffset = w * colSz;
int br = 0; for (int y = 0; y < 10; y++)
for (int x = 0; x < 10; x++)
try
{
Color c = fast.GetPixel(
x + xoffset,
y + yoffset);
br =
br + (int)(c.GetBrightness() * 10);
}
catch
br += 10;
br /= 10;
if (br / 5 < charset.Length)
sb.Append(
charset[br / 5]);
else
sb.Append(' ');
}
sb.AppendLine();
}
fast.Unlock(); return sb.ToString();
}

You can even make this program animated like this:

The End. \(\Box\)

ASCII Art (English)的更多相关文章

  1. ASCII Art ヾ(≧∇≦*)ゝ

    Conmajia, 2012 Updated on Feb. 18, 2018 What is ASCII art? It's graphic symbols formed by ASCII char ...

  2. ASCII Art

    ASCII Art https://npms.io/search?q=ASCII art ASCII Art Text to ASCII Art Generator (TAAG) http://pat ...

  3. Pictures of Ascii Art

    简述 指尖上的艺术 - 通过键盘上韵律般的敲敲打打,一幅幅美轮美奂的艺术作品便跃然于屏. 这样的画作,包含了无穷的创意,糅合了现代计算机科技与传统绘画艺术,难道还有比这更令人陶醉的美妙事物吗? 简述 ...

  4. Python下字符画(ascii art)生成

    之前在b站上看到有人用C写了个脚本把妹抖龙op转换成字符画的形式输出了,感觉比较好玩在下就用python也写了一遍(主要是因为python比较简单好用).这里就这里就不介绍字符画了,因为能搜到这个的肯 ...

  5. ASCII 码对应表

    Macron symbol ASCII CODE 238 : HTML entity : [ Home ][ español ] What is my IP address ? your public ...

  6. Linux/Unix 桌面趣事:文字模式下的 ASCII 艺术与注释绘画

    boxes 命令不仅是一个文本过滤器,同时是一个很少人知道的有趣工具,它可以在输入的文本或者代码周围框上各种ASCII 艺术画.你可以用它快速创建邮件签名,或者在各种编程语言中留下评论块.这个命令可以 ...

  7. linux ascii艺术与ansi艺术

    Linux终端下的ASCII艺术 http://zh.wikipedia.org/zh-tw/%E9%9B%BB%E5%AD%90%E9%81%8A%E6%88%B2%E5%8F%B2 电子游戏史 h ...

  8. UVALive 7324 ASCII Addition (模拟)

    ASCII Addition 题目链接: http://acm.hust.edu.cn/vjudge/contest/127407#problem/A Description Nowadays, th ...

  9. Yahoo! Logo ASCII Animation in 462 bytes of C

    Last week I put together another obfuscated C program and have been urged by my coworkers to post it ...

随机推荐

  1. java的运算符和表达式

    )1.算数运算符:java中常用的算术运算符除了 +.-.*./之外,还有%(取余).++(自增).--(自减). )1.1%(取余):可适用于整数,char,浮点数的取余中.在取余中,如果进行运算的 ...

  2. HtmlHelper总结

    HTML helper是在视图页面上操作HTML元素时可以调用的方法,还包括URL helper和AJAX helper.这些帮助方法都为了使得操作HTML更加容易.分为两类:a.编辑和输入帮助类b. ...

  3. dede文章插入分页符不起作用,编辑器中出现分页符,导致文章显示不全

    文章来源:小灰博客| 时间:2013-10-30 13:40:21| 作者:Leo | 1 条评论 文章分类:IT技术分享.PHP     标签: dedecms 今天偶尔发现给一篇dede下的长文章 ...

  4. php curl实现get和post请求

    1.cURL介绍 cURL 是一个利用URL语法规定来传输文件和数据的工具,支持很多协议,如HTTP.FTP.TELNET等.最爽的是,PHP也支持 cURL 库.本文将介绍 cURL 的一些高级特性 ...

  5. 编程:在屏幕中间分别显示绿色、绿底红色、白底蓝色的字符串 'welcome to masm!'

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  6. 爬取知名社区技术文章_items_2

    item中定义获取的字段和原始数据进行处理并合法化数据 #!/usr/bin/python3 # -*- coding: utf-8 -*- import scrapy import hashlib ...

  7. Duilib学习(一)

    #pragma once #include <UIlib.h> using namespace DuiLib; #ifdef _DEBUG # ifdef _UNICODE # pragm ...

  8. POI--帮助文档

    1.创建工作簿 (WORKBOOK) HSSFWorkbook wb = new HSSFWorkbook(); FileOutputStream fileOut = new FileOutputSt ...

  9. org.json.JSONObject的optXXX方法

    JSONObject有很多optXXX方法,比如optBoolean,optString,optInt.... 他们的意思是:如果这个JSONObject对象,如果有返回这个属性的值,如果没有返回一个 ...

  10. fullpage.js的easing参数怎样配置自定义动画

    首先看非官方文档 并没有详细的说明怎样去使用easing.js,所以我加的运动属性根本就不起作用, 再看,官方文档 Optionally, when using css3:false, you can ...