ASCII点阵 16x8 与24x16 Java

news/2024/11/23 21:41:59/

1

字库下载链接:https://download.csdn.net/download/llapton/12910449

.ASCII与汉字寻址公式不同,注意区分,寻址公式如下图
在这里插入图片描述

2

.16x8 ASCII点阵显示,注意这里使用的字库为"ASC16",注意寻址公式为 offset = ascii * 16

package tools;import org.springframework.core.io.ClassPathResource;import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;public class AsciiPoint {public static void main(String[] args) throws IOException {String str = "B";char[] key = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};int size_step = 8;//16x8的ASCII点阵byte[] cbuf = new byte[16];byte[] bytes = str.getBytes("ASCII");System.out.println(Arrays.toString(bytes));//byte转intint ascii = bytes[0] & 0xff;//计算偏移量int offset = ascii * 16;//读取点阵字库文件,需要按需修改为你电脑上实际字库的绝对地址ClassPathResource classPathResource = new ClassPathResource("ASC16");InputStream inputStream = classPathResource.getInputStream();//跳过offset个字节,读取汉字占用的16个字节inputStream.skip(offset);inputStream.read(cbuf);//按行解析for (int i = 0; i < 16; i++) {for (int j = 0; j < 8; j++) {int index = i * 8 + j;int flag = cbuf[index / size_step] & key[index % size_step];System.out.print(flag > 0 ? "●" : "○");}System.out.println();}}
}

16x8效果:
在这里插入图片描述

**

3

24x16 ASCII点阵显示,注意这里使用的字库为"ASC24",注意寻址公式为 offset = (ascii-32) * 16

package tools;import org.springframework.core.io.ClassPathResource;import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;public class AsciiPoint24 {public static void main(String[] args) throws IOException {String str = "t";char[] key = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};int size_step = 8;//24x16的ASCII点阵byte[] cbuf = new byte[48];byte[] bytes = str.getBytes("ASCII");System.out.println(Arrays.toString(bytes));//byte转intint ascii = bytes[0] & 0xff;//计算偏移量int offset = (ascii-32) * 48;//读取点阵字库文件,需要按需修改为你电脑上实际字库的绝对地址ClassPathResource classPathResource = new ClassPathResource("ASC24");InputStream inputStream = classPathResource.getInputStream();//跳过offset个字节,读取汉字占用的16个字节inputStream.skip(offset);inputStream.read(cbuf);//按行解析for (int i = 0; i < 24; i++) {for (int j = 0; j < 16; j++) {int index = i * 16 + j;int flag = cbuf[index / size_step] & key[index % size_step];System.out.print(flag > 0 ? "●" : "○");}System.out.println();}}
}

24x16 效果如下:
在这里插入图片描述

字库下载链接:https://download.csdn.net/download/llapton/12910449


http://www.ppmy.cn/news/205232.html

相关文章

【论文笔记】An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale (ViT)

题目&#xff1a;An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale 作者&#xff1a;谷歌大脑团队&#xff08;Dosovitskiy, A., Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, M. Dehghani, Matthia…

C语言16x16点阵显示汉字程序,单片机+16x16点阵,汉字滚动显示程序(带仿真)

2013-6-26 04:31 上传 点击文件名下载附件 下面是源代码预览: #include #include #define DATAOUT P2 //P2 use as data, you can change #define SPEED 13 void ymove(char dir,unsigned char *ptr,char speed); void xmove(char dir,unsigned char *ptr,char n,char speed)…

Proteus8.6中16x16LED点阵制作教程

文章目录 前言 一、Proteus8.6中16x16LED点阵制作教程 二、步骤 1.8x8点阵 2.16x16点阵 3.创建完16x16点阵图 总结 前言 经常使用4个8x8点阵连接成16x16的点阵&#xff0c;不但麻烦&#xff0c;效果还不好元件件库还没有16x16点阵&#xff0c;所以自己制作元件。 提示…

【ViT 论文笔记】AN IMAGE IS WORTH 16X16 WORDS: TRANSFORMERS FOR IMAGE RECOGNITION AT SCALE

“We show that this reliance on CNNs is not necessary and a pure transformer applied directly to sequences of image patches can perform very well on image classification tasks.” ——完全不依赖CNN 参考&#xff1a;Vision Transformer详解_太阳花的小绿豆的博客…

PowerDesigner16x64_Evaluation下载安装

链接&#xff1a;https://pan.baidu.com/s/13Q_AQxnl6wbQswJOZj62bA 提取码&#xff1a;ns3t 官网下载地址&#xff1a;https://www.sap.com/ 或者 https://www.powerdesigner.biz/

1616矩阵c语言程序,51单片机16X16点阵上移C语言程序

前面已经分享了&#xff0c;点阵汇编语言&#xff0c;想信大家大部分用C语言较多了&#xff0c;下面我就将16X16点阵上移C语言程序分享出来&#xff0c;希望能帮到需要的朋友&#xff01;本人此程序有经过实物测试的。并非随意弄出来的。并且有配视频效果&#xff0c;可以点击查…

【论文阅读】An Image is Worth 16x16 Words:Transformers for Image Recognition at Scale

&#x1f6a9;前言 &#x1f433;博客主页&#xff1a;&#x1f61a;睡晚不猿序程&#x1f61a;⌚首发时间&#xff1a;2022.9.2⏰最近更新时间&#xff1a;2022.9.2&#x1f646;本文由 睡晚不猿序程 原创&#xff0c;首发于 CSDN&#x1f921;作者是蒻蒟本蒟&#xff0c;如果…

Conway‘s Game of Life 16x16(Conwaylife)

项目场景&#xff1a; Conway’s Game of Life is a two-dimensional cellular automaton. The “game” is played on a two-dimensional grid of cells, where each cell is either 1 (alive) or 0 (dead). At each time step, each cell changes state depending on how m…