不知道爲什麼,以及兩天嘗試不同的東西時,我無處可去。繼續在WriteableBitmap行獲取NRP。你可以看到我已經嘗試關閉並沖洗(並且一起)流。
任何想法,將不勝感激。嘗試在WP7中保存圖像時,WriteableBitmap上的空引用指針錯誤
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
XmlSerializer serializer = new XmlSerializer(typeof(MyClass));
XDocument document = XDocument.Load(myIsolatedStorage.OpenFile("Selections.xml", FileMode.Open));
MyClass enclaves = (MyClass)serializer.Deserialize(document.CreateReader());
enclavesList.ItemsSource = enclaves.Collection1;
foreach (XElement xencl in document.Descendants("rest"))
{
WebClient downloader = new WebClient();
String theelement = xencl.Element("couplink").Value;
String nameElement = xencl.Element("coup").Value;
String uriring = theelement.ToString();
Uri uri = new Uri(uriring, UriKind.RelativeOrAbsolute);
downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(enclavesDownloaded);
downloader.DownloadStringAsync(uri);
Random random = new Random();
int randomNumber = random.Next(0, 100);
using (IsolatedStorageFile newIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
String tempJPEG = randomNumber.ToString();
IsolatedStorageFileStream fileStream = newIsolatedStorage.CreateFile(tempJPEG);
//fileStream.Close();
//fileStream.Flush();
BitmapImage image = new BitmapImage(new Uri("" + uri));
image.CreateOptions = BitmapCreateOptions.None;
WriteableBitmap wb = new WriteableBitmap(image);
System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
}
}
}
我GOOGLE了,直到我失明,不知道現在該做什麼。 在此先感謝您的所有人。
謝謝philorube。花了一些時間重新組織我的代碼,但這是一個調用,並在最終的文件保存期間添加了一個正斜槓。 – NoJoeGo
很高興能幫到你!我曾經有過類似的問題。 :) – philorube
那麼工作,但我的新代碼是不完全正確的,在循環中執行第二個解析方法來獲取字符串,它不會迭代......必須弄清楚如何執行自定義事件來傳遞字符串這樣的處理程序..在MS的例子真的不好。你有什麼技巧提示? – NoJoeGo