/* * private ArrayList paint() * { * return null; * } * * public Hashtable GenerateTestImages(Bitmap inImage) * { * return null; * } * */ #region IPainter Members private void StatusUpdater(object state) { StatusManager.Instance.SetTaskPercentCompletion(this.GetHashCode(), NativeMomentPainterWrapper.GetPaitingPercentComplete()); while (renderingInProgress) { Thread.Sleep(100); StatusManager.Instance.SetTaskPercentCompletion(this.GetHashCode(), NativeMomentPainterWrapper.GetPaitingPercentComplete()); } StatusManager.Instance.SetTaskPercentCompletion(this.GetHashCode(), 100); }
protected override Bitmap CreatePainting() { /* * 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(new Bitmap(original))); } try { using (UnsafeBitmap unsafeBrush = new UnsafeBitmap(new Bitmap(Properties.Resources.brush1))) { using (UnsafeBitmap unsafePainting = NativeMomentPainterWrapper.GenerateSegmentedCompositePainting(width, height, unsafeOriginals.ToArray(), BrushCollection.Instance.AvailableBrushes, this.windowSize)) { unsafePainting.UnlockBitmap(); return(new Bitmap(unsafePainting.Bitmap)); } } } finally { //renderingInProgress = false; // We're done with the unsafe originals, free them up foreach (UnsafeBitmap unsafeOriginal in unsafeOriginals) { unsafeOriginal.Dispose(); } // The originals were disposed of when the unsafe wrappers were // disposed of. So, simply null out this collection. this.originals = null; } }
private Bitmap CreatePaintingWithLocations(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(new Bitmap(original))); } try { using (UnsafeBitmap unsafeBrush = new UnsafeBitmap((Bitmap)Properties.Resources.brush1.Clone())) { using (UnsafeBitmap unsafePainting = NativeMomentPainterWrapper.GenerateCompositePainting(width, height, unsafeOriginals.ToArray(), locations, BrushCollection.Instance.AvailableBrushes, this.windowSize)) { unsafePainting.UnlockBitmap(); return(new Bitmap(unsafePainting.Bitmap)); } } } finally { renderingInProgress = false; // We're done with the unsafe originals, free them up foreach (UnsafeBitmap unsafeOriginal in unsafeOriginals) { unsafeOriginal.Dispose(); } } }