B-16
return maukirim;
} void
pesanInformasi string
pesan {
MessageBox .Showpesan,
Informasi ,
MessageBoxButtons .OK,
MessageBoxIcon .Information,
MessageBoxDefaultButton .Button1;
}
void pesanKesalahan
string pesan
{ MessageBox
.Showpesan, Kesalahan
, MessageBoxButtons
.OK, MessageBoxIcon
.Warning, MessageBoxDefaultButton
.Button1; }
private void
pengungkapan_FormClosed object
sender, FormClosedEventArgs
e {
} }
}
4. Form Hitung Mean Squared Error MSE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Threading;
namespace TA_091401006_alespanjaitan
{ public
partial class
hitungmse :
Form {
hitungMseClass mse =
new hitungMseClass
; public
hitungmse {
InitializeComponent; }
private void
hitungmse_Load object
sender, EventArgs
e {
CenterToParent; }
private void
bt_bukagbr1_Click object
sender, EventArgs
e {
OpenFileDialog bukagbr =
new OpenFileDialog
;
Universitas Sumatera Utara
B-17
bukagbr.InitialDirectory = ;
bukagbr.Filter = Format Bitmap .bmp|.bmp|Format
JPEG.jpg|.jpg ;
bukagbr.FilterIndex = 1; bukagbr.RestoreDirectory =
true ;
if DialogResult
.OK == bukagbr.ShowDialog {
Bitmap gb =
new Bitmap
bukagbr.FileName; gbr1.Image = gb;
label3.Text = perolehnamabukagbr.FileName+ \n
+ gb.Size.Width+
\n + gb.Size.Height;
} }
private void
bt_bukagbr2_Click object
sender, EventArgs
e {
OpenFileDialog bukagbr =
new OpenFileDialog
; bukagbr.InitialDirectory =
; bukagbr.Filter =
Format Bitmap .bmp|.bmp|Format JPEG.jpg|.jpg
; bukagbr.FilterIndex = 1;
bukagbr.RestoreDirectory = true
; if
DialogResult .OK == bukagbr.ShowDialog
{ Bitmap
gb = new
Bitmap bukagbr.FileName;
gbr2.Image = gb; label6.Text = perolehnamabukagbr.FileName +
\n +
gb.Size.Width + \n
+ gb.Size.Height; }
} private
void button1_Click
object sender,
EventArgs e
{ try
{ Cursor
.Current = Cursors
.WaitCursor; Bitmap
datagb1 = new
Bitmap gbr1.Image;
Bitmap datagb2 =
new Bitmap
gbr2.Image; if
datagb1.Width == datagb2.Width datagb1.Height == datagb2.Height
{ label7.Text = mse.hitungdatagb1,
datagb2.ToString; MessageBox
.Show Compare Selesai
, Informasi
, MessageBoxButtons
.OK, MessageBoxIcon
.Information, MessageBoxDefaultButton
.Button1; }
else {
MessageBox .Show
Pastikan resolusi gambar anda sama
, Informasi
, MessageBoxButtons
.OK, MessageBoxIcon
.Information, MessageBoxDefaultButton
.Button1; }
} catch
{ MessageBox
.Show Ada Kesalahan
;
Universitas Sumatera Utara
B-18
} finally
{ Cursor
.Current = Cursors
.Default; }
} string
perolehnama string
param {
string temp;
temp = ;
for int
i = param.Length-1; i = 0; i-- {
if param[i] = 92
{ temp = param[i] + temp;
} else
{ break
; }
} return
temp; }
private void
gbr2_Click object
sender, EventArgs
e {
} }
}
5. Form Menggunakan Aplikasi