📄 bmp2code.frm
字号:
Put outfile_no, cu1, "};"
cu1 = cu1 + 2
End If
End Select
If StructSet And file_out_format = 0 Then '输出为C格式且生成结构:
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
temp_str1 = "struct Picture_Head Pic_" + Text_VariableName.Text + "={"
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
Put outfile_no, cu1, " 0x"
cu1 = cu1 + 6
temp_data1 = pic_width
If temp_data1 < 256 Then
temp_str1 = "00" + Hex(temp_data1)
Else
If temp_data1 < 4096 Then
temp_str1 = "0" + Hex(temp_data1)
Else
temp_str1 = Hex(temp_data1)
End If
End If
Put outfile_no, cu1, temp_str1
cu1 = cu1 + 4
Put outfile_no, cu1, ",0x"
cu1 = cu1 + 3
temp_data1 = pic_height
If temp_data1 < 256 Then
temp_str1 = "00" + Hex(temp_data1)
Else
If temp_data1 < 4096 Then
temp_str1 = "0" + Hex(temp_data1)
Else
temp_str1 = Hex(temp_data1)
End If
End If
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
temp_str1 = ", //宽度,高度"
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
Put outfile_no, cu1, " 0x"
cu1 = cu1 + 6
Select Case color_format
Case 1:
Put outfile_no, cu1, "0" + "1"
cu1 = cu1 + 2
temp_str1 = ", //单色"
Case 3:
Put outfile_no, cu1, "0" + "8"
cu1 = cu1 + 2
temp_str1 = ", //8位色"
Case 4:
Put outfile_no, cu1, "1" + "6"
cu1 = cu1 + 2
temp_str1 = ", //16位色"
End Select
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
Put outfile_no, cu1, " "
cu1 = cu1 + 4
temp_str1 = "Pic_" + Text_VariableName.Text + "_Data,"
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
Put outfile_no, cu1, " "
cu1 = cu1 + 4
If ico Then
'生成图标:
Put outfile_no, cu1, "1"
Else
Put outfile_no, cu1, "0"
End If
cu1 = cu1 + 1
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
Put outfile_no, cu1, " "
cu1 = cu1 + 4
temp_str1 = "};"
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
End If
Close infile_no
Close outfile_no
Label7.Caption = ""
Label8.Caption = ""
Command1.Enabled = True
End If
End Sub
Private Sub Command3_Click()
file_sel = 1 '选择输出文件
File1.Pattern = "*.h"
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
If file_sel Then
Text2.Text = File1.Path + "\" + File1.FileName
outfilename = Text2.Text
outfilename_en = 1 '已输入文件名
Else
Text_VariableName.Text = Mid(File1.FileName, 1, Len(File1.FileName) - 4)
Text1.Text = File1.Path + "\" + File1.FileName
infilename = Text1.Text
If Len(Text_VariableName.Text) > 8 Then
Txt_PicName.Text = Mid(Text_VariableName.Text, 1, 8)
Else
Txt_PicName.Text = Text_VariableName.Text
End If
If outfilename_en = 0 Then
If file_out_format = 2 Then
Text2.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 3) + "bin"
Else
Text2.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 3) + "h"
End If
End If
End If
Dim X As Picture
Dim input_dat As Long
Dim BM1 As Byte
Dim input_dat2 As Long
Dim a As Long
If File1.Pattern = "*.bmp" Then
infile_no = FreeFile
Open infilename For Binary Access Read As infile_no
Set X = LoadPicture(Text1.Text)
Set Picture1.Picture = X
a = 1
Get infile_no, 1, BM1
If BM1 = Asc("B") Then
a = 2
Get infile_no, 2, BM1
If BM1 = Asc("M") Then
Get infile_no, 3, input_dat
Label_filesize.Caption = Str(input_dat) + "Byte"
Get infile_no, 19, input_dat
Get infile_no, 23, input_dat2
Label_picsize.Caption = Str(input_dat) + " X" + Str(input_dat2)
Get infile_no, 29, input_dat
' Select Case input_dat
' Case 1:
If input_dat = 1 Then
Label_colre.Caption = "单色"
Else
' Case 2:
Label_colre.Caption = Str(2 ^ input_dat) + "色"
' End Select
End If
End If
End If
Close infile_no
End If
End Sub
Private Sub Form_Load()
file_sel = 0 '选择输入文件
File1.Pattern = "*.bmp"
PicNameF = GetSetting("BMP2CODE", "PicNameSet", "PicNameF", "0")
If PicNameF Then
Label10.Visible = True
Txt_PicName.Visible = True
Check_PicName.Value = 1
Else
Label10.Visible = False
Txt_PicName.Visible = False
Check_PicName.Value = 0
End If
bit15_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit15_c16", "16")
bit14_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit14_c16", "15")
bit13_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit13_c16", "14")
bit12_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit12_c16", "11")
bit11_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit11_c16", "10")
bit10_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit10_c16", "9")
bit9_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit9_c16 ", "4")
bit8_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit8_c16 ", "3")
bit7_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit7_c16 ", "2")
bit6_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit6_c16 ", "8")
bit5_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit5_c16 ", "13")
bit4_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit4_c16 ", "1")
bit3_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit3_c16 ", "7")
bit2_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit2_c16 ", "12")
bit1_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit1_c16 ", "0")
bit0_c16 = GetSetting("BMP2CODE", "C16BitSet", "bit0_c16 ", "6")
bit7_c8 = GetSetting("BMP2CODE", "C8BitSet", "bit7_c8", "2") 'R4
bit6_c8 = GetSetting("BMP2CODE", "C8BitSet", "bit6_c8", "8") 'G4
bit5_c8 = GetSetting("BMP2CODE", "C8BitSet", "bit5_c8", "13") 'B5
bit4_c8 = GetSetting("BMP2CODE", "C8BitSet", "bit4_c8", "1") 'R5
bit3_c8 = GetSetting("BMP2CODE", "C8BitSet", "bit3_c8", "7") 'G5
bit2_c8 = GetSetting("BMP2CODE", "C8BitSet", "bit2_c8", "12") 'B6
bit1_c8 = GetSetting("BMP2CODE", "C8BitSet", "bit1_c8", "0") 'R6
bit0_c8 = GetSetting("BMP2CODE", "C8BitSet", "bit0_c8", "6") 'G6
file_out_format = GetSetting("BMP2CODE", "Format", "file_out_format", "0")
color_format = GetSetting("BMP2CODE", "Format", "color_format", "3")
array_format = GetSetting("BMP2CODE", "Format", "array_format", "1")
StructSet = GetSetting("BMP2CODE", "Format", "StructSet", "1")
ico = GetSetting("BMP2CODE", "Format", "ico", "1")
Select Case file_out_format
Case 0
Call Option_c_Click
Option_a.Value = False
Option_c.Value = True
Option_bin.Value = False
If (StructSet) Then
Che_struct.Value = 1
Else
Che_struct.Value = 0
End If
If (ico) Then
Check_ico.Value = 1
Else
Check_ico.Value = 0
End If
Case 1
Call Option_a_Click
Option_a.Value = True
Option_c.Value = False
Option_bin.Value = False
Case 2
Call Option_bin_Click
Option_a.Value = False
Option_c.Value = False
Option_bin.Value = True
End Select
Select Case color_format
Case 0: '黑白
Call Option1_Click
Option1.Value = True
Option2.Value = False
Option3.Value = False
Option4.Value = False
Option5.Value = False
Case 1: '4级灰度
Call Option2_Click
Option1.Value = False
Option2.Value = True
Option3.Value = False
Option4.Value = False
Option5.Value = False
Case 2: '16级灰度
Call Option3_Click
Option1.Value = False
Option2.Value = False
Option3.Value = True
Option4.Value = False
Option5.Value = False
Case 3: '8位彩色
Call Option4_Click
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = True
Option5.Value = False
Case 4: '16位彩色
Call Option5_Click
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = False
Option5.Value = True
End Select
' file_out_format = 0 '输出格式:c
' outfilename_en = 0
' color_format = 3 '彩色格式:8位色
' array_format = 1 '2维数组
' 0=R6
' 1=R5
' 2=R4
' 3=R3
' 4=R2
' 5=R1
' 6=G6
' 7=G5
' 8=G4
' 9=G3
' 10=G2
' 11=G1
' 12=B6
' 13=B5
' 14=B4
' 15=B3
' 16=B2
' 17=B1
bit_c8_change = 1
bit_c16_change = 1
End Sub
Private Sub Option_a_Click()
file_out_format = 1 '输出格式:ASM
Frame2.Enabled = False '数组设置无效
Che_struct.Enabled = False
Check_ico.Enabled = False
Text_VariableName.Visible = True
Label9.Visible = True
Call Save_set
End Sub
Private Sub Option_bin_Click()
file_out_format = 2 '输出格式:BIN
Frame2.Enabled = False '数组设置无效
Che_struct.Enabled = False
Check_ico.Enabled = False
Text_VariableName.Visible = False
Label9.Visible = False
Call Save_set
End Sub
Private Sub Option_c_Click()
file_out_format = 0 '输出格式:c
Frame2.Enabled = True '数组设置有效
Che_struct.Enabled = True
Check_ico.Enabled = True
Text_VariableName.Visible = True
Label9.Visible = True
Call Save_set
End Sub
Private Sub Option1_Click()
color_format = 0 '彩色格式:黑白
Combo_B15.Visible = False
Label_B15.Visible = False
Combo_B14.Visible = False
Label_B14.Visible = False
Combo_B13.Visible = False
Label_B13.Visible = False
Combo_B12.Visible = False
Label_B12.Visible = False
Combo_B11.Visible = False
Label_B11.Visible = False
Combo_B10.Visible = False
Label_B10.Visible = False
Combo_B9.Visible = False
Label_B9.Visible = False
Combo_B8.Visible = False
Label_B8.Visible = False
Combo_B7.Visible
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -