RAW Data from Embedded Image Resource

I am trying to get an image from an embedded resource and display it in RAW DATA format (i.e. -> text data).

Basically, I run into the wall with everything I try. Can anyone show me how to do this correctly?

0


source to share


1 answer


You can use the following msdn ref

System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(fileName)

      



This will give you a stream, which you can then use code cite to convert to a byte array, which is pretty much raw data.

private Function GetStreamAsByteArray(ByVal stream As System.IO.Stream) As Byte()
Dim streamLength As Integer = Convert.ToInt32(stream.Length)
Dim fileData As Byte() = New Byte(streamLength) {}
' Read the file into a byte array
stream.Read(fileData, 0, streamLength)
stream.Close()
Return fileData
End Function

      

0


source







All Articles