2016-01-06 66 views
0

這是我用來創建Image的代碼,我將其插入FlowDocumentWPF FlowDocument顯示*一些*圖像但不是其他人

private static Image GetImage(string url) 
{ 
    if (url == null) throw new ArgumentNullException("url"); 

    if (!(url.StartsWith("http://") || url.StartsWith("https://") || url.StartsWith("ftp://"))) 
      return null; 

    var uri = new Uri(url, UriKind.Absolute); 
    var bmpImg = new BitmapImage(uri) 
    { 
     CacheOption = BitmapCacheOption.OnDemand, 
    }; 
    if (bmpImg.CanFreeze) bmpImg.Freeze(); 

    var img = new Image 
    { 
     Source = bmpImg, 
     Stretch = Stretch.Uniform, 
     Height = 120, 
     Width = 120, 
    }; 

    return img; 
} 

當我創建一個文檔,並從我的服務器

Designer.CaretPosition.Paragraph.Inlines.Add(image); 

一切插入圖像正常工作 - 圖像顯示爲預期。此外,the main Google Logo image工作正常,但the HackaDay Logo和其他只顯示一個空白圖像。

這可能是什麼原因?

+1

我覺得有些網站有[hotlink prevent](http://www.htaccesstools.com/hotlink-protection/)。這可能是一個原因。 – ganchito55

+0

@ ganchito55看起來就是這樣。作爲回答發佈,我會接受。 –

+0

感謝您的回覆:) – ganchito55

回答

0

我覺得有些網站有hotlink protection。例如,在我的網站中,我可以鏈接每個頁面中的一張照片,該照片位於我的域中,並且效果很好,但是如果您嘗試鏈接其他域中的照片,則無法加載照片。

相關問題