Skip to main content

Microsoft Silverlight

Answered Question Play .Gif File in silverlightRSS Feed

(0)

NavinKumar.K.S
NavinKum...

Member

Member

295 points

227 Posts

Play .Gif File in silverlight

Hello community,

i need to play a gif file in silverlight. can it be possible to play a .gif animation if yes how to do it please explain me i got a link

please refer this link that i got and please send me your's taughts how can i implement .Gif images in silverlight 3

and also i got this link where we can get some customized loading gif images

Please Mark "Mark As answer" if this post answers your's question


("-ksnavinkumar@live.com-")

watabou
watabou

Member

Member

418 points

75 Posts

Answered Question

Re: Play .Gif File in silverlight

 I think this is what you're looking for :

http://imagetools.codeplex.com/

(If this has answered your question, please click on "mark as answer" on this post. Thank you!)
Hope it helps !
Bastien BESSON

brauliod
brauliod

Participant

Participant

1169 points

472 Posts

Silverlight MVP

Re: Play .Gif File in silverlight

Wow !!

   I was not aware that Image Tools was able to load animated gifs, ... about this open source project, is quite active, you can easily contact with the person that developed it and probably will get a quick response.

   Cheers

    Braulio

// ---------------------------------
    Braulio Diez

    http://www.dbschemaeditor.com
    Free Silverlight Based Database Schema Editor
/// ---------------------------------

rontch
rontch

Member

Member

12 points

6 Posts

Re: Play .Gif File in silverlight

Hi Brauliod,

Were you able to use the ImageTools.dll in Silverlight application?

Can you be kind and share a few lines on how to set the animated-gif to work.

I've tried (with no success):

xmlns:theTool="clr-namespace:ImageTools;assembly=ImageTools"

<theTool:AnimatedImage Source="Images/progressbar.gif" />

what am i missing here? the above code fail when i start the application

Thanks in advance, Ron

malignate
malignate

Member

Member

16 points

17 Posts

Re: Re: Play .Gif File in silverlight

Hi,

I have created this project.

First two questions:
(1) Which version do you use? Please download the latest source and compile it. There are a lot of bugs in version 0.1.
(2) Where is the image located?

rontch
rontch

Member

Member

12 points

6 Posts

Re: Re: Play .Gif File in silverlight

1) I'm using the 'Download' link - which only gives me the DLL (version 1.1) - but i couldn't see any demo-project that i caould compile in this link.

2)The image - which is an animated gif - is located under ClientBin\Images\progressbar.gif

* in order to make sure that the path is correct in Source="Images/progressbar.gif"  I've set the path to another image - under "Images" as well, and it does show the image (normal gif, not animated).

malignate
malignate

Member

Member

16 points

17 Posts

Re: Re: Re: Play .Gif File in silverlight

Please download the latest source and compile it. You will also find some demo projects there.

As far as I have time to complete the gif encoder, a new version will be released.

If this also does not work (but I have tested it again yesterday), please send me your image for testing.  

rontch
rontch

Member

Member

12 points

6 Posts

Re: Re: Re: Play .Gif File in silverlight

Hi, I have tried working with your sample code on ImageTools.Demo.Animation
(under your link: http://imagetools.codeplex.com/SourceControl/changeset/view/33161#518787)

 but with no luck..  The WrapPanel does not display my Animated-GIF.

I have attached the file i'm using (not sure if it was upload correctly) - if you can please check if it works for you.

The code I'm using is below - appreciate if you can let me know what am i doing wrong here:

Image image = new Image();

System.Windows.Media.Imaging.BitmapImage imgSource1 = new System.Windows.Media.Imaging.BitmapImage();

imgSource1.UriSource = new Uri("Images/" + name, UriKind.RelativeOrAbsolute);

//image.Source = imgSource1;

//image.UriSource = new Uri("Images/" + name, UriKind.Relative); // <--- no such property "image.UriSource"

AnimatedImage smiley = new AnimatedImage();

//smiley.Stretch = System.Windows.Media.Stretch.None;

smiley.AutoSize = true;

smiley.Source = imgSource1; //image; // <--- passing the source URI (works for normal image under ClientBin\Images\MyImg.gif)

smiley.VerticalAlignment = VerticalAlignment.Bottom;

smiley.Margin = new Thickness(0, 2, 2, 2);

return smiley;

malignate
malignate

Member

Member

16 points

17 Posts

Re: Re: Re: Re: Play .Gif File in silverlight

Aah, I think I see the problem. Whenever you pass an relative address like yours the image looks in the assembly for an image.

When you specify an absolute address like http://domain/images/mygif.gif it uses a WebClient to get the stream to the image. I will have a look with reflector how Image handles this. Didnt know that it also works when placing the image under ClientBin.

rontch
rontch

Member

Member

12 points

6 Posts

Re: Re: Re: Re: Play .Gif File in silverlight

hope i helped you think of how to improve the code. I realy think it's a good project and a great innovation of yours, thanks.

I managed to download the project and noticed you placed your "Images" folder in each of your demo projects.

fyi, Images Uri in silverlight works RELATIVE TO THE .xap FILE LOCATION.

>> the .xap file is always under ClientBin

>> if you've got a folder "ClientBin/Images" then your xaml code should refer the Uri as: Source="Images/myImg.png"

waiting to see your new version,

malignate
malignate

Member

Member

16 points

17 Posts

Re: Re: Re: Re: Re: Play .Gif File in silverlight

Hi,

you can retry it if you want :)

rontch
rontch

Member

Member

12 points

6 Posts

Play .Gif File in silverlight - Using DLLs only as references

hi again,

thanks for your efforts, just 1 thing is still a mistory..

I've started a new VS2008 "Silverlight application" , with .Web project and duplicate the structure you've demo in ImageTools.Demo.Sources. (meaning I've ended up with 2 project: Sources and Sources.Web)

My goal here is to use the references only - from the Bin folder.

The thing is that I'm getting a Javascript error when running the sample solution...

Can you please confirm it's an issue? I've cheked the silvelight versions and project properties and it's all the same, just your project rs but mine doesn't :)

(I can run the demo project fine - when running from your solution. Weird isn't it..)

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities