Hi everyone, currently working on a digital watermarking system in VB.NET and was wondering if it would be possible to convert a string from a text box into bitmap format in-order to use it as a watermark. I currently have a programming which works by using a bitmap from file, the code is below if it would help:
Private Sub btnWatermark_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWatermark.Click
Dim watermark_bm As New Bitmap(picWatermark.Image)
Dim result_bm As New Bitmap(picImage.Image)
Dim x As Integer = (result_bm.Width - watermark_bm.Width) \ 2
Dim y As Integer = (result_bm.Height - watermark_bm.Height) \ 3
DrawWatermark(watermark_bm, result_bm, x, y)
watermark_bm = New Bitmap(picWatermark2.Image)
y = 2 * (result_bm.Height - watermark_bm.Height) \ 3
DrawWatermark(watermark_bm, result_bm, x, y)
picImage.Image = result_bm
End Sub
Private Sub DrawWatermark(ByVal watermark_bm As Bitmap, ByVal result_bm As Bitmap, ByVal x As Integer, ByVal y As Integer)
Const ALPHA As Byte = 128
' Set the watermark's pixels' Alpha components.
Dim clr As Color
For py As Integer = 0 To watermark_bm.Height - 1
For px As Integer = 0 To watermark_bm.Width - 1
clr = watermark_bm.GetPixel(px, py)
watermark_bm.SetPixel(px, py, Color.FromArgb(ALPHA, clr.R, clr.G, clr.B))
Next px
Next py
' Set the watermark's transparent color.
watermark_bm.MakeTransparent(watermark_bm.GetPixel(0, 0))
' Copy onto the result image.
Dim gr As Graphics = Graphics.FromImage(result_bm)
gr.DrawImage(watermark_bm, x, y)
End Sub
Any help would be greatly recieved,
Thanks
Stephen
Private Sub btnWatermark_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWatermark.Click
Dim watermark_bm As New Bitmap(picWatermark.Image)
Dim result_bm As New Bitmap(picImage.Image)
Dim x As Integer = (result_bm.Width - watermark_bm.Width) \ 2
Dim y As Integer = (result_bm.Height - watermark_bm.Height) \ 3
DrawWatermark(watermark_bm, result_bm, x, y)
watermark_bm = New Bitmap(picWatermark2.Image)
y = 2 * (result_bm.Height - watermark_bm.Height) \ 3
DrawWatermark(watermark_bm, result_bm, x, y)
picImage.Image = result_bm
End Sub
Private Sub DrawWatermark(ByVal watermark_bm As Bitmap, ByVal result_bm As Bitmap, ByVal x As Integer, ByVal y As Integer)
Const ALPHA As Byte = 128
' Set the watermark's pixels' Alpha components.
Dim clr As Color
For py As Integer = 0 To watermark_bm.Height - 1
For px As Integer = 0 To watermark_bm.Width - 1
clr = watermark_bm.GetPixel(px, py)
watermark_bm.SetPixel(px, py, Color.FromArgb(ALPHA, clr.R, clr.G, clr.B))
Next px
Next py
' Set the watermark's transparent color.
watermark_bm.MakeTransparent(watermark_bm.GetPixel(0, 0))
' Copy onto the result image.
Dim gr As Graphics = Graphics.FromImage(result_bm)
gr.DrawImage(watermark_bm, x, y)
End Sub
Any help would be greatly recieved,
Thanks
Stephen