Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7638781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:15:25+00:00 2026-05-31T08:15:25+00:00

I have an array of urls. Each url contains one image. I need to

  • 0

I have an array of urls. Each url contains one image. I need to download them one by one and start a slideshow. I tried to download each file using a loop and display them. But whenever I am trying to get previous image I get nothing.

My code is shown below

string [] urlArray;
int currentItem;
int totalItems;
private void StartSlideShow()
{
    for(int i=0;i < totalItems;i++)
    {
        DownloadImage(urlArray[i]);
    }
}

private void DownloadImage(string url)
{
    WebClient wc=new WebClient();
    wc.OpenReadCompleted+=new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
    wc.OpenReadAsync(new Uri(url));
}

private void wc_OpenReadCompleted(object sender,OpenReadCompletedEventArgs e)
{
    BitmapImage bi=new BitmapImage();
    bi.SetSource(e.Result);
    imgThumbnail.Source=bi;
}

private void btnNext_Click(object sender, RoutedEventArgs e)
{
    if (currentItem < totalItems)
    {
        DownloadImage(urlArray[currentItem+1]);
        currentItem++;
    }
}
private void btnBack_Click(object sender, RoutedEventArgs e)
{
    if (currentItem > 1)
    {
        DownloadImage(urlArray[currentItem-1]);
        currentItem--;
    }
}

Then I was tried to download all the images first and save into an array of BitmapImage and tried to start slideshow after completing the download. Nothing is displayed in this case.

The code is

private void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
        bi.SetSource(e.Result);
        biArr[currentItem].SetSource(e.Result);
    if(currentItem==totalItems])
        ShowSlides(biArr);
}

private void ShowSlides(BitmapImage[] biArr)
{
    for(int i=0;i < totalItems;i++)
    {
        imgThumbnail.Source=biArr[i];
        System.Threading.Thread.Sleep(5000);
    }
}

Then I tried to convert the images to byteArray and save it into a list names BMPList. ( List BMPList ). After complete the download when I am trying to display the images only a black color is shown as image

The code is

private void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    BitmapImage bi = new BitmapImage();
    bi.SetSource(e.Result);
    using (MemoryStream ms = new MemoryStream())
    {
        WriteableBitmap btmMap = new WriteableBitmap(bi.PixelWidth, bi.PixelHeight);
        System.Windows.Media.Imaging.Extensions.SaveJpeg(btmMap, ms, bi.PixelWidth, bi.PixelHeight, 0, 100);
        BMPList.Add(ms.ToArray());
    }
    if(currentItem == totalItems)
        ShowSlides(BMPList);
}

private void ShowSlides(List<byte[]> BMPList)
{
    for(int i=0; i < BMPList.Count;i++)
    {
        if (BMPList[currentDisplayItem] != null)
        {
            MemoryStream ms = new MemoryStream(BMPList[i], 0, BMPList[i].Length);
            ms.Write(BMPList[i], 0, BMPList[i].Length);

            BitmapImage img = new BitmapImage();
            img.SetSource(ms);
            imgThumbnail.Source = img;
        }
                System.Threading.Thread.Sleep(5000);
    }
}

How can I download all images and start a slideshow?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:15:26+00:00Added an answer on May 31, 2026 at 8:15 am

    There should be no need for you to download the images yourself, just point the Source of the Image to the Uri.

    See also http://blogs.msdn.com/b/swick/archive/2011/04/07/image-tips-for-windows-phone-7.aspx for details about avoiding memory issues when working with lots of web based images.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of URLs and I wan't to open each one and
I have an array of Image URl's from that array i have displayed my
I have a list of URL. Each url has an image of specific size.
I currently have an Array that contains some URL's to images. @images = [
I have an array of Image URLS .I want to dynamically add Pivot item
I have an array of urls that I want to display one by one
I have xml file that contains the URLs for geocoding requests to Google. I
I have an array of urls of images, from which i have to first
I have an array containing the contents of a MySQL table. I need to
I have an array of URLs of content to load asynchronously, e.g. var toLoad

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.