Bad apple for CSharp
前言:记得10年的时候我还在上学,有一天逛csdn看到了字符版的badapple,感觉这东西好NB啊,然后就下载了一份,最近整理博客就把他整理博客,原作者是谁真心不知道,这是在果壳看到的.
Bad Apple最初是作为日本同人游戏社团“上海爱莉丝幻乐团”所制作的“东方Project”系列游戏背景音乐出现的。后来在日本著名视频站点NicoVideo上有人萌发了为此系列制作MADMovie的想法,最后有了这段3D制作的影绘风格视频:
这段视频由不断变换的影绘风格游戏人物组成,完全黑白,视觉震撼力十足。此视频在网络上引发了一场宏大的运动,各种技术宅使用了各种方法来演奏这段三分多钟长的视频。
看完本文后,你将能做出如下效果的视频:
1 所需工具
2 思路原理
而输出的字符需要从原始视频获取,将原始视频压缩成一个较低的分辨率,再获取到每一帧上的所有像素点,转换成对应的字符串。
3 确定思路

4 捕获图像


5 编码
6 输出

7 源码预览
class Program
{
static void Main(string[] args)
{
//获取in目录下所有文件 未作异常处理
string[] path = Directory.GetFileSystemEntries("in"); //保存为Gzip压缩的文本流
FileStream fileStream = new FileStream("badapple.dat", FileMode.Create, FileAccess.Write);
GZipStream compressionStream = new GZipStream(fileStream, CompressionMode.Compress);
StreamWriter sw = new StreamWriter(compressionStream); //遍历每个像素点
for (int x=;x<path.Length;x++)
{
//Console.WriteLine(path[x]);
Bitmap bitmap = new Bitmap(path[x]); for (int i = ; i < bitmap.Height; i++)
{
for (int j = ; j < bitmap.Width; j++)
{
Color color = bitmap.GetPixel(j, i);
if (color.R > )
{
//Console.Write("1");
sw.Write(" ");
}
else
{
//Console.Write("0");
sw.Write("#");
}
}
//Console.WriteLine();
sw.WriteLine();
Console.Clear();
Console.WriteLine("{0} of {1} completed! ",x,path.Length);
}
bitmap.Dispose();
}
sw.Dispose();
} }
压缩图片
class Program
{
private static StreamReader reader;
static void Main(string[] args)
{
//打开压缩文本流
FileStream fileStream = new FileStream("badapple.dat", FileMode.Open, FileAccess.Read);
GZipStream compressionStream = new GZipStream(fileStream, CompressionMode.Decompress);
reader = new StreamReader(compressionStream); //初始化控制台参数
Console.Title = "BadAppleSharp 0.1";
Console.WindowWidth = ;
Console.WindowHeight = ; //调用播放器播放背景音乐
WaveStream mp3Reader = new Mp3FileReader(@"BadApple.mp3");
WaveStream pcmStreamer = WaveFormatConversionStream.CreatePcmStream(mp3Reader);
WaveStream blockAlignedStream = new BlockAlignReductionStream(pcmStreamer);
WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback());
waveOut.Init(blockAlignedStream);
waveOut.Play(); //初始化定时器
Timer timer = new Timer();
timer.Elapsed+=new ElapsedEventHandler(Render);
timer.Enabled = true; Console.ReadKey();
waveOut.Dispose();
blockAlignedStream.Dispose();
pcmStreamer.Dispose();
mp3Reader.Dispose();
} //渲染一帧
public static void Render(Object sender,ElapsedEventArgs e)
{
{
Console.Clear();
StringBuilder data=new StringBuilder();
for (int i = ; i < ; i++)
{
data.Append(reader.ReadLine());
}
Console.Write(data.ToString());
} }
}
播放源码
8 源码下载
程序及源代码下载 (需要本机安装.net2.0或以上运行环境)
转载自果壳艾斯昆
Bad apple for CSharp的更多相关文章
- Storm系列(二):使用Csharp创建你的第一个Storm拓扑(wordcount)
WordCount在大数据领域就像学习一门语言时的hello world,得益于Storm的开源以及Storm.Net.Adapter,现在我们也可以像Java或Python一样,使用Csharp创建 ...
- c#操作MangoDB 之MangoDB CSharp Driver驱动详解
序言 MangoDB CSharp Driver是c#操作mongodb的官方驱动. 官方Api文档:http://api.mongodb.org/csharp/2.2/html/R_Project_ ...
- iOS: 在iPhone和Apple Watch之间共享数据: App Groups
我们可以在iPhone和Apple Watch间通过app groups来共享数据.方法如下: 首先要在dev center添加一个新的 app group: 接下来创建一个新的single view ...
- c#进阶之神奇的CSharp
CSharp 简写为c#,是一门非常年轻而又有活力的语言. CSharp的诞生 在2000年6月微软发布了c#这门新的语言.作为微软公司.NET 平台的主角,c#吸收了在他之前诞生的语言(c ...
- 一道Apple公司(中国)的面试题目
Apple在中国(上海)有公司业务,但是感觉主要是做测试工作的部门,主要是保障Apple的产品质量QE.面试的时候,面试官出了一道题目,我貌似曾今开过类似的题目,但是由于当场发挥不佳没有答出来.题目大 ...
- apple常用网址
https://developer.apple.com/ https://itunesconnect.apple.com/ iTunes Connect Developer Guide https:/ ...
- Apple Pay 初探
Apple Pay 一.概述 1.支付方式:Touch ID/ Passcode 2.设备要求:iPhone6以上(iphone:线上/线下 ipad:线上 watch:线下) 3.系统要求:iOS8 ...
- Apple、Google、Microsoft的用户体验设计原则
轻巧的Apple 注重设计过程: 在设计过程中引入用户交互的5个目标: 了解您的目标客户 分析用户的工作流 构造原型系统 观察用户测试 制定观察用户准则 做出设计决定 避免功能泛滥 80% 方案 优秀 ...
- 【转】iOS开发 -- Apple Pay
技术博客原地址:http://www.cnblogs.com/dashunzi/p/ApplePay.html#top 原技术博客中有源码和视频,有感兴趣的朋友可以研究一下! 一.什么是Apple P ...
随机推荐
- 在TextView上加上下划线或中划线
在做商城项目是需要用到原价格以及降价后的价格,不可避免用到下划线或中划线 textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下 ...
- .NET 4.0 MemoryCache with SqlChangeMonitor
Summary There isn't a lot of documentation on the internet about how to use the SqlChangeMonitor wit ...
- MVC4 导出word
添加程序包 DocX using System.IO;using Novacode; /// <summary> /// 导出Word /// </summary> publi ...
- LDA-math-神奇的Gamma函数
http://cos.name/2013/01/lda-math-gamma-function/ 1. 神奇的Gamma函数1.1 Gamma 函数诞生记学高等数学的时候,我们都学习过如下一个长相有点 ...
- smarty简单介绍
smarty简单介绍 示意图如下 简单介绍smarty.class.php类的大体内容,如下: <?php class Smarty //此类就是libs中的Smarty.class.php类 ...
- sql数据库(资料库)的基本操作
1 Character Set与Collation 任何资讯技术在处理资料的时候,如果只是单纯的数值和运算,那就不会有太复杂的问题:如果处理的资料是文字的话,就会面临世界上各种不同语言的问题.以资料库 ...
- 有趣的insert死锁
昨天看到一个很有意思的死锁,拿来记录下: 环境:deadlock on 事务隔离级别: read commited 表结构: root::>show create table lingluo\G ...
- MyBatis的Dao层注入SqlSession
有点坑爹,以前没用过Mybatis,最近才用,而且一直用Mybatis推荐的接口映射的方式,但是今天有人告诉我接口方式用得少,大多还是采用从配置文件里面读sql的方式,当然接口也是类似的,都是利用ma ...
- Table Properties [AX 2012]
Table Properties [AX 2012] 1 out of 2 rated this helpful - Rate this topic Updated: July 20, 2012 Ap ...
- 【jqGrid for ASP.NET MVC Documentation】.学习笔记.4.性能
1 HTML / ViewState 大小 1.1 HTML 大小 jqGrid for ASP.NET MVC 使用最佳的客户端渲染,意味着 HTML gird 的 尺寸是最小的.事实上,只有 gr ...