private void UpdateBitmap(ThreadSafeBitmap bitmap, WriteableBitmapHolder holder, Image image) { if (holder == null || bitmap == null) { return; } var changed = false; bitmap.Access(bitmapData => changed = holder.WritePixels(bitmap.Width, bitmap.Height, bitmapData)); if (changed) { image.Source = holder.Bitmap; } }
/// <summary> /// Updates the source of given image. /// </summary> /// <param name="bitmap">Bitmap</param> /// <param name="holder">Bitmap holder</param> /// <param name="image">Image from statickinect window.</param> private void UpdateBitmap(ThreadSafeBitmap bitmap, WriteableBitmapHolder holder, Image image) { if (holder == null || bitmap == null) { return; } var changed = false; // Can not be interrupted by other threads. WritePixels returns true if the bitmap is changed. bitmap.Access(bitmapData => changed = holder.WritePixels(bitmap.Width, bitmap.Height, bitmapData)); // If bitmap is changed updates the source of the image. if (changed) { image.Source = holder.Bitmap; } }