public Image RenderImage(ILUT lut) { bool render = false; if (_bitmap == null) { System.Drawing.Imaging.PixelFormat format = Components == 4 ? System.Drawing.Imaging.PixelFormat.Format32bppArgb : System.Drawing.Imaging.PixelFormat.Format32bppRgb; _pixels = new PinnedIntArray(ScaledData.Width * ScaledData.Height); _bitmap = new Bitmap(ScaledData.Width, ScaledData.Height, ScaledData.Width * 4, format, _pixels.Pointer); render = true; } if (_applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); render = true; } _bitmap.RotateFlip(RotateFlipType.RotateNoneFlipNone); if (render) { ScaledData.Render((_applyLut ? lut : null), _pixels.Data); } _bitmap.RotateFlip(GetRotateFlipType()); return(_bitmap); }
public BitmapSource RenderImageSource(ILUT lut) { bool render = false; if (_applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); render = true; } if (_bitmapSource == null || render) { _pixels = new PinnedIntArray(ScaledData.Width * ScaledData.Height); ScaledData.Render((_applyLut ? lut : null), _pixels.Data); _bitmapSource = RenderBitmapSource(ScaledData.Width, ScaledData.Height, _pixels.Data); } if (_rotation != 0 || _flipX || _flipY) { TransformGroup rotFlipTransform = new TransformGroup(); rotFlipTransform.Children.Add(new RotateTransform(_rotation)); rotFlipTransform.Children.Add(new ScaleTransform(_flipX ? -1 : 1, _flipY ? -1 : 1)); _bitmapSource = new TransformedBitmap(_bitmapSource, rotFlipTransform); } return(_bitmapSource); }
public BitmapSource RenderImageSource(ILUT lut) { bool render = false; if (_bitmap == null) { _pixels = new PinnedIntArray(ScaledData.Width * ScaledData.Height); _bitmap = new WriteableBitmap(ScaledData.Width, ScaledData.Height); render = true; } if (_applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); render = true; } if (render) { ScaledData.Render((_applyLut ? lut : null), _pixels.Data); } MultiThread.For(0, _pixels.Count, delegate(int i) { _bitmap.Pixels[i] = _pixels.Data[i]; }); _bitmap.Rotate(_rotation); if (_flipX) { _bitmap.Flip(WriteableBitmapExtensions.FlipMode.Horizontal); } if (_flipY) { _bitmap.Flip(WriteableBitmapExtensions.FlipMode.Vertical); } _bitmap.Invalidate(); return(_bitmap); }
public BitmapSource RenderImageSource(ILUT lut) { var render = false; if (_bitmap == null) { _pixels = new PinnedIntArray(ScaledData.Width * ScaledData.Height); _bitmap = BitmapFactory.New(ScaledData.Width, ScaledData.Height); render = true; } if (_applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); render = true; } if (render) { ScaledData.Render((_applyLut ? lut : null), _pixels.Data); foreach (var overlay in _overlays) { overlay.Render(_pixels.Data, ScaledData.Width, ScaledData.Height); } } using (var context = _bitmap.GetBitmapContext()) { Array.Copy(_pixels.Data, context.Pixels, _pixels.Count); _bitmap.Rotate(_rotation); if (_flipX) { _bitmap.Flip(WriteableBitmapExtensions.FlipMode.Horizontal); } if (_flipY) { _bitmap.Flip(WriteableBitmapExtensions.FlipMode.Vertical); } } return(_bitmap); }
public BitmapSource RenderImageSource(ILUT lut) { var render = false; if (_bitmap == null) { _pixels = new PinnedIntArray(ScaledData.Width * ScaledData.Height); render = true; } if (_applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); render = true; } if (render) { ScaledData.Render((_applyLut ? lut : null), _pixels.Data); foreach (var overlay in _overlays) { overlay.Render(_pixels.Data, ScaledData.Width, ScaledData.Height); } } using ( var context = new CGBitmapContext(_pixels, ScaledWidth, ScaledHeight, 8, 4 * ScaledWidth, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedLast)) { var transform = CGAffineTransform.MakeRotation((float)(_rotation * Math.PI / 180.0)); transform.Scale(_flipX ? -1.0f : 1.0f, _flipY ? -1.0f : 1.0f); transform.Translate(_flipX ? ScaledWidth : 0.0f, _flipY ? ScaledHeight : 0.0f); context.ConcatCTM(transform); _bitmap = context.ToImage(); } return(_bitmap); }
/// <inheritdoc /> public IImage RenderImage(ILUT lut) { if (_applyLut && lut != null && !lut.IsValid) { lut.Recalculate(); } var image = ImageManager.CreateImage(ScaledWidth, ScaledHeight); var pixels = image.Pixels.Data; ScaledData.Render(_applyLut ? lut : null, pixels); foreach (var overlay in _overlays) { overlay.Render(pixels, ScaledWidth, ScaledHeight); } image.Render(Components, _flipX, _flipY, _rotation); return(image); }