抖音上的骚气字符动画,是怎么实现的?
Solomon_肖哥弹架构 跟大家“弹弹” 图片与视频中的字符动画转换实现方案。点赞,点赞,点赞。 关注本人的公众号Solomon肖哥弹架构获取更多的惊喜
美女转字符
视频转字符
要录制 gif 动画,使用虚拟机运行 Linux,Framebuffer 的分辨率设置为 1024x768。同样,通过上面的mplayer -vo help命令,还可以看到 mplayer 支持使用 libaa 库,将视频播放为字符画。使用mplayer -vo aa -moniterpixelaspect 0.5 badapple.mp4播放
美女转换字符
图片转字符核心代码
final String base = "/lVXvi-!;.'";
try {
final BufferedImage image = ImageIO.read(new File(path));
System.out.println("W:"+image.getWidth()+" H:"+image.getHeight());
for (int y = 0; y < image.getHeight(); y += 6) {
for (int x = 0; x < image.getWidth(); x+= 2) {
final int pixel = image.getRGB(x, y);
final int r = (pixel & 0xff0000) >> 16, g = (pixel & 0xff00) >> 8, b = pixel & 0xff;
final float gray = 0.299f * r + 0.578f * g + 0.114f * b;
final int index = Math.round(gray * (base.length() + 1) / 255);
System.out.print(index >= base.length() ? " " : String.valueOf(base.charAt(index)));
}
System.out.println();
}
} catch (final IOException e) {
e.printStackTrace();
}
将图片转黑白
图片转字符
文字转字符
做SpringBoot启动logo
关注&点赞 肖哥 后续讲解,SpringBoot 自定义启动Logo的实现方案
你的点赞与关注 是 Solomon_肖哥弹架构持续的动力。