Vb.net 从阵列重新创建图像
我有一个从0到255的整数数组,表示灰度数组。 我想将该数组显示为图像。 此my_数组如下所示: ... 26 33 56 90 123 157 181 188 197 198 我试着:Vb.net 从阵列重新创建图像,vb.net,image,image-processing,grayscale,Vb.net,Image,Image Processing,Grayscale,我有一个从0到255的整数数组,表示灰度数组。 我想将该数组显示为图像。 此my_数组如下所示: ... 26 33 56 90 123 157 181 188 197 198 我试着: Dim imgNew As Image Dim bytes() As Byte bytes = System.Text.Encoding.UTF8.GetBytes(my_array.ToString) Dim memImage As New System.IO.Memory
Dim imgNew As Image
Dim bytes() As Byte
bytes = System.Text.Encoding.UTF8.GetBytes(my_array.ToString)
Dim memImage As New System.IO.MemoryStream(bytes)
imgNew = Image.FromStream(memImage)
Dim pav As Bitmap = imgNew
PictureBox1.Image = pav
但它不起作用
好的,我根据我的灰度数组(my_数组)绘制了一幅图像:
问题是我必须从C盘打开空白图像“pav”,然后在其中设置像素
我想跳过手动创建该图像的步骤。如何操作?为了使
imgNew=Image.FromStream(memImage)
执行任何操作,流中的字节必须来自图像。您无法从随机字节中获取有效位图。您正在使用吗?我没有处理。。。那么,有没有一种方法可以从灰度阵列中重建图像呢?
Dim pav As New Bitmap("opens_white_image_of_resolution_height_x_width")
Dim ix
Dim iy
For iy = 0 To pav.height-1
For ix = 0 To pav.Width - 1
pav.SetPixel(ix, iy, Color.FromArgb(250, my_array(pixl), my_array(pixl), my_array(pixl)))
pixl += 1
Next
Next
g.DrawImage(pav, 0, 0, pav.Width, pav.Height)
pav.Save("savefoldername", ImageFormat.Jpeg)