Programming with .NET - Generalhttp://forums.silverlight.net//17.aspx/1?Programming+with+NET+GeneralGeneral discussions around authoring Silverlight .NET applications.Mon, 01 Jan 0001 00:00:00 -05001711354http://forums.silverlight.net//p/3883/11354.aspx/1?Displaying+Gifs+in+silverlightDisplaying Gifs in silverlight <p>Good day ! </p> <p>&nbsp;I've searched the web a bit and havn't found any specific solutions to this problem (other than renaming them to jpg :P). Is there a way to either display a gif image, of export it to another format on the fly? My application will eventually use images from a server that I don't have write permissions on that uses gifs. I thought maybe using a downloader, downloading the image first then changing the format before displaying, but silverlight is missing namespaces that could be usefull for this. </p> <p>Anybody out there have an idea ?? I'm sure I'm not the 1st to have come accross a similar problem lol.</p> <p>Thank you very much, <br> Eric.</p> <p>&nbsp;</p> 2007-08-21T21:10:11-04:0011374http://forums.silverlight.net//p/3883/11374.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>hello.</p> <p>well, i believe that's one of the scenarios that isnt't supported in the current version. as you've seen, currently you don't have support for working with images in the mini-clr</p> 2007-08-21T23:45:40-04:0011382http://forums.silverlight.net//p/3883/11382.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>Hi,&nbsp;</p> <p>May be you can&nbsp;setup a web page to convert image&nbsp;format. The page&nbsp;gets&nbsp;image&nbsp;url&nbsp;from&nbsp;request parameter, fetchs the real&nbsp;image from remoting server, converts the image's format to&nbsp;JPG or PNG&nbsp;and outputs&nbsp;the resulting data. </p> <p>&nbsp;</p> 2007-08-22T03:07:30-04:0011434http://forums.silverlight.net//p/3883/11434.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>Actually that's not a bad idea! My silverlight app is actually already calling out to a webservice to get the link of the address. I'll keep you posted.</p> <p>&nbsp;</p> <p>Eric</p> 2007-08-22T13:32:37-04:0011449http://forums.silverlight.net//p/3883/11449.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>hello.,</p> <p>that is, in fact, a valid scenario. if you follow it, you'll be better served by a custom handler. however, it still looks like a lot of work to me...</p> 2007-08-22T15:39:38-04:0011452http://forums.silverlight.net//p/3883/11452.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>I looked into it and .. It does seem like alot of work. Especially because the way things are set up, the only thing I can return for the picture is actually a string. So I need to transform the picture in a stream, transform the stream in to a string, send the&nbsp;string out threw the webservice, then transform it back to a stream, then try to figure out, within silverlight, how to transform from stream to image, all this without saving to a local file (for performance of course). Complicated and long task, especially since this won't be used in production anytime soon. Ohh well, I guess I'll keep my fingers crossed for MS to eventually support gifs ! </p> <p>&nbsp;Thanks alot people !</p> <p>Eric.</p> 2007-08-22T15:44:22-04:0011457http://forums.silverlight.net//p/3883/11457.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>hello.</p> <p>hum, not sure about this one. i'm under the assumption that your handler should return the stream wiht the image bytes and you only need to pass an uri that points to your handler to the source of the image element....</p> <p>&nbsp;</p> <p>&nbsp;</p> 2007-08-22T15:54:55-04:0011461http://forums.silverlight.net//p/3883/11461.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p></p> <blockquote><span class="icon-blockquote"></span> <h4>luisabreu</h4> <p>hello.</p> <p>hum, not sure about this one. i'm under the assumption that your handler should return the stream wiht the image bytes and you only need to pass an uri that points to your handler to the source of the image element....</p> <p></p> </blockquote> <p></p> <p>Ok so ... I create a uri, and instead of a link, I put in the stream directly ?? How would it work ?? Can you elaborate please ?<br> <br> Eric.</p> 2007-08-22T16:05:52-04:0011462http://forums.silverlight.net//p/3883/11462.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>hello again.</p> <p>nop. i only see it working by doing something like this:</p> <p>Uri uri = new Uri( &quot;localhandler.asxh?url=http://blabla.com/image.gif&quot;, urikind.relative);</p> <p>image.source = uri;</p> <p>then your handler would have to retrieve the gif, change it and write the stream back to the client (don't forget to set the correct mime type from the handler)...</p> 2007-08-22T16:10:20-04:0011483http://forums.silverlight.net//p/3883/11483.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p></p> <blockquote><span class="icon-blockquote"></span> <h4>luisabreu</h4> <p>hello again.</p> <p>nop. i only see it working by doing something like this:</p> <p>Uri uri = new Uri( &quot;localhandler.asxh?url=http://blabla.com/image.gif&quot;, urikind.relative);</p> <p>image.source = uri;</p> <p>then your handler would have to retrieve the gif, change it and write the stream back to the client (don't forget to set the correct mime type from the handler)...</p> <p></p> </blockquote> <p></p> <p>&nbsp;Hello ! <br> Good news ! <br> it actually worked perfectly lol ... I don't know how &quot;resource-heavy&quot; it is, but I doubt that to be a major issue. Here's what the handler looks like (FYI):</p> <font size="2"> <blockquote></font><font color="#0000ff" size="2"><font size="2"><font size="2"> <p>context.Response.ContentType = </font><font color="#a31515" size="2">&quot;image/jpeg&quot;</font><font size="2">;</font><br> context.Response.BinaryWrite(GetBufferFromImage(imageLnk));<font size="2"></p> </font><font size="2"> <p></font></font></font><font color="#0000ff" size="2">private</font><font size="2"> </font><font color="#0000ff" size="2">byte</font><font size="2">[] GetBufferFromImage(</font><font color="#0000ff" size="2">string</font><font size="2"> imageLnk)<br> {<br> </font><font color="#2b91af" size="2">HttpWebRequest</font><font size="2"> request = (</font><font color="#2b91af" size="2">HttpWebRequest</font><font size="2">)</font><font color="#2b91af" size="2">HttpWebRequest</font><font size="2">.Create(imageLnk);<br> </font><font color="#2b91af" size="2">HttpWebResponse</font><font size="2"> response = (</font><font color="#2b91af" size="2">HttpWebResponse</font><font size="2">)request.GetResponse();<br> </font><font color="#2b91af" size="2">Image</font><font size="2"> myImage = </font> <font color="#2b91af" size="2">Image</font><font size="2">.FromStream(response.GetResponseStream());<br> </font><font color="#2b91af" size="2">MemoryStream</font><font size="2"> ImageStream = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">MemoryStream</font><font size="2">();<br> myImage.Save(ImageStream, </font><font color="#2b91af" size="2">ImageFormat</font><font size="2">.Jpeg);<br> ImageStream.Position = 0;<br> </font><font color="#0000ff" size="2">byte</font><font size="2">[] Buffer = </font> <font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#0000ff" size="2">byte</font><font size="2">[(</font><font color="#0000ff" size="2">int</font><font size="2">)ImageStream.Length];<br> ImageStream.Read(Buffer, 0, (</font><font color="#0000ff" size="2">int</font><font size="2">)ImageStream.Length);<br> </font><font color="#0000ff" size="2">return</font><font size="2"> Buffer;<br> }</font></p> </blockquote> <p><font size="2">This is all in a ashx file so usage is pretty simple : <a href="http://(whatever)/myHandler.ashx?link=http://www.GifsIntoSL.net/myGifImage.gif"> http://(whatever)/myHandler.ashx?link=http://www.GifsIntoSL.net/myGifImage.gif</a><br> </font></p> <p><font size="2">Hope this helps !<br> Eric.</p> </font> 2007-08-22T17:30:09-04:00232550http://forums.silverlight.net//p/3883/232550.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>Hey!<br> </p> <p>can anyone tell me how to work with that outside silverlight? My situation is that inside my wcf I have an url to a gif and need to convert that. Maybe I can do something els instead of giving the string to my silverlight application and the go back to the server in order to convert the image? <br> </p> 2009-06-12T11:28:50-04:00232781http://forums.silverlight.net//p/3883/232781.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>Hi,</p> <p>If you are&nbsp;interested in displaying GIF images with Silverlight, you should consider using the&nbsp;.NET Image Tools library for Silverlight. This library is free to use and&nbsp;available on Codeplex. It implements different image file&nbsp;formats, including the ability to load GIF files and even animated GIF files.</p> <p><a href="http://www.codeplex.com/imagetools"><font color="#697dff">http://www.codeplex.com/imagetools</font></a></p> 2009-06-12T21:29:45-04:00232806http://forums.silverlight.net//p/3883/232806.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>There is no download available for that library</p> 2009-06-12T22:44:32-04:00232862http://forums.silverlight.net//p/3883/232862.aspx/1?Re+Displaying+Gifs+in+silverlightRe: Displaying Gifs in silverlight <p>There is no downloadable package of this library but you can download its source code and build it for your own purposes.</p> <p><a href="http://imagetools.codeplex.com/SourceControl/ListDownloadableCommits.aspx#DownloadLatest">http://imagetools.codeplex.com/SourceControl/ListDownloadableCommits.aspx#DownloadLatest</a></p> 2009-06-13T07:04:38-04:00