BAB V KESIMPULAN DAN SARAN
LAMPIRAN II Listing Code
Adapun source code untuk aplikasi watermarking di atas adalah sebagai berikut:
Untuk Menampilkan Halaman Utama
Option Explicit
Private Sub Form_Unload(Cancel As Integer) Set Form1 = Nothing
'TranslucentForm Me, g End If
g = g - 2
Untuk Menampilkan Perbandingan citra sebelum dan sesudah di watermark
Option Explicit
Dim strImageFile$ 'the main image where the files will be attach Dim strImageFile2$
Dim m_Millimeter&
Dim m_Millimeter2&
Private Sub Gambar()
Dim ToW&, ToH&, InW&, InH&, mPad&
Dim ToW2&, ToH2&, InW2&, InH2&, mPad2&
mPad = 2 mPad2 = 2
strImageFile = frmAdd.File strImageFile2 = frmAdd.Target
Picture2.Picture = LoadPicture(strImageFile) Picture3.Picture = LoadPicture(strImageFile2)
Move (MDIForm1.ScaleWidth - Width) \ 2, (MDIForm1.ScaleHeight - Height) \ 2
m_Millimeter = ScaleX(100, vbPixels, vbMillimeters)
'fill the name for each step process
End Sub
Private Sub Form_Unload(Cancel As Integer) Set Form2 = Nothing
Picture2.Move Picture2.Left, -VS.Value End Sub
Private Sub VS_Scroll()
Picture2.Move Picture2.Left, -VS.Value End Sub
Private Sub VS2_Change()
Picture3.Move Picture3.Left, -VS2.Value End Sub
Private Sub VS2_Scroll()
Picture3.Move Picture3.Left, -VS2.Value End Sub
Untuk menampilkan Menu About
Dim M_About As String Dim MaxText As Long Dim NowText As Long
Private Sub Form_Load()
M_About = "MVD Watermark ||" & _
"Image Copyright Protector Version 1.00|" & _ "Created by Muhammad Virza Dwiriandry|" & _ "Copyright ©2012 All Right Reserved|" & _
"||If you have any question or suggestion, please contact us: [email protected]"
TWrite.Enabled = True End Sub
Private Sub Form_Unload(Cancel As Integer) NowText = 0
TAbout.Text = Left(M_About, NowText) TAbout.SelStart = Len(TAbout.Text) End Sub
Untuk menampilkan Menu Sisipkan File
Option Explicit Dim vSteps
Dim currentStep& 'Counter to know the current step in process Const MAX_STEPS = 4 'Max step in this module
Dim DemoLimit&
Dim strImageFile$ 'the main image where the files will be attach
Public File$
Public Target$
Dim m_Millimeter&
Dim WithEvents clsStega As ClsStegano 'The magic class Dim WithEvents clsStegaRead As ClsStegano
Dim j As Integer, str As String
Private Sub Check1_Click() If Check1.Value = 1 Then txtPwd.PasswordChar = ""
Else
txtPwd.PasswordChar = "X"
End If
End Sub
'If you wants capture some error, do it here
Private Sub clsStegaRead_SomeError(strDescription As String)
'If you wants capture some error, do it here
Private Sub clsStega_SomeError(strDescription As String)
MsgBox "Some error: " & strDescription, , "Image Copyright Protector"
End Sub
'The current process is show it here
Private Sub clsStega_StatusChanged(prcDone As Long, strStatus As String) 'frmLoad.ProgBar.Value = prcDone
ProgBar.Value = prcDone 'frmLoad.lbStatus = strStatus lbStatus = strStatus
End Sub
'The current process is show it here
Private Sub clsStegaRead_StatusChanged(prcDone As Long, strStatus As String) 'frmLoad.ProgBar.Value = prcDone
OsenXPProgressBar1.Value = prcDone 'frmLoad.lbStatus = strStatus
Label1 = strStatus End Sub
Private Sub cmdAddFile_Click() Dim theData$, theKey$, sTitle$
Dim Itlvw As ListItem
Dim iconFile%, myclsGetIcon As New clsGetIcon Dim imgRet As IPictureDisp
'browse to get the files to be add 'File type tested
'Files.Filter = "All Files|*.*"
Files.Filter = "Audio Files (*.amr,*.mid,*.wav,*.mp3)|*.amr;*.mid;*.wav;*.mp3"
Files.Filename = ""
Files.ShowOpen
theData = Files.Filename
sTitle = VBA.Left$(Files.FileTitle, Len(Files.FileTitle) - 4)
If theData <> "" Then
theKey = "f0" & lvwFilesAdded.ListItems.Count + 1 'generate a unique key for this file
'If (clsStega.BytesAdded + FileLen(Files.Filename)) > DemoLimit Then
' MsgBox "Demo version is limit to 1000 bytes", , "Image Copyright Protector"
' Exit Sub 'End If
If clsStega.AddFile(theData, sTitle, theKey) Then 'if was added... continue
End Sub
Private Sub cmdBack_Click() cmdNext.Enabled = True cmdFinish.Enabled = False If currentStep >= 0 Then
frStep(currentStep).Visible = False currentStep = currentStep - 1 lbStep = vSteps(currentStep)
If currentStep < 0 Then currentStep = 0 frStep(currentStep).Visible = True
If currentStep = 0 Then cmdBack.Enabled = False
frStep(currentStep).Visible = False currentStep = currentStep + 1 lbStep = vSteps(currentStep) frStep(currentStep).Visible = True If currentStep >= MAX_STEPS Then
If currentStep = 2 Then cmdNext.Enabled = True 'encryp step
If currentStep = 3 Then cmdNext.Enabled = True 'encryp step
Set ItSel = lvwFilesAdded.SelectedItem If Not ItSel Is Nothing Then
clsStega.RemoveFile ItSel.Key
lbRema = "Remaining Bytes: " & clsStega.BytesTotal - clsStega.BytesAdded lvwFilesAdded.ListItems.Remove ItSel.Index
End If
If lvwFilesAdded.ListItems.Count = 0 Then cmdNext.Enabled = False End Sub
Private Sub cmdSee_Click()
'Shell "explorer " & Files.Filename Form2.Show vbModal
End Sub
Private Sub cmdTarget_Click()
Dim ToW&, ToH&, InW&, InH&, mPad&
mPad = 2
Files.Filter = "Bitmap (*.bmp)|*.bmp"
Files.ShowOpen
strImageFile = Files.Filename File = strImageFile
If strImageFile <> "" And VBA.Right$(strImageFile, 4) = ".bmp" Then TheImage.Picture = LoadPicture(strImageFile)
clsStega.ImageFile = strImageFile clsStegaRead.ImageFile = strImageFile
lbImgName = "Name: " & Files.FileTitle lbImgSize = "Size: " & clsStega.ImgSize
'calculate the size the image to adjust in screen
MsgBox "Error: Gambar tidak support", vbCritical, "Bad image"
End If End Sub
Private Sub Form_Load()
Move (MDIForm1.ScaleWidth - Width) \ 2, (MDIForm1.ScaleHeight - Height) \ 2 Set clsStega = New ClsStegano
Set clsStegaRead = New ClsStegano
currentStep = 0
'DemoLimit = 1000 '1000bytes
'If bPurchase Then DemoLimit = 2147483647 'unlimited DemoLimit = 2147483647
'for future use
'vHex = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", " E", " F")
'vBin = Array("0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010",
"1011", "1100", "1101", " 1110", " 1111")
m_Millimeter = ScaleX(100, vbPixels, vbMillimeters) 'fill the name for each step process
vSteps = Array("Langkah 1: Pilih Gambar", "Langkah 2: Mengecek Gambar", "Step 3: Pilih File Yang Ingin Dimasukkan", "Step 4: Isi Kata Sandi", "Step 5: Proses Menggabungkan 2 File", "Selesai: File Berhasil Disisipkan")
End Sub
Private Sub Form_Unload(Cancel As Integer) Dim It As ListItem
If currentStep >= MAX_STEPS Then 'proccess done, delete tmp files For Each It In lvwFilesAdded.ListItems
Kill clsStega(It.Key).Filename
Private Sub HS_Scroll()
Private Sub OpAlgoId_Click(Index As Integer) clsStega.HashAlgorithm = Index
End Sub
Private Sub OpEncAlgo_Click(Index As Integer) clsStega.EncryptionAlgorithm = Index End Sub
Private Sub Timer1_Timer() If j < 100 Then
j = j + 1
OsenXPProgressBar1.Value = j
ElseIf OsenXPProgressBar1.Value = 100 Then Timer1.Enabled = False
TheImage.Move TheImage.Left, -VS.Value End Sub
Private Sub VS_Scroll()
TheImage.Move TheImage.Left, -VS.Value End Sub
Untuk menampilkan Menu Ekstrak File
Option Explicit
Dim strImageFile$ 'the main image where the files was attached Dim m_Millimeter&
Dim vSteps
Const MAX_STEPS = 2 Dim currentStep&
Dim imgIco%
Dim WithEvents clsStegaRead As ClsStegano 'the magic class
Private Sub clsStegaRead_SomeError(strDescription As String) MsgBox strDescription, , "Image Copyright Protector"
End Sub
Private Sub clsStegaRead_StatusChanged(prcDone As Long, strStatus As String)
lbStatus = strStatus End Sub
Private Sub cmdBack_Click() cmdNext.Enabled = True cmdFinish.Enabled = False If currentStep >= 0 Then
frStep(currentStep).Visible = False currentStep = currentStep - 1 lbStep = vSteps(currentStep)
If currentStep < 0 Then currentStep = 0
frStep(currentStep).Visible = True
If currentStep = 0 Then cmdBack.Enabled = False
If txtLock.Visible = True And Len(Trim(txtLock)) = 0 Then
MsgBox "Password is empty!", vbExclamation, "Image Copyright Protector"
txtLock.SetFocus
Close OutFile
MsgBox Err.Description, , "Image Copyright Protector"
End Sub
frStep(currentStep).Visible = False currentStep = currentStep + 1 lbStep = vSteps(currentStep)
cmdBack.Enabled = False
Dim ToW&, ToH&, InW&, InH&, mPad&
mPad = 2
Files.Filter = "Bitmap (*.bmp)|*.bmp"
Files.ShowOpen
strImageFile = Files.Filename
If strImageFile <> "" And VBA.Right$(strImageFile, 4) = ".bmp" Then TheImage.Picture = LoadPicture(strImageFile)
clsStegaRead.ImageFile = strImageFile
lbImgName = "Name: " & Files.FileTitle
ToW = Me.ScaleWidth - mPad - mPad
MsgBox "Error: trying to add unsupport image", vbCritical, "Bad image"
End If End Sub
Private Sub Form_Load() currentStep = 0 'for futture use
'vHex = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", " E", " F")
'vBin = Array("0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010",
"1011", "1100", "1101", " 1110", " 1111") Set clsStegaRead = New ClsStegano
m_Millimeter = ScaleX(100, vbPixels, vbMillimeters)
vSteps = Array("Langkah 1: Pilih Gambar Terwatermark", "Langkah 2: Mengekstrak File dari Gambar",
"Langkah 3: Pilih File yang akan Diekstrak", "Selesai: File Berhasil Diekstrak")
End Sub
Private Sub Form_Unload(Cancel As Integer) Dim It As ListItem
For Each It In lvwFilesAdded.ListItems Kill clsStegaRead(It.Key).Filename Next
Private Sub VS_Scroll()
TheImage.Move TheImage.Left, -VS.Value End Sub
Untuk Menampilkan Pemutar Audio
Private Sub Form_Load() End Sub
Private Sub WindowsMediaPlayer1_OpenStateChange(ByVal NewState As Long) End Sub
Modul Dan Class Modul
Karena aplikasi ini dibuat dengan menggunakan modul,maka source code di atas tidak lengkap apabila tidak menyertakan pula modulnya. Untuk source code modulnya adalah sebagai berikut :
Modul
Option Explicit
Public bPurchase As Boolean
Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
'Public Enum TypeFileEncode 'file header, total 14 bytes Type winBMPFileHeader
strFileType As String * 2 ' file type always 4D42h or "BM"
lngFileSize As Long 'size in bytes ussually 0 for uncompressed bytReserved1 As Integer ' always 0
bytReserved2 As Integer ' always 0
lngBitmapOffset As Long 'starting position of image data in bytes End Type
'image header, total 40 bytes Type BITMAPINFOHEADER
biYPelsPerMeter As Long 'preferred resolution in pixels per meter biClrUsed As Long 'number of colors that are actually used (can be 0) biClrImportant As Long 'which color is most important (0 means all of them) End Type
Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As msg, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long Declare Function TranslateMessage Lib "user32" (lpMsg As msg) As Long
Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As msg) As Long Public Const PM_REMOVE = &H1 'paramater on peekmessage to remove or leave message in queue
'myDoEvents() 43% more faster than Vb-DoEvents Public Function myDoEvents() As Boolean
If PeekMessage(Message, 0, 0, 0, PM_REMOVE) Then 'checks for a message in the queue and removes it if there is one
TranslateMessage Message 'translates the message(dont need if there is no menu)
Function AscChar(ByVal MyMot As String) As String
If TmpMot = VBA.Space(Len(TmpMot)) Then TmpMot = ""
AscChar = TmpMot End Function
'Function String2Binary(theStr As String, RetArray() As tBits, olbStatus As Label, ProgBar As ProgressBar) 'Dim I&, hexRes$, LenBy&
'Dim arrHexStr() As String, arrHexBy() As Byte, BinRes() As tBits '
' Convert2BinaryArray arrHexBy(), BinRes(), olbStatus, ProgBar '
' End If ' Next I 'Bin2Hex = Res 'End Function
Function Bin2Asc(Bin As tBits) As Integer Dim num As Integer
Function ByteToBinary(ByVal Data As Byte) As tBits Dim tmpBit As tBits
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal wNewWord As Long) As Long
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Const GWL_EXSTYLE = (-20) Public Const WS_EX_LAYERED = &H80000 Public Const LWA_ALPHA = &H2
Public Function TranslucentForm(frm As Form, TranslucenceLevel As Byte) As Boolean SetWindowLong frm.hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes frm.hwnd, 0, TranslucenceLevel, LWA_ALPHA TranslucentForm = Err.LastDllError = 0
End Function
Public Function MakeTransparent(ByVal hwnd As Long, Perc As Integer) As Long Dim msg As Long
Else
msg = GetWindowLong(hwnd, GWL_EXSTYLE) msg = msg Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, msg
SetLayeredWindowAttributes hwnd, 0, Perc, LWA_ALPHA MakeTransparent = 0
Private Const SC_MAXIMIZE As Long = &HF030&
Private Const xSC_MAXIMIZE As Long = -11&
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const hWnd_NOTOPMOST = -2 Private Const SWP_NOZORDER = &H4 Private Const SWP_NOSIZE = &H1 Private Const SWP_NOMOVE = &H2
Private Const SWP_FRAMECHANGED = &H20
Private Const MIIM_STATE As Long = &H1&
Private Const MIIM_ID As Long = &H2&
Private Const MFS_GRAYED As Long = &H3&
Private Const WM_NCACTIVATE As Long = &H86
Private Type MENUITEMINFO
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Long Private Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'*******************************************************************************
' Enable / Disable Maximise Button
'---
Public Sub EnableMaxButton(ByVal hwnd As Long, Enable As Boolean) Dim lngFormStyle As Long
' Enable / Disable System Menu Item
EnableSystemMenuItem hwnd, SC_MAXIMIZE, xSC_MAXIMIZE, Enable, "EnableMaxButton"
' Enable / Disable TitleBar button
lngFormStyle = GetWindowLong(hwnd, GWL_STYLE) If Enable Then
lngFormStyle = lngFormStyle Or WS_MAXIMIZEBOX Else
lngFormStyle = lngFormStyle And Not WS_MAXIMIZEBOX End If
SetWindowLong hwnd, GWL_STYLE, lngFormStyle
' Dirty, slimy, devious hack to ensure that the changes to the ' window's style take immediate effect before the form is shown
SetParent hwnd, GetParent(hwnd)
SetWindowPos hwnd, hWnd_NOTOPMOST, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_FRAMECHANGED
End Sub
Private Sub EnableSystemMenuItem(hwnd As Long, Item As Long, Dummy As Long, Enable As Boolean, FuncName As String)
Dim hMenu As Long
Dim MII As MENUITEMINFO Dim lngMenuID As Long
If IsWindow(hwnd) = 0 Then
Err.Raise vbObjectError, "modCloseBtn::" & FuncName, _
' Retrieve a handle to the window's system menu hMenu = GetSystemMenu(hwnd, 0)
' Retrieve the menu item information for the Max menu item/button MII.cbSize = Len(MII)
If GetMenuItemInfo(hMenu, MII.wID, False, MII) = 0 Then Err.Raise vbObjectError, "modCloseBtn::" & FuncName, _ "modCloseBtn::" & FuncName & "() - Menu Item Not Found"
If SetMenuItemInfo(hMenu, lngMenuID, False, MII) = 0 Then Err.Raise vbObjectError, "modCloseBtn::" & FuncName, _ "modCloseBtn::" & FuncName & "() - Error encountered " & _
If SetMenuItemInfo(hMenu, MII.wID, False, MII) = 0 Then Err.Raise vbObjectError, "modCloseBtn::" & FuncName, _ "modCloseBtn::" & FuncName & "() - Error encountered " & _ "changing state"
Exit Sub End If
SendMessage hwnd, WM_NCACTIVATE, True, 0 End Sub
urr