WPF: How to save a GIF file in a string or file from an URL? -
i seek retrieve content of .gif located on url string -and save disk-, ran wpf appliactions using webbrowser. after trying dozens of solutions not farther yesterday. thought code below job, saved string cgif contains...the url itself. http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.gifbitmapdecoder.aspx thought needed gifbitmapencoder instead, sample suggests creates empty gif instead of downloaded one.
(ps: want retrieve gif bytes straight wpf webbrowser haven't found working there either)
private void gifsave() { var uri = new uri(@"http://www.archivearts.com/giraffe2.gif"); var img = new gifbitmapdecoder(uri, bitmapcreateoptions.preservepixelformat, bitmapcacheoption.onload); string cgif = img.tostring(); }
modified sample on gifbitmapdecoder msdn page:
// open stream , decode gif image var uri = new uri(@"http://www.archivearts.com/giraffe2.gif"); gifbitmapdecoder decoder = new gifbitmapdecoder(uri, bitmapcreateoptions.preservepixelformat, bitmapcacheoption.onload); bitmapsource bitmapsource = decoder.frames[0];
then utilize copypixels()
method of bitmapsource re-create pixel info array. convert array string?
i haven't done this, took @ msdn hints.
wpf string save uri gif
No comments:
Post a Comment