资源简介
以倚天16x15字型作為翻譯基準
輸入中英文字(不包含特殊符號,基本ASCII可以使用),翻譯成每個字每個字的16x15 Byte 圖形
如有字幕機可搭配註解區段使用
for (i = 0; i < srvch.Length; i ) { oneltr = srvch[i].ToString(); if (Encoding.GetEncoding(950).GetByteCount(oneltr) < 2) { tmp = Encoding.ASCII.GetBytes(oneltr); hi = tmp[0]; offset = hi * 15; for (j = i * 34, h = 0; h < 34; h = 2, j = 2) { if (h < 30) { tx[j] = ascf[offset]; } else if (h >= 30 && h < 32) tx[j] = 0x00; else if (h == 32 && i != srvch.Length - 1) { tx[j] = 0x94; tx[j 1] = 0xd0; } offset ; } } else { tmp = Encoding.GetEncoding(950).GetBytes(oneltr); hi = tmp[0]; lo = tmp[1]; if (lo >= 161) sercode = (hi - 161) * 157 (lo - 161) 1 63; else sercode = (hi - 161) * 157 (lo - 64) 1; if (sercode >= 472 && sercode <= 5872) offset = (sercode - 472) * 30; else if (sercode >= 6281 && sercode <= 13973) offset = (sercode - 6281) * 30 162030; for (j = i * 34, h = 0; h < 34; j , h ) { if (h < 30) { if (offset > 3) { tx[j] = stdf[offset - 2]; } else { tx[j] = stdf[offset]; } } else if (h < 32) tx[j] = 0x00; else if (h == 32 && i != srvch.Length - 1) tx[j] = 0x94; else if (h == 33 && i != srvch.Length - 1) tx[j] = 0xd0; offset ; } } }
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
using System.IO;
namespace TEST
{
public partial class ETtranslate : Form
{
public ETtranslate()
{
InitializeComponent();
}
static Dictionary datapool = new Dictionary();
private void button1_Click(object sender EventArgs e)
{
SerialPort RS = new SerialPort(“COM1“ 9600 Parity.None 8 StopBits.One);
byte[] stdf = File.ReadAllBytes(“stdfont.15“);
byte[] ascf = File.ReadAllBytes(“ascfont.15“);
// 字幕機格式
Byte[] bgn = new Byte[] { 0xf1 0xb0 0xdf 0x22 0x20 0x41 0x22 0x80 0x94 0x9b 0xd0 };
Byte[] end = new Byte[] { 0xbf };
// 所以每 32 Byte
- 上一篇:一汽零部件二维码解析
- 下一篇:asp.net 页面数据压缩回传
评论
共有 条评论