2009-05-04 36 views
0

我试图从嵌入式资源中检索图像,并以RAW数据格式显示它(即 - >垃圾文本数据)。来自嵌入式资源图像的RAW数据

基本上,我遇到了所有我尝试的东西。 有人可以告诉我如何正确地做到这一点?

回答

0

您可以使用以下msdn ref

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

这会给你一个流,你就可以使用code cite转换为一个字节数组,这是相当多的原始数据。

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