字模转换工具源代码.doc

上传人:rrsccc 文档编号:9271527 上传时间:2021-02-13 格式:DOC 页数:22 大小:120KB
返回 下载 相关 举报
字模转换工具源代码.doc_第1页
第1页 / 共22页
字模转换工具源代码.doc_第2页
第2页 / 共22页
字模转换工具源代码.doc_第3页
第3页 / 共22页
字模转换工具源代码.doc_第4页
第4页 / 共22页
字模转换工具源代码.doc_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《字模转换工具源代码.doc》由会员分享,可在线阅读,更多相关《字模转换工具源代码.doc(22页珍藏版)》请在三一文库上搜索。

1、下面是全部源代码VERSION 5.00Begin 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 ScaleHeigh

2、t = 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

4、= 255 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

5、= 375 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 = -

6、1 True 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 Picture

7、1 AutoRedraw = -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 Ca

8、ption = 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.OptionBu

9、tton 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 T

11、abIndex = 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 Begi

12、n VB.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

13、 Begin 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 W

14、idth = 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.FGameG 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 EndEndAttr

16、ibute VB_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_

17、C As IntegerPrivate 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()ZK_

18、PATH = Text1.TextIf HZK.Value = 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_SI

19、ZE = 14If ZT16.Value = True Then 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

20、 ZK_COLOR_C = 1 If TSB2.Value = 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()清空预览框Picture1.Cls读取参数LoadParams读取字库文件 Dim nFileSize As Long Dim byteFileBuf() As

21、 Byte 打开字库文件 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 n

22、BytePerHZ = 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 End Select计算将要生成的位图大小只计算出高度占用图块数即可 利用高度块数和宽度块数 可以计算所有的关于图片尺寸的数值 不论是10,12,14还是16号字, 每个汉字在NES字库中我都希望它占用4个 8*8Pi

23、x 图块 所以 字库占用的图块数 = 字库字数 * 4 Dim nImgCount 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

24、 临时变量, 记录要绘点的位置 初始化原点 DRAW_X = 0 DRAW_Y = 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_L

25、OOP End If 计算移位乘数 Select Case j Case 0: nRMul = 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 + ZK_OFFSET_X py = py + ZK_OFFSET_Y

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1