0

I am building an Rss reader app and having problems with gifs.

Does anyone know how to build the ImageConverter class so it would convert gif to png? Converting gifs in code will also work for me. My app works in a way that it takes everything from the feed, puts it in a list() first and then it populates the listbox, (in a way the user chooses to). gifs leave blank images :(

so basically converter would have to work with a link, not a direct data stream.

I will add some code on how my data is updated:

ObservableCollection<FeedItem> slika0; //where the feeditems from the selected category go 

    public ObservableCollection<FeedItem> Slika0
    {
        get { return slika0; }
        set
        {
            slika0 = value;
            OnPropertyChanged("Slika0");
        }
    }

    int broj_elemenata = 0;
    bool nema_elemenata = false;
    private void UpdateFeedList(string feedXML)
    {
        StringReader stringReader = new StringReader(feedXML);
        XmlReader xmlReader = XmlReader.Create(stringReader);
        SyndicationFeed feed = SyndicationFeed.Load(xmlReader);

        List<string> kategorije = new List<string>();
        foreach (SyndicationItem sitem in feed.Items)
        {
            foreach (SyndicationCategory sc in feed.Categories)
            {
                if (!kategorije.Contains(sc.Name))
                {
                    kategorije.Add(sc.Name);
                }
            }
        }

        FeedItem FeedItem = new FeedItem();
        Slika0 = new ObservableCollection<FeedItem>();
        //SyndicationCategory tražena_kat = new SyndicationCategory("Trendy");

        foreach (SyndicationItem item in feed.Items)
        {
            foreach (SyndicationCategory sc in item.Categories)
            {
                FeedItem.Content_List.Add(sc.Name);

                foreach (SyndicationElementExtension ext in item.ElementExtensions)
                {
                    XElement ele = ext.GetObject<XElement>();

                    if (ele.Name.LocalName == "encoded" && ele.Name.Namespace.ToString().Contains("content"))
                    {
                        FeedItem.Content_List.Add(item.Title.Text);
                        FeedItem.Content_List.Add(ele.Value);//takes the content of the feed
                    }
                }

                foreach (SyndicationLink link in item.Links)
                {

                    FeedItem.Content_List.Add(link.Uri.AbsoluteUri); //takes the links for  browsing and the image 

                }
            }
        }
        IsolatedStorageSettings.ApplicationSettings["ContentList"] = FeedItem.Content_List;

        Deployment.Current.Dispatcher.BeginInvoke(() =>
        {

            int i;
            int x = 0;

            Slika0.Clear();
            foreach (var item in FeedItem.Content_List)
            {
                i = FeedItem.Content_List.IndexOf(item, x); //x = index of category in the list

                if (item == "Trendy")
                {
                    FeedItem FF = new FeedItem();
                    FF.Post_text = FeedItem.Content_List[i + 1];//title of article
                    FF.Content_link = FeedItem.Content_List[i + 2];//content
                    FF.Post_link = FeedItem.Content_List[i + 3];//the location of link for browsing
                    FF.Post_slika = FeedItem.Content_List[i + 4]; //location of image link

                    if (FF.Post_slika == "") //if there is no link for picture code is executed
                    {
                        FF.Post_slika = "Slike/zimo_veliki_tile.png";
                    }

                    Slika0.Add(FF);
                    this.lsSlika_P.ItemsSource = Slika0; //take

                    x = i + 5;
                    broj_elemenata++;
                }
            }

            if (lsSlika_P.Items.Count <= 3)
            {
                scroll_panorama.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
            }

            if (lsSlika_P.Items.Count == 0)
            {
                nema_elemenata = true;
            }
            else nema_elemenata = false;


        });
        pan_progres.Visibility = Visibility.Collapsed;//progress bar
    }
Goran303
  • 591
  • 1
  • 6
  • 16
  • Can you not just get the stream from the link and then convert it? – Matt Lacey May 24 '12 at 12:13
  • I'm not an experienced Dev. besides is it possible to avoid the stream? do I have to go to web via link always. and where in the code would I put the decode/encode? – Goran303 May 24 '12 at 13:41
  • can anyone build a converter or example in code. an idea at least? – Goran303 May 24 '12 at 21:31
  • I do everything like its in this topic: http://stackoverflow.com/questions/4152564/display-gif-in-a-wp7-application-with-silverlight but I get major error System.MissingMethodException was unhandled Message=Could not load type 'System.Diagnostics.Contracts.ContractFailureKind' from assembly 'mscorlib, Version=3.7.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC'. StackTrace: at ImageTools.Controls.AnimatedImage.$InvariantMethod$() at ImageTools.Controls.AnimatedImage..ctor() – Goran303 May 27 '12 at 11:38

0 Answers0