我有一个0到255之间的整数数组,代表灰度数组。 我想将该数组显示为图像。 这个my_array看起来像这样: ... 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.MemoryStream(bytes)
imgNew = Image.FromStream(memImage)
Dim pav As Bitmap = imgNew
PictureBox1.Image = pav
但它不起作用。
好的,我设法根据我的灰度数组(my_array)绘制图像:
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)
问题是我必须从C盘打开空白图像'pav',然后将像素设置为它。
我想跳过手动创建该图像的步骤。我该怎么办?