Você está na página 1de 2

Try picContainer.Image = Catch ex As Exception MessageBox.Show(ex.

Message, "Please browse the image to be watermark ed") End Try Dim opac As Integer = 0 Dim sOpacity As String = Label3.Text.ToString Select Case (sOpacity) Case "4" opac = 255 ' 1 * 255 Case "3" opac = 191 ' .75 * 255 Case "2" opac = 127 ' .5 * 255 Case "1" opac = 64 ' .25 * 255 Case "0" opac = 25 ' .10 * 255 End Select Try Dim g As Graphics = Graphics.FromImage(picContainer.Image) Dim sz As SizeF = g.MeasureString(txtWaterMark.Text, myFont) Dim myBrush As Brush myBrush = New SolidBrush(Color.FromArgb(opac, myWatermarkColor)) Dim X As Integer Dim Y As Integer ' Set the drawing position based on the users ' selection of placing the text at the bottom or ' top of the image If (rbb.Checked = True) Then X = Convert.ToInt32((picContainer.Image.Width - sz.Width) / 2) Y = Convert.ToInt32(picContainer.Image.Height - sz.Height) g.DrawString(txtWaterMark.Text, myFont, myBrush, X, Y) ElseIf (rbl.Checked = True) Then X = Convert.ToInt32(picContainer.Left) Y = Convert.ToInt32((picContainer.Image.Height - sz.Height) / 2) g.DrawString(txtWaterMark.Text, myFont, myBrush, X, Y) ElseIf (rbr.Checked = True) Then X = Convert.ToInt32(picContainer.Image.Width - sz.Width) Y = Convert.ToInt32((picContainer.Image.Height - sz.Height) / 2) g.DrawString(txtWaterMark.Text, myFont, myBrush, X, Y) ElseIf (rbc.Checked = True) Then X = Convert.ToInt32((picContainer.Image.Width / 2) - sz.Width / 2) Y = Convert.ToInt32((picContainer.Image.Height / 2) - sz.Height / 2) g.DrawString(txtWaterMark.Text, myFont, myBrush, X, Y)

ElseIf (rbt.Checked = True) Then X = Convert.ToInt32((picContainer.Image.Width - sz.Width) / 2) Y = Convert.ToInt32((sz.Height) / 2) g.DrawString(txtWaterMark.Text, myFont, myBrush, X, Y) End If

Catch ex As Exception MessageBox.Show(ex.Message, "Please browse the image to be watermark ed") End Try

Você também pode gostar