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 ヾ(≧∇≦*)ゝ的更多相关文章

  1. ASCII Art (English)

    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. Linux/Unix 桌面趣事:文字模式下的 ASCII 艺术与注释绘画

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

  6. 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 ...

  7. UVALive 7324 ASCII Addition (模拟)

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

  8. 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 ...

  9. ASCII 码对应表

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

随机推荐

  1. python接口自动化(二十四)--unittest断言——中(详解)

    简介 上一篇通过简单的案例给小伙伴们介绍了一下unittest断言,这篇我们将通过结合和围绕实际的工作来进行unittest的断言.这里以获取城市天气预报的接口为例,设计了 2 个用例,一个是查询北京 ...

  2. MySQL · 引擎特性 · InnoDB崩溃恢复

    前言 数据库系统与文件系统最大的区别在于数据库能保证操作的原子性,一个操作要么不做要么都做,即使在数据库宕机的情况下,也不会出现操作一半的情况,这个就需要数据库的日志和一套完善的崩溃恢复机制来保证.本 ...

  3. 微信小游戏爆款秘笈 数据库MongoDB攻略篇

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由腾讯云数据库 TencentDB 发表于云+社区专栏 随着微信小游戏的爆发,越来越多开发者关注到MongoDB与小游戏业务的契合度. ...

  4. 【MQ】消息队列及常见MQ比较

    一.什么是消息队列 我们可以把消息队列比作是一个存放消息的容器,当我们需要使用消息的时候可以取出消息供自己使用.消息队列是分布式系统中重要的组件,使用消息队列主要是为了通过异步处理提高系统性能和削峰. ...

  5. 02. Install redis on Linux

    安装下载redis,参考官方文档:https://redis.io/download 下载: shell>wget http://download.redis.io/releases/redis ...

  6. goldengate同源一目标+多表和同源多目标+多表

    小结一下,永记心中!几经修改,看见完美曾经遇到的问题或值得注意的地方,就此记录一下,以免再犯开始...******************同源一目标+多表******************针对部分表 ...

  7. Windows10家庭版运行应用提示”管理员已阻止你运行此应用...“的解决办法

    win10版本家庭中文版: 运行应用程序报错: 解决办法(亲试): 1.进入”控制面板“--”用户账户“--”用户账户“,选择”更改用户账户控制设置“,选择最后一项,点击”确定“按钮,如下图: 2.按 ...

  8. Git报错 bad numeric config value '100000' for 'pack.windowmemory': out of range

    Git报错 bad numeric config value '10240M' for 'pack.windowmemory': out of range $ git config --edit -- ...

  9. 在docker私有仓库如何查看有哪些镜像?

    搭建了docker私有仓库,上传了一些镜像,时间长了就会忘了有哪些镜像,在网上查了,有大佬是通过脚本查看的,多厉害! #!/usr/bin/env python#-*- coding:utf-8 -* ...

  10. EF和Dapper之争的关键

    突然发现园子里为EF和Dapper的事闹翻了天.(学Java的同学大概就是Hibernate和MyBatis之争了) 讲到EF对Mysql的支持,我在一边偷着乐:还好我用的是NHibernate,对M ...