Dim InSt As New SealYourPics
InSt.Seal(PictureBoxSource.Image, _
PictureBoxLogo.Image, SealYourPics.Corner.Top_Left)
PictureBoxResult.Image = InSt.ResultPic
'Author : Moayad Mardini [moayad.m_at_gmail_dot_com]
'Forum : In|Structurez [http:/ / www.agdn-online.com]
'IDE : Visual Studio .NET 2005 Professional
'Date : 02/12/2005
'Last Edit : 06/12/2005
Imports System.Drawing
Imports System.Math
Public Class SealYourPics
Private Result As Bitmap
Public ReadOnly Property ResultPic()
Get
Return Result
End Get
End Property
Public Sub Seal(ByVal OrigianPicture As Bitmap, _
ByVal CompanyLogo As Bitmap, ByVal DrawLogoCorner As Corner)
Try
Dim SourcePic As New Bitmap(OrigianPicture)
Dim LogoPic As New Bitmap(CompanyLogo)
Dim Temp As Integer, Temp2 As Integer
Dim MinWidth As Integer = Min(LogoPic.Width, _
SourcePic.Width)
Dim MinHeight As Integer = Min(LogoPic.Height, _
SourcePic.Height)
Dim WidthPlus As Integer
Dim HeightPlus As Integer
Select Case DrawLogoCorner
Case Corner.Bottom_Left
WidthPlus = 0
HeightPlus = SourcePic.Height - MinHeight
Case Corner.Bottom_Right
WidthPlus = SourcePic.Width - MinWidth
HeightPlus = SourcePic.Height - MinHeight
Case Corner.Top_Left
WidthPlus = 0
HeightPlus = 0
Case Corner.Top_Right
WidthPlus = SourcePic.Width - MinWidth
HeightPlus = 0
End Select
For Temp = 0 To MinHeight - 1
For Temp2 = 0 To MinWidth - 1
If LogoPic.GetPixel(Temp2, Temp).ToArgb <> -65281 Then
SourcePic.SetPixel(Temp2 + WidthPlus, _
Temp + HeightPlus, LogoPic.GetPixel(Temp2, Temp))
End If
Next
Next
Result = New Bitmap(SourcePic)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Public Enum Corner
Top_Right
Top_Left
Bottom_Right
Bottom_Left
End Enum
End Class
Min(LogoPic.Width, SourcePic.Width) – 1
Min(LogoPic.Height, SourcePic.Height) - 1
Dim InSt As New SealYourPics(PictureBoxSourcePic.Image, _
PictureBoxLogo.Image, SealYourPics.Corner.Top_Right)
PictureBoxResult.Image = InSt.ResultPic
Dim VR As New SealYourPics (...)
Dim VR As New SealYourPics
VR.Seal (...)