Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.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
Vb.net 如何将位图保存到PNG文件而不引起错误_Vb.net_Image Processing_Bitmap_Gdi+ - Fatal编程技术网

Vb.net 如何将位图保存到PNG文件而不引起错误

Vb.net 如何将位图保存到PNG文件而不引起错误,vb.net,image-processing,bitmap,gdi+,Vb.net,Image Processing,Bitmap,Gdi+,我想将位图编码为PNG,然后将其保存到文件中。 但是我的heatmap\u PictureBox\u Bitmap.Save(文件路径名) …导致错误的原因: GDI+中发生一般性错误 . . . heatmap_PictureBox_Bitmap.Save( XY_HEATMAP_PNG_PATHNAME ) <<<< CAUSES THE ERROR PictureBox_heat_map.Image = heatmap_PictureBox_Bitmap hea

我想将位图编码为PNG,然后将其保存到文件中。 但是我的
heatmap\u PictureBox\u Bitmap.Save(文件路径名)
…导致错误的原因:

GDI+中发生一般性错误

. . .
heatmap_PictureBox_Bitmap.Save( XY_HEATMAP_PNG_PATHNAME  ) <<<< CAUSES THE ERROR
PictureBox_heat_map.Image = heatmap_PictureBox_Bitmap
heatmap\u PictureBox\u位图
包含彩色图像

这将在Windows 10上的my.NET应用程序上显示图片:

public const  MOBILE_UPLOADER_PATH = "C:\demo\DEMO4\MOBILE UPLOADER\"
public const XY_HEATMAP_PNG_FILENAME = "XY_HEATMAP.PNG"
public const  XY_HEATMAP_PNG_PATHNAME = MOBILE_UPLOADER_PATH     & XY_HEATMAP_PNG_FILENAME  

dim heatmap_PictureBox_Bitmap   as Bitmap
. . .

' Build the image bitmap:
for x = 0 to x_range
  for y = 0 to y_range
    ' red, green, blue are integers 0 to 255
    pixel_color = Color.FromArgb( red, green, blue )
    heatmap_PictureBox_Bitmap.SetPixel( x, y, pixel_color   )  
  next
next
. . .
PictureBox_heat_map.Image = heatmap_PictureBox_Bitmap  ' displays ok
但是添加这一行(如下)会导致错误“GDI+中发生一般错误”

…同样的问题


XY\u热图\u PNG\u路径名中的目录存在。

问题在于目标文件夹 public const MOBILE\u UPLOADER\u PATH=“C:\demo\DEMO4\MOBILE UPLOADER” …不存在

我以为它是存在的


我修改了代码以创建不存在的文件夹。

如何加载它?加载图像时需要遵循一些规则,比如不处理生成图像的流。另外,请发布一些实际代码,而不仅仅是伪代码。我们无法从您的代码的近似值中看出哪里出了问题。我只是添加了有关如何创建位图的代码。对不起,使用给定的代码,我一点也没有收到任何错误。你需要提供更多的细节。VB编辑器修复了大小写和间距。这不可能是真正的代码。如何创建或加载位图?我在VS编辑器中关闭了大小写和间距。这是真正的密码。我会提供更多细节。
heatmap_PictureBox_Bitmap.Save(XY_HEATMAP_PNG_PATHNAME, System.Drawing.Imaging.ImageFormat.Png)