📄 bmp2code.frm
字号:
End If
If file_out_format = 1 Then
' ASM:
temp_str1 = "Pic_" + Text_VariableName.Text + "_Data:"
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
End If
If file_out_format = 0 Then
' C:
If array_format = 1 Then '2维数组:
If color_format = 4 Then
temp_str1 = "[0x" + Hex(pic_height) + "][0x" + Hex(pic_width) + "]"
temp_str1 = "unsigned short Pic_" + Text_VariableName.Text + "_Data" + temp_str1
temp_str1 = temp_str1 + "={"
' Put outfile_no, cu1, temp_str1
' cu1 = cu1 + Len(temp_str1)
Else
temp_str1 = "[0x" + Hex(pic_height) + "][0x" + Hex(pic_width) + "]"
temp_str1 = "unsigned char Pic_" + Text_VariableName.Text + "_Data" + temp_str1
temp_str1 = temp_str1 + "={"
End If
Else '1维数组:
If color_format = 4 Then
temp_str1 = "unsigned short Pic_" + Text_VariableName.Text + "_Data[]={" '16位色
Else
temp_str1 = "unsigned char Pic_" + Text_VariableName.Text + "_Data[]={" '16位色
End If
End If
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
Get infile_no, 11, data_offset '读数据偏移量
Get infile_no, 35, data_size '读数据大小
'处理位图数据:
Select Case color_bit
'原始文件为8位色:
Case 8:
Dim color8_tab_r(0 To 255) As Byte '8位彩色红色色表
Dim color8_tab_g(0 To 255) As Byte '8位彩色绿色色表
Dim color8_tab_b(0 To 255) As Byte '8位彩色蓝色色表
cu3 = 55
For cu2 = 0 To 255
Get infile_no, cu3, color8_tab_b(cu2)
cu3 = cu3 + 4
Next '读入兰色色表
cu3 = 56
For cu2 = 0 To 255
Get infile_no, cu3, color8_tab_g(cu2)
cu3 = cu3 + 4
Next '读入绿色色表
cu3 = 57
For cu2 = 0 To 255
Get infile_no, cu3, color8_tab_r(cu2)
cu3 = cu3 + 4
Next '读入红色色表
temp_data2 = data_offset + data_size - pic_width + 1
height_cu = 1
For cu2 = 1 To pic_height
width_cu = 1
If file_out_format = 0 Then 'c:
If array_format = 1 Then '2维数组:
Put outfile_no, cu1, " {"
cu1 = cu1 + 5
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
End If
End If
' Get infile_no, temp_data2, temp_data3 '读图形数据
For cu3 = 1 To pic_width
If file_out_format <> 2 Then 'no bin:
If file_out_format Then
' ASM
Put outfile_no, cu1, " DB "
cu1 = cu1 + 5
Else
' C
Put outfile_no, cu1, " "
cu1 = cu1 + 4
If array_format = 1 Then '2维数组:
Put outfile_no, cu1, " "
cu1 = cu1 + 4
End If
If cu3 = 1 Then
Put outfile_no, cu1, " "
cu1 = cu1 + 1
Else
Put outfile_no, cu1, ","
cu1 = cu1 + 1
End If
Put outfile_no, cu1, "0X"
cu1 = cu1 + 2
End If
If file_out_format Then
' ASM:
Put outfile_no, cu1, "0"
cu1 = cu1 + 1
End If
End If
Get infile_no, temp_data2, temp_data3 '读图形数据
blue_data = color8_tab_b(temp_data3)
green_data = color8_tab_g(temp_data3)
red_data = color8_tab_r(temp_data3)
Select Case color_format
Case 3: '输出为8色:
Call out_8bit_color(red_data, green_data, blue_data)
End Select
If file_out_format <> 2 Then 'no bin
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 + 13
Else
' C:
Put outfile_no, cu1, " //"
cu1 = cu1 + 14
End If
temp_str1 = Str(height_cu)
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
Put outfile_no, cu1, ","
cu1 = cu1 + 1
temp_str1 = Str(width_cu)
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
temp_data2 = temp_data2 + 1
Label7.Caption = Str(width_cu)
Label8.Caption = Str(height_cu)
OpenForms = DoEvents
width_cu = width_cu + 1
Next
temp_data2 = temp_data2 - (pic_width * 2)
height_cu = height_cu + 1
If file_out_format = 0 Then 'c
If array_format = 1 Then '2维数组:
Put outfile_no, cu1, " },"
cu1 = cu1 + 6
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
End If
End If
Next
If file_out_format = 0 Then 'c
' C:
Put outfile_no, cu1, "};"
cu1 = cu1 + 2
End If
'原始文件为16位色:
Case 16:
Dim BiCompression As Long
Dim Bit16_PIC_Data As Integer
Get infile_no, 31, BiCompression '读压缩方式
If BiCompression = 0 Then
' 非压缩:
temp_data2 = data_offset + data_size - pic_width * 2 + 1
height_cu = 1
For cu2 = 1 To pic_height
width_cu = 1
If file_out_format = 0 Then 'c
If array_format = 1 Then '2维数组:
Put outfile_no, cu1, " {"
cu1 = cu1 + 5
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
End If
End If
' Get infile_no, temp_data2, Bit16_PIC_Data '读图形数据
For cu3 = 1 To pic_width
If file_out_format <> 2 Then 'no bin
If file_out_format Then
' ASM
Put outfile_no, cu1, " DB "
cu1 = cu1 + 5
Else
' C
Put outfile_no, cu1, " "
cu1 = cu1 + 4
If array_format = 1 Then '2维数组:
Put outfile_no, cu1, " "
cu1 = cu1 + 4
End If
If cu3 = 1 Then
Put outfile_no, cu1, " "
cu1 = cu1 + 1
Else
Put outfile_no, cu1, ","
cu1 = cu1 + 1
End If
Put outfile_no, cu1, "0X"
cu1 = cu1 + 2
End If
If file_out_format Then
' ASM:
Put outfile_no, cu1, "0"
cu1 = cu1 + 1
End If
End If
Get infile_no, temp_data2, Bit16_PIC_Data '读图形数据
blue_data = Bit16_PIC_Data And 31
green_data = (Bit16_PIC_Data / 32) And 31
red_data = (Bit16_PIC_Data / 1024) And 31
Select Case color_format
Case 3: '输出为8色:
Call out_8bit_color(red_data, green_data, blue_data)
End Select
If file_out_format <> 2 Then 'no bin
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 + 13
Else
' C:
Put outfile_no, cu1, " //"
cu1 = cu1 + 14
End If
temp_str1 = Str(height_cu)
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
Put outfile_no, cu1, ","
cu1 = cu1 + 1
temp_str1 = Str(width_cu)
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
temp_data2 = temp_data2 + 1
Label7.Caption = Str(width_cu)
Label8.Caption = Str(height_cu)
OpenForms = DoEvents
width_cu = width_cu + 1
Next
temp_data2 = temp_data2 - (pic_width * 2)
height_cu = height_cu + 1
If file_out_format = 0 Then 'c
If array_format = 1 Then '2维数组:
Put outfile_no, cu1, " },"
cu1 = cu1 + 6
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
End If
End If
Next
If file_out_format = 0 Then 'c
' C:
Put outfile_no, cu1, "};"
cu1 = cu1 + 2
End If
End If
'原始文件为24位色:
Case 24:
Dim line_len As Long
Dim line_mod As Byte
line_mod = (pic_width * 3) Mod 4
If (line_mod) Then
line_len = 4 - line_mod + pic_width * 3
line_mod = 4 - line_mod
Else
line_len = pic_width * 3
End If
temp_data2 = data_offset + data_size - line_len + 1
height_cu = 1
For cu2 = 1 To pic_height
width_cu = 1
If file_out_format = 0 Then 'c
If array_format = 1 Then '2维数组:
Put outfile_no, cu1, " {"
cu1 = cu1 + 5
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
End If
End If
For cu3 = 1 To pic_width
If file_out_format <> 2 Then 'no bin
If file_out_format Then
' ASM
Put outfile_no, cu1, " DB "
cu1 = cu1 + 5
Else
' C
Put outfile_no, cu1, " "
cu1 = cu1 + 4
If array_format = 1 Then '2维数组:
Put outfile_no, cu1, " "
cu1 = cu1 + 4
End If
If cu3 = 1 Then
Put outfile_no, cu1, " "
cu1 = cu1 + 1
Else
Put outfile_no, cu1, ","
cu1 = cu1 + 1
End If
Put outfile_no, cu1, "0X"
cu1 = cu1 + 2
End If
If file_out_format Then
' ASM:
Put outfile_no, cu1, "0"
cu1 = cu1 + 1
End If
End If
Get infile_no, temp_data2, blue_data '读图形数据
Get infile_no, temp_data2 + 1, green_data '读图形数据
Get infile_no, temp_data2 + 2, red_data '读图形数据
' blue_data = Bit24_PIC_Data And 255
' green_data = (Bit24_PIC_Data / 256) And 255
' red_data = (Bit24_PIC_Data / 65536) And 255
Select Case color_format
' Case 1: '输出为单色:
Case 3: '输出为8色:
Call out_8bit_color(red_data, green_data, blue_data)
Case 4: '输出为16色:
Call out_16bit_color(red_data, green_data, blue_data)
End Select
If file_out_format <> 2 Then 'no bin
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 + 13
Else
' C:
Put outfile_no, cu1, " //"
cu1 = cu1 + 14
End If
temp_str1 = Str(height_cu)
Put outfile_no, cu1, temp_str1
cu1 = cu1 + Len(temp_str1)
Put outfile_no, cu1, ","
cu1 = cu1 + 1
temp_str1 = Str(width_cu)
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
temp_data2 = temp_data2 + 3
Label7.Caption = Str(width_cu)
Label8.Caption = Str(height_cu)
OpenForms = DoEvents
width_cu = width_cu + 1
Next
temp_data2 = temp_data2 - (line_len * 2) + line_mod
height_cu = height_cu + 1
If file_out_format = 0 Then 'c
If array_format = 1 Then '2维数组:
Put outfile_no, cu1, " },"
cu1 = cu1 + 6
Put outfile_no, cu1, 13
cu1 = cu1 + 1
Put outfile_no, cu1, 10
cu1 = cu1 + 1
End If
End If
Next
If file_out_format = 0 Then 'c
' C:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -