/// <inheritdoc/> public System.IO.Stream CombineImages(System.IO.Stream sourceImageStream, System.IO.Stream detailImageStream, Rect detailImageRect, double angle = 0) { #region validation if (sourceImageStream == null) { throw new ArgumentNullException(nameof(sourceImageStream)); } if (detailImageStream == null) { throw new ArgumentNullException(nameof(detailImageStream)); } #endregion using Image <Rgba32> sourceImage = LoadImageFromStream <Rgba32>(sourceImageStream, out IImageFormat imageFormat); using Image <Rgba32> detailImage = LoadImageFromStream <Rgba32>(angle != 0 ? RotateImage(detailImageStream, angle) : detailImageStream, out IImageFormat detailImageFormat); var detailImagePosition = new SixLabors.ImageSharp.Point(0, 0); if (detailImageRect != null) { Size detailImageSize = new Size(detailImageRect.Width, detailImageRect.Height); detailImage.Mutate(x => x.Resize(detailImageSize)); detailImagePosition = new SixLabors.ImageSharp.Point(detailImageRect.X, detailImageRect.Y); } sourceImage.Mutate(x => x.DrawImage(detailImage, detailImagePosition, 1.0f)); return(SaveAsStream(sourceImage, imageFormat)); }
private Image <Rgba32> generatePicture(Direction direction, Image <Rgba32> currentImage, Image <Rgba32> nextImage) { int height = LEDPIProcessorBase.LEDHeight; int width = LEDPIProcessorBase.LEDWidth; SixLabors.ImageSharp.Point pointCurrentImage; SixLabors.ImageSharp.Point pointNextImage; if (direction == Direction.Down || direction == Direction.Up) { if (direction == Direction.Down) { pointCurrentImage = new SixLabors.ImageSharp.Point(0, 0); pointNextImage = new SixLabors.ImageSharp.Point(0, LEDPIProcessorBase.LEDHeight); } else { pointNextImage = new SixLabors.ImageSharp.Point(0, 0); pointCurrentImage = new SixLabors.ImageSharp.Point(0, LEDPIProcessorBase.LEDHeight); } height *= 2; } else { if (direction == Direction.Left) { pointCurrentImage = new SixLabors.ImageSharp.Point(0, 0); pointNextImage = new SixLabors.ImageSharp.Point(LEDPIProcessorBase.LEDWidth, 0); } else { pointNextImage = new SixLabors.ImageSharp.Point(0, 0); pointCurrentImage = new SixLabors.ImageSharp.Point(LEDPIProcessorBase.LEDWidth, 0); } width *= 2; } Image <Rgba32> wholeImage = new Image <Rgba32>(width, height); wholeImage.Mutate(c => c.DrawImage(currentImage, pointCurrentImage, 1).DrawImage(nextImage, pointNextImage, 1)); return(wholeImage); }