vb Code:
Private Sub saveImage(ByVal fileName As String, ByVal format As Drawing.Imaging.ImageFormat, ByVal pb As PictureBox) Dim img As New Bitmap(DirectCast(pb.Image.Clone, Bitmap), pb.image.Width, pb.image.Height) Dim gr As Graphics = Graphics.FromImage(img) Dim sf As New StringFormat sf.Alignment = StringAlignment.Near sf.LineAlignment = StringAlignment.Center For Each lbl As Label In pb.Controls.OfType(Of Label)() gr.FillRectangle(New SolidBrush(lbl.BackColor), lbl.Bounds) gr.DrawString(lbl.Text, lbl.Font, New SolidBrush(lbl.ForeColor), lbl.Bounds, sf) 'this draws a red border gr.DrawRectangle(Pens.Red, lbl.Bounds) Next img.Save(fileName, format) End Sub




Reply With Quote
