Skip to content

Instantly share code, notes, and snippets.

@abe238
Created June 29, 2015 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abe238/6cc4ebc1b431afb8998b to your computer and use it in GitHub Desktop.
Save abe238/6cc4ebc1b431afb8998b to your computer and use it in GitHub Desktop.
Create Blended Image
private static Image CreateBlendedImage(string backgroundimageurl)
{
Image imageBackground;
Image imageOverlay;
var request = WebRequest.Create(backgroundimageurl);
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
{
imageBackground = Bitmap.FromStream(stream);
}
var request2 = WebRequest.Create("http://c1.staticflickr.com/1/286/19041020628_2657a057cc_k.jpg"); //Rainbow Flag
using (var response2 = request2.GetResponse())
using (var stream2 = response2.GetResponseStream())
{
imageOverlay = Bitmap.FromStream(stream2);
}
imageOverlay = ChangeOpacity(imageOverlay, 0.5F);
imageOverlay = ScaleImage(imageOverlay, imageBackground.Width, imageBackground.Height);
imageOverlay = imageOverlay.GetThumbnailImage(imageBackground.Width, imageBackground.Height, null, IntPtr.Zero);
Image img = new Bitmap(imageBackground.Width, imageBackground.Height);
using (Graphics gr = Graphics.FromImage(img))
{
gr.DrawImage(imageBackground, new Point(0, 0));
gr.DrawImage(imageOverlay, new Point(0, 0));
}
return img;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment