Analisis dan Implementasi Anti Watermarking untuk Memperbaiki Kualitas Citra Digital Dengan Menggunakan Metode Image Averaging

A-1

LISTING PROGRAM
1. Form Home
using
using
using
using

System;
System.Collections.Generic;
System.Drawing;
System.Windows.Forms;

namespace KhalidaZia121401018
{
///
/// Description of MainForm.
///
public partial class MainForm : Form
{

public MainForm()
{
//
// The InitializeComponent() call is required for Windows
Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the
InitializeComponent() call.
//
}
void ImplementationToolStripMenuItemClick(object sender, EventAr
gs e)
{
FormImplementation fi = new FormImplementation();
fi.ShowDialog();
}
void HelpToolStripMenuItemClick(object sender, EventArgs e)
{

FormHelp fh = new FormHelp();
fh.ShowDialog();
}
void AboutToolStripMenuItemClick(object sender, EventArgs e)
{
FormAbout fa = new FormAbout();
fa.ShowDialog();
}

Universitas Sumatera Utara

A-2

}
}

2. Form Implementation

using
using

using
using
using
using

System;
System.Drawing;
System.Windows.Forms;
System.Drawing.Imaging;
System.Diagnostics;
System.Runtime.InteropServices;

namespace KhalidaZia121401018
{
///
/// Description of FormImplementation.
///
public partial class FormImplementation : Form
{
public FormImplementation()

{
//
// The InitializeComponent() call is required for Windows
Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the
InitializeComponent() call.
//
}
void GroupBox2Enter(object sender, EventArgs e)
{
}
void Button1Click(object sender, EventArgs e)
{
try
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Image Files( *.bmp) | *.bmp";

if (open.ShowDialog() == DialogResult.OK)

Universitas Sumatera Utara

A-3

{
Bitmap bit = new Bitmap(open.FileName);
if (bit.Height = 350 )
{
pictureBox1.Image = bit;
textBox1.Text = open.SafeFileName.ToString();
textBox2.Text = bit.Width.ToString();
textBox3.Text = bit.Height.ToString();
}
else
MessageBox.Show("Image Pixel must be least 350 x
350 px and max 500 x 500 px", "Warning");
}
}

catch (Exception)
{
throw new ApplicationException("Failed loading image");
}
}
void Button2Click(object sender, EventArgs e)
{
pictureBox1.Image = null;
pictureBox3.Image = null;
pictureBox4.Image = null;
pictureBox5.Image = null;
pictureBox6.Image = null;
textBox1.Text="";
textBox2.Text="";
textBox3.Text="";
textBox7.Text="";
textBox8.Text="";
textBox9.Text="";
textBox10.Text="";
textBox11.Text="";

textBox12.Text="";
}
Bitmap average5x5(Bitmap image)
{

Universitas Sumatera Utara

A-4

int iw
int ih
double
=0, hasilblue=0;
double
Bitmap

= image.Width;
= image.Height;
red, green, blue, hasilred =0, hasilgreen
redfix, greenfix, bluefix;

imagehasil = new Bitmap(iw, ih);

for(int i = 0; i