Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net ';图像转换器';can';t将位图转换为字节数组。出错_.net_Vb.net_Bitmap - Fatal编程技术网

.net ';图像转换器';can';t将位图转换为字节数组。出错

.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

错误是: “'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_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
关于数组没有任何内容。

不过,您认为这种“转换”应该如何发生?将图像对象“转换”为字节数组的常规方法是将其作为特定的图像文件类型保存到字节流中。不过,您认为这种“转换”应该如何进行?将图像对象“转换”为字节数组的常规方法只是将其作为特定的图像文件类型保存到字节流中。