private void button4_Click(object sender, EventArgs e) { if (openFileDialog2.ShowDialog() == DialogResult.OK) { f = new Fractal(); FileStream fs = (FileStream)openFileDialog2.OpenFile(); f.import(FractalFile.readFromFile(fs)); fs.Close(); MessageBox.Show("Import successed!!"); return; } MessageBox.Show("Import failed!!"); }
private void findMatch(out FractalFile file) { file = new FractalFile(R.GetLength(0), R.GetLength(1)); double Rcount = 0; double Rsize = R.GetLength(1) * R.GetLength(0); for (int j = 0; j < R.GetLength(1); j++) { for (int i = 0; i < R.GetLength(0); i++) { Rcount++; if (monitor != null) { monitor.OnValueChanged(new ValueEventArgs() { value = Rcount / Rsize }); } // refer R double md = Double.PositiveInfinity; int x = 0, y = 0, t = 0; double s = 1.0, o = 0; for (int Dr = 0; Dr < D.GetLength(1); Dr++) { for (int Dc = 0; Dc < D.GetLength(0); Dc++) { if (EncodeDraw && (viewer != null) && (VG != null)) { matchDraw(i, j, Dc, Dr); } //compare D for (int tt = 0; tt < 8; tt++) { double ts, to; double distance = BlockImage.mse(R[i, j], D[Dc, Dr][tt], out ts, out to); if (md > distance) { md = distance; x = Dc; y = Dr; t = tt; s = ts; o = to; } } } } file.pairs[i, j] = new FractalData(x, y, t, s, o); } } }
private void saveFile(bool noUse) { if (saver != null) {//save compress file if (saver.ShowDialog() == DialogResult.OK) { // If the file name is not an empty string open it for saving. if (saver.FileName != "") { FileStream fs = (FileStream)saver.OpenFile(); FractalFile.writeToFile(fs, file); fs.Close(); } } } activeFrom.tableLayoutPanel1.Enabled = true; }
public static void writeToFile(Stream fs, FractalFile myff) {// write myct to fs BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, myff); }
public void import(FractalFile file) { this.file = file; }