I’ve been searching around for a solution to this but haven’t really found one.
Here is some patchwork code that I’ve been playing with trying to get this working but no success.
private Image GetAlbumArt(String url)
{
byte[] rBytes;
Image Testing;
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
WebResponse myResponse = myRequest.GetResponse();
Stream rStream = myResponse.GetResponseStream();
using (BinaryReader br = new BinaryReader(rStream))
{
rBytes = br.ReadBytes(1000000);
br.Close();
}
myResponse.Close();
using (MemoryStream imageStream = new MemoryStream(rBytes, 0, rBytes.Length))
{
imageStream.Write(rBytes, 0, rBytes.Length);
Testing = Image.FromStream(imageStream, true);
Testing.Save("temp.jpg"); //Error here!
}
return Testing;
}
I would actually rather not save the bitmap and just return the bitmap to the parent function, but that didnt work either. (cannot close the memory stream if you want to use the bitmap)
The really strange thing is that this works fine if i give it a different jpg url.
Doesnt work: http://2.images.napster.com/mp3s/2492/resources/207/116/files/207116316.jpg
works: http://3.images.napster.com/mp3s/2256/resources/301/404/files/301404546.jpg
I found if I save your image to bmp and it works fine. I also checked the DPI of your first image is much higher than the second one. Hope this is the clue you can go through.