2010-11-29 8 views
0

ビットマップイメージをテキストファイルから保存できるようにするため、テキストファイルとビットマップファイルを開いて後で表示することができます。これは、ビットマップイメージを保存するための私の現在のコードです:C#のテキストボックスからテキスト付きのビットマップを保存する

{ 
    //Show a save dialog to allow the user to specify where to save the image file 
    using (SaveFileDialog dlgSave = new SaveFileDialog()) 
    { 
     dlgSave.Title = "Save Image"; 
     dlgSave.Filter = "Bitmap Images (*.bmp)|*.bmp|All Files (*.*)|*.*"; 
     if (dlgSave.ShowDialog(this) == DialogResult.OK) 
     { 
      //If user clicked OK, then save the image into the specified file 
      using (Bitmap bmp = new Bitmap(capturebox.Width, capturebox.Height)) 
      { 
       capturebox.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height)); 
       bmp.Save(dlgSave.FileName); 
      } 
     } 
    } 
} 

ので、私はそれがExtraNotesと呼ばれるラベルにテキストを保存し、その後のPictureBoxで画像を開くことができるようにする必要があります(capturebox)とのテキストもう一度ラベルを付けます。 、

おかげ

答えて

4

これは大まかなテキストを描画します助けてください(あなたはそれがきれいに作ることができる):

static void DrawSomethingToBitmap(Image img, string text) 
    { 
     Graphics g = Graphics.FromImage(img); 
     g.DrawString(text, SystemFonts.DefaultFont, Brushes.Gray, 
      img.Width/2, img.Height/2); 

    } 

を呼び出すだけ

DrawSomethingToBitmap(bmp, lblMyLabel.Text); 
関連する問題