C#源码 任意语言任意大小任意字体任意排列 字符汉字取模及显示 可以自由编辑点阵 通过串口发送 pc端和手机端
来源:互联网 发布:软件界面设计案例 编辑:程序博客网 时间:2024/06/06 05:54
C#任意语言任意大小任意字体任意排列 字符取模及显示 源码,也可以自由编辑点阵
pc端
android手机端(OTG串口发送)
//示测试 private void textBox1_TextChanged(object sender, EventArgs e) { if (textBox1.Text.Length > 0) { // textBox1.Text = "小黄人软件"; Bitmap bmp = GetStrBMP(textBox1.Text, 16, 16); // 获取待分析的字符位图 pictureBox2.Image = Display(bmp, 4, 1); //点放大为4像素,隔线线为1像素 } } //把字符串中 每个字符放到格式里 public Bitmap GetStrBMP(string str, int width, int height) //str字符串 width单个宽度 height单个高度 { int allwidth = str.Length * width; Bitmap bmp = new Bitmap(allwidth, height); // 新建位图变量 Graphics g = Graphics.FromImage(bmp); for (int i = 0; i < str.Length; i++) { g.DrawString(str[i].ToString(), new Font("宋体", 10), Brushes.Black, new PointF(i*width, 0.0F)); } return bmp; } //把整个字符放到格式里 public Bitmap GetStrBMP2(string str, int width, int height) //str字符串 width单个宽度 height单个高度 { int allwidth=str.Length*width; Bitmap bmp = new Bitmap(allwidth, height); // 新建位图变量 Graphics g = Graphics.FromImage(bmp); g.DrawString(str, new Font("宋体", 10), Brushes.Black, new PointF(0.0F, 0.0F)); //StringFormat sf = new StringFormat(); // 设置格式 //sf.Alignment = StringAlignment.Center; //sf.LineAlignment = StringAlignment.Center; // g.DrawString(str, new Font("宋体", 32), Brushes.Black, new Rectangle(0, 0, allwidth, height), sf); // 向图像变量输出字符 return bmp; } public Bitmap Display(Bitmap bmp, int pixelSize, int jg) //bmp要显示的图 pixelSize单个点大小 jg点与点间隔 ,返回转换后的图 { Bitmap bmp2 = new Bitmap(bmp.Width * (pixelSize+jg), bmp.Height * (pixelSize+jg)); // 新建位图变量 Graphics g = Graphics.FromImage(bmp2); Brush temp; Brush backgroud = Brushes.Black; //点阵分隔线颜色 g.FillRectangle(backgroud, new Rectangle(0, 0, bmp2.Width, bmp2.Height));//实心正方形 for (int i = 0; i < bmp.Width; i++) { for (int j = 0; j < bmp.Height; j++) { if (bmp.GetPixel(i, j) == Color.FromArgb(0x0, 0, 0)) //黑 temp = Brushes.White; //亮点颜色 else temp = Brushes.Blue; //暗点颜色 g.FillRectangle(temp, new Rectangle(i * pixelSize+i*jg, j * pixelSize+j*jg, pixelSize, pixelSize));//点阵实心正方形 } } return bmp2; } //取得字节(低位在前,纵向 从上到下 从左到右,16*16) public void CreateCharSet(string str, int width, int height) //str要取模的字符 width单个宽度 height单个高度 ,得到byteArray[]数据 长度为byteArrayLength { //Byte[] byteArray = new Byte[height * width / 8]; //得到的取模数据 //int byteArrayLength = 0; //得到的取模数据 长度 int temp = 0; foreach (char ch in str) { int mode = (int)ch; if (mode <= 127) { width = width/2; } //如果是字符ASCII,宽度为8 如果是汉字,宽度为16 Bitmap bmp = GetStrBMP2(ch.ToString(), width, height); // 获取待分析的字符位图 for (int i = 0; i < bmp.Width; i++) { for (int j = 0; j < bmp.Height; j++) //先列 纵向 { temp = temp >> 1; if (bmp.GetPixel(i, j) == Color.FromArgb(0, 0, 0)) //黑色 temp = temp | 0x80; //判断获取到的像素点 else temp = temp & 0x7f; if (j % 8 == 7) //8个像素点一个字节 { //byteArray[byteArrayLength] = Convert.ToByte(temp); //byteArrayLength++; sen[k] = Convert.ToByte(temp); k++; temp = 0; } } } } }
阅读全文
0 0
- C#源码 任意语言任意大小任意字体任意排列 字符汉字取模及显示 可以自由编辑点阵 通过串口发送 pc端和手机端
- 任意语言,任意大小,任意字体,任意格式,任意范围,任意字符,任意扫描方式取模,生成字节,UNICODE_Font_宋体16_ 纵向取模下高位_数据排列_从左到右从上到下
- 俄文取模 可以生成任意语言任意大小取模 韩文日文中文意大利德文Unicode等
- 树莓派用Java实现Max7219 LED点阵输出字符常用汉字和任意字符......
- C#任意变换图像大小
- 任意大小汉字点阵字库(字模)的制作与生成 单片机GUI/STemwin
- C# 图片自由变换 任意扭曲
- Android设置SurfaceView任意大小和任意位置
- 任意数字的排列
- css嵌入任意字体
- css嵌入任意字体
- css嵌入任意字体
- vc6修改任意字体
- 任意大小缩放图片
- 输出任意大小菱形
- 任意大小矩阵乘积
- 创建任意大小数组
- 任意数比较大小
- javaHL JNI not available
- 月薪两万,头脑灵活,为什么没有女朋友,舞步学院说当代程序员的悲哀
- CentOS7 安装vsftp文件服务器
- Windows安装BeautifulSoup及使用
- [Codeforces 814E] An unavoidable detour for home DP+BFS树+组合数学
- C#源码 任意语言任意大小任意字体任意排列 字符汉字取模及显示 可以自由编辑点阵 通过串口发送 pc端和手机端
- Android中关于沉浸式状态栏的实现
- Android视频开发
- 【MyBatis】映射器(1)
- juniper QFX5100 用业务口做virtual-chassis 实例
- 剑指offer——整数中1出现的次数(从1到n整数中出现1的次数)可优化
- 利用yum下载RPM包不安装
- MAC-安装Visual Studio 2017
- Android高仿QQ及微信底部菜单的多种实现方式【附源码地址】