Perbandingan Algoritma Alternate Reverse Unary Codes dan Algoritma Run-Length Encoding(RLE) pada Kompresi Citra.JPG

A-2

LISTING PROGRAM
1.

Main Form

using
using
using
using

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

namespace Skripsi
{
///
/// 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 KOMPRESIToolStripMenuItemClick(object sender, E
ventArgs e)
{
Kompresi k = new Kompresi();
k.Show();

this.Hide();
}
void DEKOMPRESIToolStripMenuItemClick(object sender,
EventArgs e)
{
Dekompresi k = new Dekompresi();
k.Show();
this.Hide();
}
void Label1Click(object sender, EventArgs e)
{
}
void Label4Click(object sender, EventArgs e)
{

Universitas Sumatera Utara

A-2

}

void Label2Click(object sender, EventArgs e)
{
}
}
}

2.

Form Kompresi

using
using
using
using
using
using
using

System;
System.Collections.Generic;

System.Diagnostics;
System.Drawing;
System.IO;
System.Text;
System.Windows.Forms;

namespace Skripsi
{
///
/// Description of Kompresi.
///
public partial class Kompresi : Form
{
public Kompresi()
{
//
// The InitializeComponent() call is required
for Windows Forms designer support.
//
InitializeComponent();

//
// TODO: Add constructor code after the
InitializeComponent() call.
//
}
Image file;
Bitmap bmp;
long fileLength;
Color p;
List ch1 = new List();
List ch2 = new List();
List ch3 = new List();
List hs1 = new List();
List hs2 = new List();
List hs3 = new List();

Universitas Sumatera Utara

A-2


List ch4 = new List();
List hs4 = new List();
List ch5 = new List();
List hs5 = new List();
List ch6 = new List();
List hs6 = new List();
public static String[] aruc1;
public static String[] aruc2;
public static String[] aruc3;
int[] fr1, fr2, fr3;
int width,height,sss;
void Button1Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "JPEG ( *.jpg)|*.jpg|BITMAP
(*.bmp)|*.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
file = Image.FromFile(open.FileName);
bmp = new Bitmap(open.FileName);

pictureBox1.Image = file;
textBox1.Text = open.FileName;
width = bmp.Width;
height = bmp.Height;
fileLength
= new FileInfo(open.FileName).Length;
}
}
bool cek1(int x)
{
for(int i=0; i