📅  最后修改于: 2022-03-11 14:48:53.651000             🧑  作者: Mango
Bitmap bmp = new Bitmap(300, 300);
using (Graphics g = Graphics.FromImage(bmp))
{
Font font = new Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Point);
g.Clear(Color.White);
g.DrawString("Hello", font, Brushes.Black, 0, 0);
}
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
Bitmap newBitmap = new Bitmap(300, 300, bmpData.Stride, System.Drawing.Imaging.PixelFormat.Format1bppIndexed, bmpData.Scan0);
newBitmap.Save(@"c:\x\x.bmp");