字模转换工具源代码.docx

上传人:b****2 文档编号:1421868 上传时间:2023-04-30 格式:DOCX 页数:31 大小:19.44KB
下载 相关 举报
字模转换工具源代码.docx_第1页
第1页 / 共31页
字模转换工具源代码.docx_第2页
第2页 / 共31页
字模转换工具源代码.docx_第3页
第3页 / 共31页
字模转换工具源代码.docx_第4页
第4页 / 共31页
字模转换工具源代码.docx_第5页
第5页 / 共31页
字模转换工具源代码.docx_第6页
第6页 / 共31页
字模转换工具源代码.docx_第7页
第7页 / 共31页
字模转换工具源代码.docx_第8页
第8页 / 共31页
字模转换工具源代码.docx_第9页
第9页 / 共31页
字模转换工具源代码.docx_第10页
第10页 / 共31页
字模转换工具源代码.docx_第11页
第11页 / 共31页
字模转换工具源代码.docx_第12页
第12页 / 共31页
字模转换工具源代码.docx_第13页
第13页 / 共31页
字模转换工具源代码.docx_第14页
第14页 / 共31页
字模转换工具源代码.docx_第15页
第15页 / 共31页
字模转换工具源代码.docx_第16页
第16页 / 共31页
字模转换工具源代码.docx_第17页
第17页 / 共31页
字模转换工具源代码.docx_第18页
第18页 / 共31页
字模转换工具源代码.docx_第19页
第19页 / 共31页
字模转换工具源代码.docx_第20页
第20页 / 共31页
亲,该文档总共31页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

字模转换工具源代码.docx

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

字模转换工具源代码.docx

字模转换工具源代码

下面是全部源代码

BeginVB.FormForm1

AutoRedraw=-1'True

BorderStyle=3'FixedDialog

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=346

ScaleMode=3'Pixel

ScaleWidth=680

ShowInTaskbar=0'False

BeginVB.CheckBoxCheck1

Caption="压缩字库"

Height=375

Left=3240

TabIndex=34

Top=3240

Width=1335

End

BeginVB.FrameFrame5

Caption="图片或字模尺寸(单位:

8*8Pix)"

Enabled=0'False

Height=735

Left=120

TabIndex=30

Top=3720

Width=4455

BeginVB.VScrollBarVScrollW

Height=375

Left=3600

Max=0

Min=32767

TabIndex=33

Top=240

Value=32

Width=375

End

BeginVB.TextBoxtxImgWidth

Height=390

Left=2760

Locked=-1'True

TabIndex=32

Text="32"

Top=240

Width=855

End

BeginVB.LabelLabel7

Caption="图片或字模宽度"

Height=255

Left=120

TabIndex=31

Top=360

Width=1335

End

End

BeginVB.FrameFrame1

Caption="偏移量(仅针对位图,因为计算字模偏移量太麻烦了)"

Enabled=0'False

Height=855

Left=120

TabIndex=23

Top=1440

Width=4455

BeginVB.VScrollBarVScrollY

Height=375

Left=3600

Max=0

Min=16

TabIndex=29

Top=240

Width=375

End

BeginVB.VScrollBarVScrollX

Height=375

Left=1560

Max=0

Min=16

TabIndex=28

Top=240

Width=375

End

BeginVB.TextBoxtxOffsetY

Height=375

Left=3000

Locked=-1'True

TabIndex=27

Text="0"

Top=240

Width=615

End

BeginVB.TextBoxtxOffsetX

Height=375

Left=960

Locked=-1'True

TabIndex=26

Text="0"

Top=240

Width=615

End

BeginVB.LabelLabel6

Caption="OffsetY:

"

Height=255

Left=2160

TabIndex=25

Top=360

Width=855

End

BeginVB.LabelLabel5

Caption="OffsetX:

"

Height=255

Left=120

TabIndex=24

Top=360

Width=855

End

End

BeginVB.PictureBoxPicture1

AutoRedraw=-1'True

ForeColor=&H00800080&

Height=3495

Left=4920

ScaleHeight=229

ScaleMode=3'Pixel

ScaleWidth=341

TabIndex=19

Top=120

Width=5175

End

BeginVB.FrameFrame4

Caption="调色-透明"

Height=1215

Left=1680

TabIndex=10

Top=2400

Width=1455

BeginVB.OptionButtonTSB3

Caption="11"

Height=375

Left=840

TabIndex=18

Top=720

Width=495

End

BeginVB.OptionButtonTSB2

Caption="10"

Height=375

Left=120

TabIndex=17

Top=720

Width=495

End

BeginVB.OptionButtonTSB1

Caption="01"

Height=375

Left=840

TabIndex=16

Top=240

Width=495

End

BeginVB.OptionButtonTSB0

Caption="00"

Height=375

Left=120

TabIndex=15

Top=240

Value=-1'True

Width=495

End

End

BeginVB.FrameFrame3

Caption="调色-字模"

Height=1215

Left=120

TabIndex=9

Top=2400

Width=1455

BeginVB.OptionButtonTSA3

Caption="11"

Height=375

Left=840

TabIndex=14

Top=720

Width=495

End

BeginVB.OptionButtonTSA2

Caption="10"

Height=375

Left=120

TabIndex=13

Top=720

Width=495

End

BeginVB.OptionButtonTSA1

Caption="01"

Height=375

Left=840

TabIndex=12

Top=240

Value=-1'True

Width=495

End

BeginVB.OptionButtonTSA0

Caption="00"

Height=375

Left=120

TabIndex=11

Top=240

Width=495

End

End

BeginVB.CommandButtonCommandToChr

Caption="转换成字模"

Height=495

Left=2400

TabIndex=8

Top=4560

Width=2175

End

BeginVB.CommandButtonCommandToBmp

Caption="转换成位图"

Enabled=0'False

Height=495

Left=120

TabIndex=7

Top=4560

Width=2175

End

BeginVB.FrameFrame2

Caption="字体大小"

Height=735

Left=120

TabIndex=2

Top=600

Width=4455

BeginVB.OptionButtonZT16

Caption="16"

Height=375

Left=3240

TabIndex=6

Top=240

Width=735

End

BeginVB.OptionButtonZT14

Caption="14"

Height=375

Left=2160

TabIndex=5

Top=240

Width=975

End

BeginVB.OptionButtonZT12

Caption="12"

Height=375

Left=1080

TabIndex=4

Top=240

Value=-1'True

Width=855

End

BeginVB.OptionButtonZT10

Caption="10"

Height=375

Left=120

TabIndex=3

Top=240

Width=855

End

End

BeginVB.TextBoxText1

Height=375

Left=1080

TabIndex=1

Top=120

Width=3495

End

BeginVB.LabelLabel8

Caption="字模A=01+03字模B=10+03透明C=00"

Height=735

Left=3240

TabIndex=35

Top=2520

Visible=0'False

Width=1335

End

BeginVB.LabelLabel4

Caption="提示信息"

Height=375

Left=4920

TabIndex=22

Top=3720

Width=5175

End

BeginVB.LabelLabel3

Caption="预览窗口>>"

Height=1455

Left=4680

TabIndex=21

Top=120

Width=255

End

BeginVB.LabelLabel2

Caption="by六十六Yu.Lee."

Height=255

Left=7080

TabIndex=20

Top=4800

Width=3015

End

BeginVB.LabelLabel1

Caption="字库文件"

Height=255

Left=240

TabIndex=0

Top=240

Width=855

End

End

AttributeVB_Name="Form1"

AttributeVB_GlobalNameSpace=False

AttributeVB_Creatable=False

AttributeVB_PredeclaredId=True

AttributeVB_Exposed=False

PrivateZK_PATHAsString

'PrivateZK_TYPEAsInteger

PrivateZK_SIZEAsInteger

PrivateZK_COLOR_AAsInteger

'PrivateZK_COLOR_BAsInteger

PrivateZK_COLOR_CAsInteger

PrivateZK_OVERLAPAsBoolean'重叠绘制?

PrivateZK_OFFSET_XAsInteger

PrivateZK_OFFSET_YAsInteger

PrivateZK_IMG_WIDTHAsInteger

PrivateZK_IMG_HEIGHTAsInteger

'PrivateConstCHAR_128AsByte=128

'字库绘制出来时候的X,Y坐标

PrivateDRAW_XAsLong

PrivateDRAW_YAsLong

'读取当前设定选项

PrivateSubLoadParams()

'IfHZK.Value=TrueThenZK_TYPE=0

'IfGBK.Value=TrueThenZK_TYPE=1

ZK_IMG_WIDTH=CInt(txImgWidth.Text)

ZK_OFFSET_X=CInt(txOffsetX.Text)

ZK_OFFSET_Y=CInt(txOffsetY.Text)

IfZT10.Value=TrueThenZK_SIZE=10

IfZT12.Value=TrueThenZK_SIZE=12

IfZT14.Value=TrueThenZK_SIZE=14

IfZT16.Value=TrueThenZK_SIZE=16

IfCheck1.Value=0Then

IfTSA0.Value=TrueThenZK_COLOR_A=0

IfTSA1.Value=TrueThenZK_COLOR_A=1

IfTSA2.Value=TrueThenZK_COLOR_A=2

IfTSA3.Value=TrueThenZK_COLOR_A=3

IfTSB0.Value=TrueThenZK_COLOR_C=0

IfTSB1.Value=TrueThenZK_COLOR_C=1

IfTSB2.Value=TrueThenZK_COLOR_C=2

IfTSB3.Value=TrueThenZK_COLOR_C=3

ElseIfCheck1.Value=1Then

ZK_COLOR_A=1

'ZK_COLOR_B=2

ZK_COLOR_C=0

EndIf

EndSub

'转换成位图

PrivateSubCommandToBmp_Click()

'清空预览框

'读取参数

LoadParams

'读取字库文件

DimnFileSizeAsLong

DimbyteFileBuf()AsByte

'打开字库文件

OpenZK_PATHForBinaryAs1

OnErrorGoToERROR_MESSAGE

'取得文件字节总数

nFileSize=LOF

(1)

'将字库文件读入缓冲区

ReDimbyteFileBuf(1TonFileSize)AsByte

Get1,,byteFileBuf

Close1

'分析字模

DimnHZCountAsLong'字库中包含的汉字数

DimnBytePerHZAsLong'每个汉字所占的字节数

'每个汉字占用字库的字节数

'字库中的汉字个数

SelectCaseZK_SIZE

Case10

nBytePerHZ=20

nHZCount=nFileSize/20

Case12

nBytePerHZ=24

nHZCount=nFileSize/24

Case14

nBytePerHZ=28

nHZCount=nFileSize/28

Case16

nBytePerHZ=32

nHZCount=nFileSize/32

EndSelect

'计算将要生成的位图大小

'只计算出高度占用图块数即可利用高度块数和宽度块数可以计算所有的关于图片尺寸的数值

'不论是10,12,14还是16号字,每个汉字在NES字库中我都希望它占用4个8*8Pix图块

'所以字库占用的图块数==字库字数*4

DimnImgCountAsLong

'计算转换这套字库一共需要多少个图块

nImgCount=nHZCount*4

'计算生成图像高度是多少个图块(注意对某些情况下不能整除的补齐)

ZK_IMG_HEIGHT=(nImgCount+(nImgCountModZK_IMG_WIDTH))/ZK_IMG_WIDTH

'析出字

DimnIndexAsLong

DimnLocationAsLong

DimnRMulAsByte'计算右移乘数,因为VB里没有移位运算符

Dimpx,pyAsLong'临时变量,记录要绘点的位置

'初始化原点

DRAW_X=0

DRAW_Y=0

'遍历所有汉字

FornIndex=1TonHZCount

'得到一个字的数据首地址

'注意VB中按字节读取文件的索引是从1开始的

nLocation=(nIndex-1)*nBytePerHZ+1

Fori=0To(nBytePerHZ-1)

Forj=0To7

'这一步为了减少运算量,如果字节为零,则对应8位全为零

'下一步位运算就没有必要了[这两行代码可以去掉]

IfbyteFileBuf(nLocation+i)=0Then

GoToNEXT_LOOP

EndIf

'计算移位乘数

SelectCasej

Case0:

nRMul=1

Case1:

nRMul=2

Case2:

nRMul=4

Case3:

nRMul=8

Case4:

nRMul=16

Case5:

nRMul=32

Case6:

nRMul=64

Case7:

nRMul=128

EndSelect

'注意括号,and和<>是同一级运算

If(byteFileBuf(nLocation+i)And(CHAR_128\nRMul))<>0Then

'欲绘点的坐标

px=DRAW_X+j+(iMod2)*8

py=DRAW_Y+i\2

'加入偏移量

px=px+ZK_OFFSET_X

py=py+ZK_OFFSET_Y

'TODO

'...

'预览窗口

'预览窗口只显示15行字模

IfDRAW_Y<=ZK_SIZE*15Then'只显示前15列

Picture1.PSet(px,py)

DoEvents

Else:

GoToNEXT_LOOP

EndIf

EndIf

NEXT_LOOP:

Nextj

Nexti

IfDRAW_X>ZK_SIZE*24Then'每行只显示24个字

DRAW_X=0

DRAW_Y=DRAW_Y+ZK_SIZE

Else

DRAW_X=DRAW_X+16'为了凑整,10-16的字库每个字的宽度都是16

EndIf

'转换进度显示

Label4.Caption=nIndex&"/"&nHZCount

DoEvents

NextnIndex

Label4.Caption=nHZCount&"个汉字转换完成!

"

GoToEND_SUB

ERROR_MESSAGE:

Close1

MsgBox"我擦~出错了?

!

"

END_SUB:

EndSub

'转换成NES字模文件

PrivateSubCommandToChr_Click()

'清空预览框

'读取参数

LoadParams

'读取字库文件

DimnFileSizeAsLong

DimbyteFileBuf()AsByte'字库文件缓冲

DimNesBufIndexAsLong'欲生成的Nes文件缓冲的索引

NesBufIndex=1'初始化

DimbyteNesBuf()AsByte'欲生成的Nes文件缓冲(比字库文件缓冲至少大两倍,因为NES是固定的16*16Pix一个字)

'打开字库文件

OpenZK_PATHForBinaryAs#1

OnErrorGoToERROR_MESSAGE

'取得文件字节总数

nFileSize=LOF

(1)

'将字库文件读入缓冲区

ReDimbyteFileBuf(1TonFileSize)AsByte

Get#1,,byteFileBuf

Close#1

'分析字模

DimnHZCountAsLong'字库中包含的汉字数

DimnBytePerHZAsLong'每个汉字所占的字节数

'每个汉字占用字库的字节数

'字库中的汉字个数

SelectCaseZK_SIZE

Case10

nBytePerHZ=20

nHZCount=nFileSize/20

Case12

nBytePerHZ=24

nHZCount=nFileSize/24

Case14

nBytePerHZ=28

nHZCount=nFileSize/28

Case16

nBytePerHZ=32

nHZCount=nFileSize/32

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

当前位置:首页 > 求职职场 > 简历

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

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