2010-11-29 3 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);