将带有背景图像的图片框保存到文件
Saving picturebox WITH backgroundimage to file
有没有办法将带有背景图像的图片框(Windows 表单)保存到文件中?
我试图将 picturebox.Image 存储到位图中
但它只是图像本身,而不是背景图像。
您可以使用图形或位图组合两个图像。提供了一个很好的例子here
位图
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");
}
图形:
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");
}
}
有没有办法将带有背景图像的图片框(Windows 表单)保存到文件中? 我试图将 picturebox.Image 存储到位图中 但它只是图像本身,而不是背景图像。
您可以使用图形或位图组合两个图像。提供了一个很好的例子here
位图
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");
}
图形:
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");
}
}