📄 bmp2code.frm
字号:
End Sub
Private Sub Combo_B4_Click()
bit4 = Combo_B4.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
bit4_c8 = bit4
Case 4:
bit_c16_change = 1
bit4_c16 = bit4
End Select
Call Save_set
End Sub
Private Sub Combo_B5_Click()
bit5 = Combo_B5.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
bit5_c8 = bit5
Case 4:
bit_c16_change = 1
bit5_c16 = bit5
End Select
Call Save_set
End Sub
Private Sub Combo_B6_Click()
bit6 = Combo_B6.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
bit6_c8 = bit6
Case 4:
bit_c16_change = 1
bit6_c16 = bit6
End Select
End Sub
Private Sub Combo_B7_Click()
bit7 = Combo_B7.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
bit7_c8 = bit7
Case 4:
bit_c16_change = 1
bit7_c16 = bit7
End Select
Call Save_set
End Sub
Private Sub Combo_B8_Click()
bit8 = Combo_B8.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
Case 4:
bit_c16_change = 1
bit8_c16 = bit8
End Select
Call Save_set
End Sub
Private Sub Combo_B9_Click()
bit9 = Combo_B9.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
Case 4:
bit_c16_change = 1
bit9_c16 = bit9
End Select
End Sub
Private Sub Combo_B10_Click()
bit10 = Combo_B10.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
Case 4:
bit_c16_change = 1
bit10_c16 = bit10
End Select
Call Save_set
End Sub
Private Sub Combo_B11_Click()
bit11 = Combo_B11.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
Case 4:
bit_c16_change = 1
bit11_c16 = bit11
End Select
Call Save_set
End Sub
Private Sub Combo_B12_Click()
bit12 = Combo_B12.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
Case 4:
bit_c16_change = 1
bit12_c16 = bit12
End Select
Call Save_set
End Sub
Private Sub Combo_B13_Click()
bit13 = Combo_B13.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
Case 4:
bit_c16_change = 1
bit13_c16 = bit13
End Select
Call Save_set
End Sub
Private Sub Combo_B14_Click()
bit14 = Combo_B14.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
Case 4:
bit_c16_change = 1
bit14_c16 = bit14
End Select
Call Save_set
End Sub
Private Sub Combo_B15_Click()
bit15 = Combo_B15.ListIndex
Select Case color_format
Case 3:
bit_c8_change = 1
Case 4:
bit_c16_change = 1
bit15_c16 = bit15
End Select
Call Save_set
End Sub
Private Sub Command_infile_Click()
file_sel = 0 '选择输入文件
File1.Pattern = "*.bmp"
End Sub
Private Sub Command1_Click()
Dim temp_data1 As Integer
Dim temp_str1 As String
Dim temp_str2 As String
Dim temp_data2 As Long
Dim color_bit As Byte
Dim data_offset As Long '数据偏移量。
Dim data_size As Long '数据大小。
Dim pic_width As Long '图片宽。
Dim pic_height As Long '图片高。
Dim cu2 As Long
Dim cu3 As Long
Dim temp_data3 As Byte
Dim temp_data4 As Byte
Dim red_data As Byte
Dim green_data As Byte
Dim blue_data As Byte
Dim width_cu As Long
Dim height_cu As Long
Dim byte_temp As Byte
If infilename <> "" And outfilename <> "" Then
Command1.Enabled = False
infile_no = FreeFile
Open infilename For Binary Access Read As infile_no
outfile_no = FreeFile
Open outfilename For Binary Access Write As outfile_no
Close outfile_no
Kill outfilename
Open outfilename For Binary Access Write As outfile_no
cu1 = 1
Call c16_mask_tab_set
If file_out_format <> 2 Then '输出格式非BIN
If file_out_format Then
' ASM:
temp_str1 = "Pic_" + Text_VariableName.Text + "_Size:"
Put outfile_no, cu1, temp_str1
cu1 = 30
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
Else
' C:
If StructSet = 0 Then '不生成结构:
temp_str1 = "unsigned int Pic_" + Text_VariableName.Text + "_Size[]={"
Put outfile_no, cu1, temp_str1
cu1 = 30
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
End If
End If
If file_out_format Then
' ASM
Put outfile_no, cu1, " DB "
cu1 = cu1 + 5
Else
' C
If StructSet = 0 Then '不生成结构:
Put outfile_no, cu1, " 0x"
cu1 = cu1 + 6
End If
End If
End If
Get infile_no, 19, temp_data1 '读宽度数据
pic_width = temp_data1
If PicNameF Then '将图片名称写入文件前面:
Put outfile_no, cu1, Txt_PicName.Text
cu1 = Seek(outfile_no)
If cu1 > 15 Then
cu1 = 15
End If
For cu1 = cu1 To 16
Put outfile_no, cu1, 0
Next
End If
If file_out_format = 2 Then
' bin:
byte_temp = temp_data1 And 255
Put outfile_no, cu1, byte_temp
cu1 = cu1 + 1
byte_temp = Int((temp_data1 / 256))
Put outfile_no, cu1, byte_temp
cu1 = cu1 + 1
Else
' ASM OR C:
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
If file_out_format Or StructSet = 0 Then '不生成结构:
Put outfile_no, cu1, temp_str1
cu1 = cu1 + 4
End If
If file_out_format Then
' ASM:
Put outfile_no, cu1, "H"
cu1 = cu1 + 1
End If
' 高度处理:
If file_out_format Then
' ASM
Put outfile_no, cu1, ","
cu1 = cu1 + 1
Else
' C
If StructSet = 0 Then '不生成结构:
Put outfile_no, cu1, ",0x"
cu1 = cu1 + 3
End If
End If
End If
Get infile_no, 23, temp_data1 '读高度数据
pic_height = temp_data1
If file_out_format = 2 Then
' bin
byte_temp = temp_data1 And 255
Put outfile_no, cu1, byte_temp
cu1 = cu1 + 1
byte_temp = Int(temp_data1 / 256)
Put outfile_no, cu1, byte_temp
cu1 = cu1 + 1
Else
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
If file_out_format Or StructSet = 0 Then '不生成结构:
Put outfile_no, cu1, temp_str1
cu1 = cu1 + 4
End If
If file_out_format Then
' ASM:
temp_str1 = "H ;宽度,高度"
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
temp_str1 = "Pic_" + Text_VariableName.Text + "_Color:"
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, " DB "
cu1 = cu1 + 5
Else
'c
If StructSet = 0 Then '不生成结构:
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
temp_str1 = "unsigned short Pic_" + Text_VariableName.Text + "_Color[]={"
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
End If
End If
End If
Get infile_no, 29, color_bit '每个象素的位数
If file_out_format = 2 Then
' Bin:
Put outfile_no, cu1, 0
cu1 = cu1 + 1
Select Case color_format
Case 1:
Put outfile_no, cu1, 1
cu1 = cu1 + 1
Case 3:
Put outfile_no, cu1, 8
cu1 = cu1 + 1
Case 4:
Put outfile_no, cu1, 16
cu1 = cu1 + 1
End Select
Else
Select Case color_format
Case 1:
If file_out_format Then
' ASM:
temp_str1 = "01H ;单色"
Else
' C:
temp_str1 = "01}; //单色"
End If
Case 3:
If file_out_format Then
' ASM:
temp_str1 = "08H ;8位色"
Else
' C:
temp_str1 = "08}; //8位色"
End If
Case 4:
If file_out_format Then
' ASM:
temp_str1 = "16H ;16位色"
Else
' C:
temp_str1 = "16}; //16位色"
End If
End Select
If file_out_format Or StructSet = 0 Then '不生成结构:
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
End If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -