1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
Dim cloneBitmap As Bitmap = Nothing
Dim fs As New System.IO.FileStream(myPath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
'Dim img2 As Image = Image.FromStream(fs)
Dim img2 As Bitmap = CType(Bitmap.FromStream(fs), Bitmap)
pbCheckImage01.BackgroundImage = img2
Using g As Graphics = Graphics.FromImage(img2)
' Text position of Label TGlass
Dim topleft As Point
topleft = New Point(TGlass.Top, TGlass.Left)
' Text content of Label TGlass
Dim strCalendar As String = TGlass.Text
' Measurement of the label TGlass (strCalendar) for a selected font
Dim sizeString As New SizeF
sizeString = g.MeasureString(strCalendar, TGlass.Font)
' Rectangle layout for the selected font
Dim layout As New Rectangle(topleft, Size.Ceiling(sizeString))
'If layout.Right < 400 - (layout.Right - layout.X) Then
layout.X = CInt(layout.X * (img2.Height / pbCheckImage01.Height))
'End If
'If layout.Bottom < 400 - (layout.Bottom - layout.Y) Then
layout.Y = CInt(layout.Y * (img2.Width / pbCheckImage01.Width))
'End If
' Text First Page
Dim myFont As New Font(TGlass.Font.FontFamily, CInt(TGlass.Font.Size * (img2.Width / img2.Height)), TGlass.Font.Style)
'Dim myFont As New Font(TGlass.Font.FontFamily, sizeString.ToSize, TGlass.Font.Style)
Dim myBrush As New SolidBrush(TGlass.ForeColor)
'g.DrawString(strCalendar, TGlass.Font, Brushes.Red, layout)
g.DrawString(strCalendar, myFont, myBrush, layout.Y, layout.X) 'layout.Width, layout.Height)
' Remove the TextWindow class
pbCheckImage01.Controls.Remove(TGlass)
Refresh()
cloneBitmap = img2
End Using |
Partager