【发布时间】:2019-03-03 01:11:21
【问题描述】:
错误是: “'ImageConverter' 无法将 'System.Drawing.Bitmap' 转换为 'System.Byte'。”
dim YZ_2D_blobmap( 150 * 100 * 3 ) as byte
dim heatmap_PictureBox_Bitmap as Bitmap
' . . .heatmap_PictureBox_Bitmap loaded with 150 x 100 bitmap
YZ_2D_blobmap = Bitmap_to_Bytes( heatmap_PictureBox_Bitmap ) <<<<<<< error
bytes_to_file( YZ_2D_blobmap, YZ_2D_BLOBMAP_BLB_PATHNAME )
Function Bitmap_to_Bytes( img as Bitmap ) as byte()
dim bytes_ImageConverter as ImageConverter = New ImageConverter()
return bytes_ImageConverter.ConvertTo( img, GetType( byte ))
end function
Sub bytes_to_file( byte_buffer, pathname )
system.io.file.writeAllBytes( pathname, byte_buffer )
End Sub
【问题讨论】:
-
你认为这种“转换”应该如何发生呢?将图像对象“转换”为字节数组的常规方法是将其保存,作为特定的图像文件类型,转换为字节流。