Perbandingan Algoritma Elias Delta Codes Dengan Levenstein Code Dalam Kompresi Citra .Gif

A-1
LISTING PROGRAM

1. Form Menu Utama
using
using
using
using

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

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

public MainForm()
{
//
// The InitializeComponent() call is required for Windows
Forms designer support.
//
InitializeComponent();
}
void KOMPRESIToolStripMenuItemClick(object sender, EventArgs e)
{
Kompresi k = new Kompresi();
k.Show();
this.Hide();
}
void DEKOMPRESIToolStripMenuItemClick(object sender, EventArgs e)
{
Dekompresi k = new Dekompresi();
k.Show();
this.Hide();
}

void ABOUTToolStripMenuItem1Click(object sender, EventArgs e)
{
About k = new About();
k.Show();
this.Hide();
}
void ABOUTToolStripMenuItemClick(object sender, EventArgs e)
{
Help k = new Help();
k.Show();
this.Hide();
}
}
}

Universitas Sumatera Utara

A-2

2. Form Kompresi

namespace KompresiCitra
{
///
/// Description of Kompresi.
///
public partial class Kompresi : Form
{
Image file;
Bitmap bmp;
double fileLength;
Color p;
List ch = new List();
List hs = new List();
List hs2 = new List();
public static String[] edc;
public static String[] lv;
int[] fr;
int width,height,proses;
public Kompresi()
{

//
// The InitializeComponent() call is required for Windows
Forms designer support.
//
InitializeComponent();
}
void Button1Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "GIF ( *.gif)|*.gif| BITMAP ( *.bmp)|*.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
string metode =
open.FileName.Substring(open.FileName.Length-3, 3);
if(metode == "bmp"){
file = Image.FromFile(open.FileName);
bmp = new Bitmap(open.FileName);
pictureBox1.Image = file;
textBox1.Text = open.FileName;
textBox2.Text = bmp.Height.ToString() + " x

" +bmp.Width.ToString();
width = bmp.Width;
height = bmp.Height;
fileLength
= new FileInfo(open.FileName).Length * 1.0 /1024;
textBox3.Text = fileLength.ToString()+" kb";
}
else if(metode == "gif")
{
byte[] ir = File.ReadAllBytes(open.FileName);
Image i = Image.FromStream(new MemoryStream(ir));
bmp = new Bitmap(new Bitmap(i));

Universitas Sumatera Utara

A-3
pictureBox1.Image = bmp;
textBox1.Text = open.FileName;
textBox2.Text = bmp.Height.ToString() + " x
" +bmp.Width.ToString();

width = bmp.Width;
height = bmp.Height;
fileLength
= new FileInfo(open.FileName).Length * 1.0 /1024;
textBox3.Text = fileLength.ToString()+" kb";
}
}
}
bool cek(int x)
{
for(int i=0; i