【发布时间】:2016-10-14 07:49:33
【问题描述】:
我想显示已创建的新位图图像。不保存。
我在 C# 中使用带有图形的位图,我希望返回新图像而无需保存新图像。
C#
private void GenerateBanner( string titleText ) {
Bitmap bannerSource = new Bitmap( DefaultBannerPath );
//bannerSource.Save( PhysicalBannerPath );
RectangleF rectf = new RectangleF( 430, 50, 650, 50 );
using (Graphics g = Graphics.FromImage(bannerSource))
{
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
g.DrawString(titleText, new Font("Bradley Hand ITC", 100, FontStyle.Bold), Brushes.White, rectf);
//bannerSource.Save( PhysicalBannerPath );
}
}
【问题讨论】:
-
Winforms?在
Form上使用PictureBox -
请问您使用的是 WinForms 还是 WPF?
-
它是我自己的类控制。它将在一个 aspx 页面上。 @FredrikRedin
-
把
private void GenerateBanner( string titleText )改成private Bitmap GenerateBanner( string titleText ),最后加上return bannerSource。