weet misschien iemand hoe ik de tekst van een label kan opslaan als een image?
ik heb al een code maar dat is niet wat ik wil. je kunt hem testen dan zul je waarschijnlijk wel zien waarom. code:
[edit]Ik heb nog een nieuwe code gevonden, maar hoe kan ik de 'Function' laten werken. code:
[/edit]
ik heb al een code maar dat is niet wat ik wil. je kunt hem testen dan zul je waarschijnlijk wel zien waarom. code:
Code:
Dim b As Bitmap = New Bitmap("C:\Temp\Test.jpg")
Dim g As Graphics = Graphics.FromImage(b)
g.DrawString("hello world", New Font("Courier", 30, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Red, 25, 25)
b.Save("C:\Temp\testout.jpg")
[edit]Ik heb nog een nieuwe code gevonden, maar hoe kan ik de 'Function' laten werken. code:
Code:
Private Function CreateBitmapImage(ByVal sImageText As String) As Bitmap
Dim objBmpImage As New Bitmap(1, 1)
Dim intWidth As Integer = 0
Dim intHeight As Integer = 0
Dim objFont As New Font(LabelX1.Font.OriginalFontName, LabelX1.Font.Size, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel)
Dim objGraphics As Graphics = Graphics.FromImage(objBmpImage)
intWidth = CInt(objGraphics.MeasureString(sImageText, objFont).Width)
intHeight = CInt(objGraphics.MeasureString(sImageText, objFont).Height)
objBmpImage = New Bitmap(objBmpImage, New Size(intWidth, intHeight))
objGraphics = Graphics.FromImage(objBmpImage)
objGraphics.Clear(Color.White)
objGraphics.SmoothingMode = SmoothingMode.AntiAlias
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias
objGraphics.DrawString(sImageText, objFont, New SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0)
objGraphics.Flush()
Return (objBmpImage)
End Function
Laatst bewerkt: