簡體   English   中英

如何在wp7中將位圖圖像轉換為字節數組?

[英]How to convert Bitmap image to byte array in wp7?

using (MemoryStream ms = new MemoryStream())
{
    image.CreateOptions = BitmapCreateOptions.None;
    image.UriSource = new Uri("/Images/chef.png", UriKind.Relative);              

    WriteableBitmap LoadedPhoto = new WriteableBitmap(image);
    LoadedPhoto.SaveJpeg(ms, LoadedPhoto.PixelWidth, LoadedPhoto.PixelHeight,0,95);
    ms.Seek(0, 0);
    byte[] data = new byte[ms.Length];
    ms.Read(data, 0, data.Length);
    ms.Close();
 }

我在圖像處收到NullReferenceException,但我的路徑也是正確的,圖像也存在。

WriteableBitmap LoadedPhoto = new WriteableBitmap(image);

有什么事嗎

請參考解決方案。 該圖顯示了將位圖圖像轉換為字節數組的解決方案。

我希望你能理解.. bitmapimage轉換為字節數組

請參閱此鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM