Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from SamPlusPlus/AlbumArt
Album art
- Loading branch information
Showing
3 changed files
with
146 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.Net; | ||
|
||
namespace WinGrooves.Utils | ||
{ | ||
public static class ImageUtils | ||
{ | ||
/// <summary> | ||
/// Retrieves the image at the url. | ||
/// </summary> | ||
/// <param name="url">url of image.</param> | ||
/// <returns>Returns image as bitmap, or null if not available.</returns> | ||
public static Bitmap BitmapFromUrl(string url) | ||
{ | ||
if (String.IsNullOrEmpty(url)) | ||
{ | ||
return null; | ||
} | ||
var request = WebRequest.Create(url); | ||
|
||
using (var response = request.GetResponse()) | ||
using (var stream = response.GetResponseStream()) | ||
{ | ||
if (stream == null) return null; | ||
return (Bitmap)Image.FromStream(stream); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Returns a bitmap of the current form. | ||
/// </summary> | ||
/// <returns>Returns a bitmap of the current form</returns> | ||
public static Bitmap ApplicationThumbnail(System.Windows.Forms.Form form) | ||
{ | ||
Graphics myGraphics = form.CreateGraphics(); | ||
Size s = form.Size; | ||
Bitmap memoryImage = new Bitmap(s.Width, s.Height, myGraphics); | ||
Graphics memoryGraphics = Graphics.FromImage(memoryImage); | ||
memoryGraphics.CopyFromScreen(form.Location.X, form.Location.Y, 0, 0, s); | ||
return memoryImage; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters