Could not load gif Image

Jul 14, 2010 at 12:34 PM

Hello,

I tried the ImageTools to get some gif or bmp images displayed inside my silverlight application, but only with medium success. I only have some lines inside my project and it work if the picture which should be loaded is inside the clientbin folder, but not when it is placed somewhere in the internet.

        private static AnimatedImage GetSmiley(string name)
        {
            ImageTools.Image image = new ImageTools.Image();
            //image.IsLoadingSynchronously = true;
            image.UriSource = new Uri(name, UriKind.Relative);
            //image.UriSource = new Uri("http://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Sunflower_as_GIF.gif/200px-Sunflower_as_GIF.gif", UriKind.Absolute);
        
            AnimatedImage smiley = new AnimatedImage();
            smiley.Stretch = System.Windows.Media.Stretch.None;
            smiley.Source = image;
            smiley.VerticalAlignment = VerticalAlignment.Bottom;
            smiley.Margin = new Thickness(0, 2, 2, 2);

            return smiley;
        }
        
        public MainPage()
        {
            ImageTools.IO.Decoders.AddDecoder<GifDecoder>();
            ImageTools.IO.Decoders.AddDecoder<PngDecoder>();
            ImageTools.IO.Decoders.AddDecoder<BmpDecoder>();
            ImageTools.IO.Decoders.AddDecoder<JpegDecoder>();

            InitializeComponent();

            LayoutRoot.Children.Add(GetSmiley("test.gif"));
        }

Does anybody have any suggestions how it would work?

Thanks
silent

Coordinator
Jul 14, 2010 at 7:00 PM
Hi, this is a because of a security restriction in silverlight: http://msdn.microsoft.com/en-us/library/cc645032%28VS.95%29.aspx Does it throw an exception or is the LoadingFailed event raised? I think the first, which is definitly a bug. But nevertheless this is a known limitation.
Jul 16, 2010 at 5:31 AM
Yes it seems like it was the cross site restriction from silverlight, as I got the same error when loading the file with the WebClient. Thank you, that component is really good. silent