private void Compress(Bitmap bitmap, int bigDelta, int a, String filepath) { //try{ Console.WriteLine("bmp size: {0}x{1}, bigDelta={2}, a={3}", bitmap.Width, bitmap.Height, bigDelta, a); FractalCompression.Structure.Region[,] regions = null; FractalCompression.Structure.Domain[,] domains = null; List<MappedPoint> intrpList = null; POTools.PrepareStructures(bitmap, bigDelta, a, out regions, out domains, out intrpList); Compressor compressor = new Compressor(bigDelta, a,Properties.Settings.Default.eps, 3, domains, regions, intrpList, bitmap); Console.WriteLine("Compression started..."); compressor.Compress(); Console.WriteLine("Image compressed, saving to file..."); compressor.SaveToFile(filepath); }
/*private void ComputeInterpolationPointsTest0(Bitmap bitmap, int domainsInRow, int a) { Console.WriteLine("bmp size: {0}x{1}", bitmap.Width, bitmap.Height); List<MappedPoint> intrpList = POTools.ComputeInterpolationPoints(bitmap, domainsInRow, a); Console.WriteLine("interpolation points: " + intrpList.Count); Console.WriteLine(); for (int i = 0; i < intrpList.Count; i++) { Console.Write("({0},{1}), ", intrpList[i].X, intrpList[i].Y); //Console.Write(intrpList[i].X + ", " + intrpList[i].Y + "; "); if ((i + 1) % 4 == 0) Console.WriteLine(); } }*/ //nie jest uzywana, zostala podzielona na dwie funckje, Compress i Decompress // private Bitmap CompressionTest(Bitmap bitmap, int bigDelta, int a) { Console.WriteLine("bmp size: {0}x{1}, bigDelta={2}, a={3}", bitmap.Width, bitmap.Height, bigDelta, a); FractalCompression.Structure.Region[,] regions = null; FractalCompression.Structure.Domain[,] domains = null; List<MappedPoint> intrpList = null; //List<MappedPoint> intrpList = POTools.PrepareRegions(bitmap, bigDelta, a, out regions); POTools.PrepareStructures(bitmap, bigDelta, a, out regions, out domains, out intrpList); //POTools.PrintInterpolationPoints(intrpList); //POTools.PrintDomains(domains); //POTools.PrintRegions(regions); string filepath = @"C:\Documents and Settings\Mroczek\Pulpit\myfile.nofc"; Compressor compressor = new Compressor(bigDelta, a, 10, 3, domains, regions, intrpList, bitmap); Console.WriteLine("Compression started..."); compressor.Compress(); Console.WriteLine("Image compressed, saving to file..."); compressor.SaveToFile(filepath); Console.WriteLine("Reading file before decompression..."); CompResult cr = POTools.DeserializeCompResult(filepath); Console.WriteLine("Preparing to decompression..."); List<double> cfactors = new List<double>(cr.Cqueue); List<MappedPoint> interpPoints = new List<MappedPoint>(cr.Iqueue); List<int> addresses = new List<int>(cr.Aqueue); Decompressor decompressor = new Decompressor(cfactors, interpPoints, addresses, cr.SmallDelta, cr.BigDelta, cr.A, cr.ImageWidth, cr.ImageHeight, cr.DMax); Console.WriteLine("Decompressing image..."); return decompressor.DecompressImage(out bitmapWithGrid); }