/// <summary> /// Crops the image by the specified width/height /// </summary> /// <param name="Width">The width.</param> /// <param name="Height">The height.</param> /// <param name="VAlignment">The v alignment.</param> /// <param name="HAlignment">The h alignment.</param> /// <returns></returns> public SwiftBitmap Crop(int Width, int Height, Align VAlignment, Align HAlignment) { Contract.Requires <NullReferenceException>(InternalBitmap != null); Unlock(); var TempRectangle = new System.Drawing.Rectangle(); TempRectangle.Height = Height; TempRectangle.Width = Width; TempRectangle.Y = VAlignment == Align.Top ? 0 : this.Height - Height; if (TempRectangle.Y < 0) { TempRectangle.Y = 0; } TempRectangle.X = HAlignment == Align.Left ? 0 : this.Width - Width; if (TempRectangle.X < 0) { TempRectangle.X = 0; } var TempHolder = InternalBitmap.Clone(TempRectangle, InternalBitmap.PixelFormat); InternalBitmap.Dispose(); InternalBitmap = TempHolder; this.Width = Width; this.Height = Height; return(this); }
protected override void CommitBuffer() { var dst = InternalBitmap.Clone(i => { i.ApplyProcessor(new BlackWhiteProcessor()); }); dst.Save(_imagePath); }
private void AcquireDevice() { var dst = InternalBitmap.Clone(i => { i.ApplyProcessor(new BlackWhiteProcessor()); }); dst.Save(_imagePath); }
/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns>A new object that is a copy of this instance.</returns> public object Clone() { Unlock(); return(new SwiftBitmap((Bitmap)InternalBitmap.Clone())); }