0

So I'm working on a project that requires being able to bring up google images pertaining to the selected item.

Right now I'm using the Google Custom Search API to make an image search and getting the results back as a json. I then parse out the first FIVE image paths provided and add these as images to a wrap panel.

Quick snippet of what this looks like

        BitmapImage bmi = new BitmapImage(new Uri(url, UriKind.Absolute));
        image.Source = bmi;

The problem is that this takes on average 20-40 seconds. While the google search takes less than 1. I initially assumed this is because google is just loading thumbnails while I'm downloading the complete image, but I checked out all the sizes and none of them are larger than 30kb, and all download instantaneously through a web browser.

So I think I'm just approaching this the wrong way.

What would be the right way to load in previews and then allow the user to select one to actually save locally.

Regards. John W.

JWrightII
  • 942
  • 11
  • 26
  • 3
    You could check out the code for the [Google Image Search Client](http://www.codeproject.com/Articles/259621/Google-Image-Search-Client-in-Csharp-5-0-and-WPF) project. It downloads several images at once using async methods, and shows how to build the images out of byte streams coming from a WebClient. – Cᴏʀʏ Feb 22 '13 at 20:44
  • I stumbled across that but my project is limited to 4.0 so I disregarded it. May take another look and see if I can make it work. – JWrightII Feb 22 '13 at 20:47
  • You can make it work in 4.0 after downloading and installing the [Async CTP](http://www.microsoft.com/en-us/download/details.aspx?id=9983). See [this thread](http://stackoverflow.com/questions/13377875/await-alternative-in-net-4-0) for more info. – Cᴏʀʏ Feb 22 '13 at 20:49
  • @Cory. Thanks, that image search client is quite a bit faster. The first time you do a search it can take quite a while. But every search after that is okay. Trying to figure out a way to do a dummy search in the background to get that out the way. Appreciate all the help. – JWrightII Feb 22 '13 at 21:49

0 Answers0