private ArrayList paintFast3(Bitmap inImage, int winSize) { StatusManager.Instance.StatusMessage("Starting paint, version: Fast 3"); ArrayList strokes = StrokeAreaGenerator.GeneratePaintingStrokes(new UnsafeBitmap(inImage), winSize); strokes.Sort(); StatusManager.Instance.StatusMessage("Total strokes generated: " + strokes.Count); return(strokes); }
/* * private ArrayList paintFast1(Bitmap inImage, int winSize) * { * int S; * ArrayList list = null; * int count; * int factor, size, level; * * S = winSize; * * // Unmanaged calculation of stroke area image * DateTime startAnalysis = DateTime.Now; * Color[] colors = StrokeAreaGenerator.GenerateFast1(new UnsafeBitmap(inImage), S); * * ColorImage areaImg = new ColorImage(inImage.Width, inImage.Height); * for (int y = 0; y < inImage.Height; y++) * for (int x = 0; x < inImage.Width; x++) * areaImg.singledata[y * inImage.Width + x] = colors[y * inImage.Width + x]; * // End unmanaged calculation * * TimeSpan durationAnalysis = DateTime.Now - startAnalysis; * StatusReporter.Instance.StatusMessage("Analysis duration: " + durationAnalysis.TotalMilliseconds + "ms"); * * //StatusReporter.Instance.SubmitWorkingImage(ImageTools.GenWorkingImage(areaImg)); * * count = 0; * list = new ArrayList(); * * factor = 1; * level = 1; * size = System.Math.Max(inImage.Width, inImage.Height); * DateTime startStrokeGen = DateTime.Now; * while (size > 4 * S) * { * System.Console.WriteLine("Processing level " + factor); * count += GenerateStrokesWithRawScaling(inImage, areaImg, list, S, factor, level); * size /= 2; * factor *= 2; * level++; * } * TimeSpan durationStrokeGen = DateTime.Now - startStrokeGen; * StatusReporter.Instance.StatusMessage("Stroke generation duration: " + durationStrokeGen.TotalMilliseconds + "ms"); * * list.Sort(); * * return list; * } */ private ArrayList paintFast2(Bitmap inImage, int winSize) { int S; ArrayList list = null; int count; int factor, size, level; S = winSize; // Unmanaged calculation of stroke area image DateTime startAnalysis = DateTime.Now; Color[] colors = StrokeAreaGenerator.GenerateFast2(new UnsafeBitmap(inImage), S); ColorImage areaImg = new ColorImage(inImage.Width, inImage.Height); for (int y = 0; y < inImage.Height; y++) { for (int x = 0; x < inImage.Width; x++) { areaImg.singledata[y * inImage.Width + x] = colors[y * inImage.Width + x]; } } // End unmanaged calculation TimeSpan durationAnalysis = DateTime.Now - startAnalysis; StatusManager.Instance.StatusMessage("Analysis duration: " + durationAnalysis.TotalMilliseconds + "ms"); //StatusReporter.Instance.SubmitWorkingImage(ImageTools.GenWorkingImage(areaImg)); count = 0; list = new ArrayList(); factor = 1; level = 1; size = System.Math.Max(inImage.Width, inImage.Height); DateTime startStrokeGen = DateTime.Now; while (size > 4 * S) { count += GenerateStrokesWithRawScaling(inImage, areaImg, list, S, factor, level); size /= 2; factor *= 2; level++; } TimeSpan durationStrokeGen = DateTime.Now - startStrokeGen; StatusManager.Instance.StatusMessage("Stroke generation duration: " + durationStrokeGen.TotalMilliseconds + "ms"); list.Sort(); return(list); }
private void StatusUpdater(object state) { StatusManager.Instance.SetTaskPercentCompletion(this.GetHashCode(), StrokeAreaGenerator.GetPaitingPercentComplete()); while (renderingInProgress) { Thread.Sleep(300); StatusManager.Instance.SetTaskPercentCompletion(this.GetHashCode(), StrokeAreaGenerator.GetPaitingPercentComplete()); } StatusManager.Instance.SetTaskPercentCompletion(this.GetHashCode(), 100); }
public Bitmap CreatePainting(Bitmap originalImage) { using (UnsafeBitmap unsafeOriginal = new UnsafeBitmap(originalImage)) { using (UnsafeBitmap unsafeBrush = new UnsafeBitmap(Properties.Resources.brush1)) { using (UnsafeBitmap unsafePainting = StrokeAreaGenerator.GeneratePainting(unsafeOriginal, unsafeBrush, this.windowSize)) { unsafePainting.UnlockBitmap(); Bitmap finalPainting = new Bitmap(unsafePainting.Bitmap); return(finalPainting); } } } }
public Bitmap CreatePainting(int width, int height, Bitmap[] originals, Point[] locations) { renderingInProgress = true; ThreadPool.QueueUserWorkItem(new WaitCallback(StatusUpdater)); // Transform the original images to the fast and unsafe bitmaps we require List <UnsafeBitmap> unsafeOriginals = new List <UnsafeBitmap>(); foreach (Bitmap original in originals) { unsafeOriginals.Add(new UnsafeBitmap(original)); } try { using (UnsafeBitmap unsafeBrush = new UnsafeBitmap(Properties.Resources.brush1)) { using (UnsafeBitmap unsafePainting = StrokeAreaGenerator.GenerateCompositePainting(width, height, unsafeOriginals.ToArray(), locations, BrushCollection.Instance.AvailableBrushes, this.windowSize)) { unsafePainting.UnlockBitmap(); Bitmap finalPainting = new Bitmap(unsafePainting.Bitmap); return(finalPainting); } } } finally { renderingInProgress = false; // We're done with the unsafe originals, free them up foreach (UnsafeBitmap unsafeOriginal in unsafeOriginals) { unsafeOriginal.Dispose(); } } }
public Hashtable GenerateTestImages(Bitmap inImage) { return(StrokeAreaGenerator.GenerateTestImages(new UnsafeBitmap(inImage), new UnsafeBitmap(Properties.Resources.brush1), this.windowSize)); }