ImageVerifierCode 换一换
格式:DOCX , 页数:31 ,大小:19.44KB ,
资源ID:1421868      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-1421868.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(字模转换工具源代码.docx)为本站会员(b****2)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

字模转换工具源代码.docx

1、字模转换工具源代码下面是全部源代码Begin VB.Form Form1 AutoRedraw = -1 True BorderStyle = 3 Fixed Dialog Caption = 点阵字库2NES字模 ClientHeight = 5190 ClientLeft = 4500 ClientTop = 2385 ClientWidth = 10200 ForeColor = &H8000000F& Icon = Form1.frx:0000 LinkTopic = Form1 MaxButton = 0 False MinButton = 0 False ScaleHeight =

2、 346 ScaleMode = 3 Pixel ScaleWidth = 680 ShowInTaskbar = 0 False Begin VB.CheckBox Check1 Caption = 压缩字库 Height = 375 Left = 3240 TabIndex = 34 Top = 3240 Width = 1335 End Begin VB.Frame Frame5 Caption = 图片或字模尺寸(单位:8*8 Pix) Enabled = 0 False Height = 735 Left = 120 TabIndex = 30 Top = 3720 Width =

3、4455 Begin VB.VScrollBar VScrollW Height = 375 Left = 3600 Max = 0 Min = 32767 TabIndex = 33 Top = 240 Value = 32 Width = 375 End Begin VB.TextBox txImgWidth Height = 390 Left = 2760 Locked = -1 True TabIndex = 32 Text = 32 Top = 240 Width = 855 End Begin VB.Label Label7 Caption = 图片或字模宽度 Height = 2

4、55 Left = 120 TabIndex = 31 Top = 360 Width = 1335 End End Begin VB.Frame Frame1 Caption = 偏移量(仅针对位图,因为计算字模偏移量太麻烦了) Enabled = 0 False Height = 855 Left = 120 TabIndex = 23 Top = 1440 Width = 4455 Begin VB.VScrollBar VScrollY Height = 375 Left = 3600 Max = 0 Min = 16 TabIndex = 29 Top = 240 Width = 3

5、75 End Begin VB.VScrollBar VScrollX Height = 375 Left = 1560 Max = 0 Min = 16 TabIndex = 28 Top = 240 Width = 375 End Begin VB.TextBox txOffsetY Height = 375 Left = 3000 Locked = -1 True TabIndex = 27 Text = 0 Top = 240 Width = 615 End Begin VB.TextBox txOffsetX Height = 375 Left = 960 Locked = -1 T

6、rue TabIndex = 26 Text = 0 Top = 240 Width = 615 End Begin VB.Label Label6 Caption = Offset Y: Height = 255 Left = 2160 TabIndex = 25 Top = 360 Width = 855 End Begin VB.Label Label5 Caption = Offset X: Height = 255 Left = 120 TabIndex = 24 Top = 360 Width = 855 End End Begin VB.PictureBox Picture1 A

7、utoRedraw = -1 True ForeColor = &H00800080& Height = 3495 Left = 4920 ScaleHeight = 229 ScaleMode = 3 Pixel ScaleWidth = 341 TabIndex = 19 Top = 120 Width = 5175 End Begin VB.Frame Frame4 Caption = 调色-透明 Height = 1215 Left = 1680 TabIndex = 10 Top = 2400 Width = 1455 Begin VB.OptionButton TSB3 Capti

8、on = 11 Height = 375 Left = 840 TabIndex = 18 Top = 720 Width = 495 End Begin VB.OptionButton TSB2 Caption = 10 Height = 375 Left = 120 TabIndex = 17 Top = 720 Width = 495 End Begin VB.OptionButton TSB1 Caption = 01 Height = 375 Left = 840 TabIndex = 16 Top = 240 Width = 495 End Begin VB.OptionButto

9、n TSB0 Caption = 00 Height = 375 Left = 120 TabIndex = 15 Top = 240 Value = -1 True Width = 495 End End Begin VB.Frame Frame3 Caption = 调色-字模 Height = 1215 Left = 120 TabIndex = 9 Top = 2400 Width = 1455 Begin VB.OptionButton TSA3 Caption = 11 Height = 375 Left = 840 TabIndex = 14 Top = 720 Width =

10、495 End Begin VB.OptionButton TSA2 Caption = 10 Height = 375 Left = 120 TabIndex = 13 Top = 720 Width = 495 End Begin VB.OptionButton TSA1 Caption = 01 Height = 375 Left = 840 TabIndex = 12 Top = 240 Value = -1 True Width = 495 End Begin VB.OptionButton TSA0 Caption = 00 Height = 375 Left = 120 TabI

11、ndex = 11 Top = 240 Width = 495 End End Begin VB.CommandButton CommandToChr Caption = 转换成字模 Height = 495 Left = 2400 TabIndex = 8 Top = 4560 Width = 2175 End Begin VB.CommandButton CommandToBmp Caption = 转换成位图 Enabled = 0 False Height = 495 Left = 120 TabIndex = 7 Top = 4560 Width = 2175 End Begin V

12、B.Frame Frame2 Caption = 字体大小 Height = 735 Left = 120 TabIndex = 2 Top = 600 Width = 4455 Begin VB.OptionButton ZT16 Caption = 16 Height = 375 Left = 3240 TabIndex = 6 Top = 240 Width = 735 End Begin VB.OptionButton ZT14 Caption = 14 Height = 375 Left = 2160 TabIndex = 5 Top = 240 Width = 975 End Be

13、gin VB.OptionButton ZT12 Caption = 12 Height = 375 Left = 1080 TabIndex = 4 Top = 240 Value = -1 True Width = 855 End Begin VB.OptionButton ZT10 Caption = 10 Height = 375 Left = 120 TabIndex = 3 Top = 240 Width = 855 End End Begin VB.TextBox Text1 Height = 375 Left = 1080 TabIndex = 1 Top = 120 Widt

14、h = 3495 End Begin VB.Label Label8 Caption = 字模A= 01 + 03 字模B= 10 + 03 透明C= 00 Height = 735 Left = 3240 TabIndex = 35 Top = 2520 Visible = 0 False Width = 1335 End Begin VB.Label Label4 Caption = 提示信息 Height = 375 Left = 4920 TabIndex = 22 Top = 3720 Width = 5175 End Begin VB.Label Label3 Caption =

15、预览窗口 Height = 1455 Left = 4680 TabIndex = 21 Top = 120 Width = 255 End Begin VB.Label Label2 Caption = by 六十六 Yu.Lee. Height = 255 Left = 7080 TabIndex = 20 Top = 4800 Width = 3015 End Begin VB.Label Label1 Caption = 字库文件 Height = 255 Left = 240 TabIndex = 0 Top = 240 Width = 855 EndEndAttribute VB_

16、Name = Form1Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate ZK_PATH As StringPrivate ZK_TYPE As IntegerPrivate ZK_SIZE As IntegerPrivate ZK_COLOR_A As IntegerPrivate ZK_COLOR_B As IntegerPrivate ZK_COLOR_C As Inte

17、gerPrivate ZK_OVERLAP As Boolean 重叠绘制?Private ZK_OFFSET_X As IntegerPrivate ZK_OFFSET_Y As IntegerPrivate ZK_IMG_WIDTH As IntegerPrivate ZK_IMG_HEIGHT As IntegerPrivate Const CHAR_128 As Byte = 128字库绘制出来时候的X, Y坐标Private DRAW_X As LongPrivate DRAW_Y As Long读取当前设定选项Private Sub LoadParams()If HZK.Value

18、 = True Then ZK_TYPE = 0If GBK.Value = True Then ZK_TYPE = 1ZK_IMG_WIDTH = CInt(txImgWidth.Text)ZK_OFFSET_X = CInt(txOffsetX.Text)ZK_OFFSET_Y = CInt(txOffsetY.Text)If ZT10.Value = True Then ZK_SIZE = 10If ZT12.Value = True Then ZK_SIZE = 12If ZT14.Value = True Then ZK_SIZE = 14If ZT16.Value = True T

19、hen ZK_SIZE = 16If Check1.Value = 0 Then If TSA0.Value = True Then ZK_COLOR_A = 0 If TSA1.Value = True Then ZK_COLOR_A = 1 If TSA2.Value = True Then ZK_COLOR_A = 2 If TSA3.Value = True Then ZK_COLOR_A = 3 If TSB0.Value = True Then ZK_COLOR_C = 0 If TSB1.Value = True Then ZK_COLOR_C = 1 If TSB2.Value

20、 = True Then ZK_COLOR_C = 2 If TSB3.Value = True Then ZK_COLOR_C = 3ElseIf Check1.Value = 1 Then ZK_COLOR_A = 1 ZK_COLOR_B = 2 ZK_COLOR_C = 0End IfEnd Sub转换成位图Private Sub CommandToBmp_Click()清空预览框读取参数LoadParams读取字库文件 Dim nFileSize As Long Dim byteFileBuf() As Byte 打开字库文件 Open ZK_PATH For Binary As 1

21、 On Error GoTo ERROR_MESSAGE 取得文件字节总数 nFileSize = LOF(1) 将字库文件读入缓冲区 ReDim byteFileBuf(1 To nFileSize) As Byte Get 1, , byteFileBuf Close 1分析字模 Dim nHZCount As Long 字库中包含的汉字数 Dim nBytePerHZ As Long 每个汉字所占的字节数 每个汉字占用字库的字节数 字库中的汉字个数 Select Case ZK_SIZE Case 10 nBytePerHZ = 20 nHZCount = nFileSize / 20

22、Case 12 nBytePerHZ = 24 nHZCount = nFileSize / 24 Case 14 nBytePerHZ = 28 nHZCount = nFileSize / 28 Case 16 nBytePerHZ = 32 nHZCount = nFileSize / 32 End Select计算将要生成的位图大小只计算出高度占用图块数即可 利用高度块数和宽度块数 可以计算所有的关于图片尺寸的数值 不论是10,12,14还是16号字, 每个汉字在NES字库中我都希望它占用4个 8*8Pix 图块 所以 字库占用的图块数 = 字库字数 * 4 Dim nImgCount

23、 As Long 计算转换这套字库一共需要多少个图块 nImgCount = nHZCount * 4 计算生成图像高度是多少个图块(注意对某些情况下不能整除的补齐) ZK_IMG_HEIGHT = (nImgCount + (nImgCount Mod ZK_IMG_WIDTH) / ZK_IMG_WIDTH析出字 Dim nIndex As Long Dim nLocation As Long Dim nRMul As Byte 计算右移乘数, 因为VB里没有移位运算符 Dim px, py As Long 临时变量, 记录要绘点的位置 初始化原点 DRAW_X = 0 DRAW_Y =

24、0 遍历所有汉字 For nIndex = 1 To nHZCount 得到一个字的数据首地址 注意VB中按字节读取文件的索引是从1开始的 nLocation = (nIndex - 1) * nBytePerHZ + 1 For i = 0 To (nBytePerHZ - 1) For j = 0 To 7 这一步为了减少运算量, 如果字节为零, 则对应8位全为零 下一步位运算就没有必要了这两行代码可以去掉 If byteFileBuf(nLocation + i) = 0 Then GoTo NEXT_LOOP End If 计算移位乘数 Select Case j Case 0: nR

25、Mul = 1 Case 1: nRMul = 2 Case 2: nRMul = 4 Case 3: nRMul = 8 Case 4: nRMul = 16 Case 5: nRMul = 32 Case 6: nRMul = 64 Case 7: nRMul = 128 End Select 注意括号, and 和 是同一级运算 If (byteFileBuf(nLocation + i) And (CHAR_128 nRMul) 0 Then 欲绘点的坐标 px = DRAW_X + j + (i Mod 2) * 8 py = DRAW_Y + i 2 加入偏移量 px = px +

26、 ZK_OFFSET_X py = py + ZK_OFFSET_Y TODO . 预览窗口 预览窗口只显示15行字模 If DRAW_Y ZK_SIZE * 24 Then 每行只显示24个字 DRAW_X = 0 DRAW_Y = DRAW_Y + ZK_SIZE Else DRAW_X = DRAW_X + 16 为了凑整, 10 - 16 的字库每个字的宽度都是16 End If 转换进度显示 Label4.Caption = nIndex & / & nHZCount DoEvents Next nIndexLabel4.Caption = nHZCount & 个汉字转换完成!Go

27、To END_SUBERROR_MESSAGE: Close 1 MsgBox 我擦出错了?!END_SUB:End Sub转换成NES字模文件Private Sub CommandToChr_Click()清空预览框读取参数LoadParams读取字库文件 Dim nFileSize As Long Dim byteFileBuf() As Byte 字库文件缓冲 Dim NesBufIndex As Long 欲生成的Nes文件缓冲的索引 NesBufIndex = 1 初始化 Dim byteNesBuf() As Byte 欲生成的Nes文件缓冲(比字库文件缓冲至少大两倍, 因为NES

28、是固定的16*16Pix 一个字) 打开字库文件 Open ZK_PATH For Binary As #1 On Error GoTo ERROR_MESSAGE 取得文件字节总数 nFileSize = LOF(1) 将字库文件读入缓冲区 ReDim byteFileBuf(1 To nFileSize) As Byte Get #1, , byteFileBuf Close #1分析字模 Dim nHZCount As Long 字库中包含的汉字数 Dim nBytePerHZ As Long 每个汉字所占的字节数 每个汉字占用字库的字节数 字库中的汉字个数 Select Case ZK_SIZE Case 10 nBytePerHZ = 20 nHZCount = nFileSize / 20 Case 12 nBytePerHZ = 24 nHZCount = nFileSize / 24 Case 14 nBytePerHZ = 28 nHZCount = nFileSize / 28 Case 16 nBytePerHZ = 32 nHZCount = nFileSize / 32

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2