2009-05-04 35 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