Hi all!
I have a problem that has had me confused for a while. I need to be able to convert an array of bytes into a bitmap, and vice versa.
I found this bit of code that takes a bitmap and converts it to a byte array.
The only problem is that it appends header data to the beginning of the array, and I am only interested in the pixel data. My bitmaps/byte arrays are all greyscale images with 0 being black, and 255 being white and set width and heights.
I need to know how to convert a bitmap into a byte array WITHOUT the header at the beginning. Then, I also need to know how to create the header and append it to the array when I need to convert from a byte array back into a bitmap.
Can anyone please help me? Thanks in advance!
-Funger
I have a problem that has had me confused for a while. I need to be able to convert an array of bytes into a bitmap, and vice versa.
I found this bit of code that takes a bitmap and converts it to a byte array.
VB.NET:
' Load bitmap From File
Dim file_name As String = "C:\temp.bmp"
Dim bm As New Bitmap(file_name)
'Convert loaded bitmap into a byte array
Dim ms As MemoryStream = New MemoryStream
Dim ba As Byte()
bm.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)
ba = ms.ToArray()
ms.close()
I need to know how to convert a bitmap into a byte array WITHOUT the header at the beginning. Then, I also need to know how to create the header and append it to the array when I need to convert from a byte array back into a bitmap.
Can anyone please help me? Thanks in advance!
-Funger