簡體   English   中英

“BitmapImage”不包含“SetSource”的定義,也沒有可訪問的擴展方法“SetSource”

[英]'BitmapImage' does not contain a definition for 'SetSource' and no accessible extension method 'SetSource'

我試圖在我的轉換器中使用方法 SetSource 將 Byte Array Byte[]轉換為BitMapImage ,但不幸的是該方法看起來已經消失了。

我看了看文檔,該方法仍在使用中。 鏈接:[https://docs.microsoft.com/en-us/previous-versions/cc189859(v=vs.95)][1]

有任何想法嗎?

public static BitmapImage ConvertByteArrayToBitMapImage(byte[] imageByteArray)
    {
        BitmapImage img = new BitmapImage();
        using (MemoryStream memStream = new MemoryStream(imageByteArray))
        {
            img.SetSource(memStream);
        }
        return img;
    }

我想我發現了類似的東西:我必須發出BitMapImage啟動的開始和他的結束的信號。

        img.BeginInit();
        img.StreamSource = memStream;
        img.EndInit();

暫無
暫無

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

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