.net ';图像转换器';can';t将位图转换为字节数组。出错
错误是: “'ImageConverter'无法将'System.Drawing.Bitmap'转换为'System.Byte'。”.net ';图像转换器';can';t将位图转换为字节数组。出错,.net,vb.net,bitmap,.net,Vb.net,Bitmap,错误是: “'ImageConverter'无法将'System.Drawing.Bitmap'转换为'System.Byte'。” dim YZ_2D_blobmap(150*100*3)作为字节 暗淡的热图\u图片框\u位图作为位图 ' . . .热图\u图片盒\u加载150 x 100位图的位图 YZ_2D_blobmap=Bitmap_to_Bytes(heatmap_PictureBox_Bitmap)您正在告诉图像转换器将位图转换为字节数组。这: return bytes_Image
dim YZ_2D_blobmap(150*100*3)作为字节
暗淡的热图\u图片框\u位图作为位图
' . . .热图\u图片盒\u加载150 x 100位图的位图
YZ_2D_blobmap=Bitmap_to_Bytes(heatmap_PictureBox_Bitmap)您正在告诉图像转换器
将位图
转换为字节
数组。这:
return bytes_ImageConverter.ConvertTo( img, GetType( byte ))
应该是这样的:
Return bytes_ImageConverter.ConvertTo(img, GetType(Byte()))
错误消息甚至会告诉您:
“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
没有关于数组的内容。您正在告诉图像转换器
将位图
转换为字节
而不是字节
数组。这:
return bytes_ImageConverter.ConvertTo( img, GetType( byte ))
应该是这样的:
Return bytes_ImageConverter.ConvertTo(img, GetType(Byte()))
错误消息甚至会告诉您:
“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
关于数组没有任何内容。不过,您认为这种“转换”应该如何发生?将图像对象“转换”为字节数组的常规方法是将其作为特定的图像文件类型保存到字节流中。不过,您认为这种“转换”应该如何进行?将图像对象“转换”为字节数组的常规方法只是将其作为特定的图像文件类型保存到字节流中。