'Saving picturebox WITH backgroundimage to file [duplicate]
is there any way to save a picturebox (Windows Forms) with it Backgroundimage to a file? I tried to store the picturebox.Image into a bitmap but its only the image itself, not the backgroundimage too.
Solution 1:[1]
You can combine two images using graphics or bitmap. There is a good example provided here
Bitmap
using (var bitmap = new Bitmap(@"Images\in.jpg"))
using (var watermark = new Bitmap(@"Images\watermark.png"))
{
//Make the watermark semitransparent.
watermark.Channels.ScaleAlpha(0.8F);
//Watermark image
bitmap.Draw(watermark, 10, bitmap.Height - watermark.Height - 40, CombineMode.Alpha);
//Save the resulting image
bitmap.Save(@"Images\Output\out.jpg");
}
Graphics:
using (var bitmap = new Bitmap(@"Images\in.jpg"))
using (var watermark = new Bitmap(@"Images\watermark.png"))
{
//Make the watermark semitransparent.
watermark.Channels.ScaleAlpha(0.8F);
//Watermark an image.
using (var graphics = bitmap.GetGraphics())
{
graphics.DrawImage(watermark, 10, bitmap.Height - watermark.Height - 40, CombineMode.Alpha);
//Save the resulting image
bitmap.Save(@"Images\Output\out.jpg");
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Boris Sokolov |