public void Process(MagickWand wand, double percent) { var currentImage = wand.CurrentImage; var height = currentImage.Height; using (var draw = new DrawingWand()) { using (PixelWand pixel = new PixelWand()) { var endX = currentImage.Width - 1; var endY = height - 1; pixel.Color = "black"; pixel.Opacity = 0.4; draw.FillColor = pixel; draw.DrawRectangle(0, endY - IndicatorHeight, endX, endY); double foregroundWidth = endX; foregroundWidth *= percent; foregroundWidth /= 100; pixel.Color = "#52B54B"; pixel.Opacity = 0; draw.FillColor = pixel; draw.DrawRectangle(0, endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), endY); wand.CurrentImage.DrawImage(draw); } } }
public async Task DrawPlayedIndicator(MagickWand wand, ImageSize imageSize) { var x = imageSize.Width - OffsetFromTopRightCorner; using (var draw = new DrawingWand()) { using (PixelWand pixel = new PixelWand()) { pixel.Color = "#52B54B"; pixel.Opacity = 0.2; draw.FillColor = pixel; draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20); pixel.Opacity = 0; pixel.Color = "white"; draw.FillColor = pixel; draw.Font = await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf", _appPaths, _iHttpClient, _fileSystem).ConfigureAwait(false); draw.FontSize = FontSize; draw.FontStyle = FontStyleType.NormalStyle; draw.TextAlignment = TextAlignType.CenterAlign; draw.FontWeight = FontWeightType.RegularStyle; draw.TextAntialias = true; draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a"); draw.FillColor = pixel; wand.CurrentImage.DrawImage(draw); } } }
/// <summary> A MagickWand extension method that draw circle. </summary> /// <param name="wand"> The wand to act on. </param> /// <param name="ox"> The ox. </param> /// <param name="oy"> The oy. </param> /// <param name="px"> The px. </param> /// <param name="py"> The py. </param> /// <param name="strokeColor"> The stroke color. </param> /// <param name="fillcolor"> The fillcolor. </param> internal static void DrawCircle(this ImageWand wand, double ox, double oy, double px, double py, PixelWand strokeColor, PixelWand fillcolor) { using (var draw = new DrawingWand()) { draw.StrokeColor = strokeColor; draw.FillColor = fillcolor; draw.DrawCircle(ox, oy, px, py); wand.DrawImage(draw); } }
/// <summary> A MagickWand extension method that draw rectangle. </summary> /// <param name="wand"> The wand to act on. </param> /// <param name="x1"> The first x value. </param> /// <param name="y1"> The first y value. </param> /// <param name="x2"> The second x value. </param> /// <param name="y2"> The second y value. </param> /// <param name="strokeColor"> The stroke color. </param> /// <param name="fillcolor"> The fillcolor. </param> internal static void DrawRectangle(this ImageWand wand, double x1, double y1, double x2, double y2, PixelWand strokeColor, PixelWand fillcolor) { using (var draw = new DrawingWand()) { draw.StrokeColor = strokeColor; draw.FillColor = fillcolor; draw.DrawRectangle(x1, y1, x2, y2); wand.DrawImage(draw); } }
/// <summary> A MagickWand extension method that draw circle. </summary> /// <param name="wand"> The wand to act on. </param> /// <param name="x"> The x coordinate. </param> /// <param name="y"> The y coordinate. </param> /// <param name="p"> The double to process. </param> /// <param name="strokeColor"> The stroke color. </param> /// <param name="fillcolor"> The fillcolor. </param> internal static void DrawCircle(this ImageWand wand, double x, double y, double p, PixelWand strokeColor, PixelWand fillcolor) { using (var draw = new DrawingWand()) { draw.StrokeColor = strokeColor; draw.FillColor = fillcolor; draw.DrawCircle(x + p, y + p, x + p, y + p * 2); wand.DrawImage(draw); } }
public void DrawUnplayedCountIndicator(MagickWand wand, ImageSize imageSize, int count) { var x = imageSize.Width - OffsetFromTopRightCorner; var text = count.ToString(CultureInfo.InvariantCulture); using (var draw = new DrawingWand()) { using (PixelWand pixel = new PixelWand()) { pixel.Color = "#52B54B"; pixel.Opacity = 0.2; draw.FillColor = pixel; draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20); pixel.Opacity = 0; pixel.Color = "white"; draw.FillColor = pixel; draw.Font = PlayedIndicatorDrawer.ExtractFont("robotoregular.ttf", _appPaths, _fileSystem); draw.FontStyle = FontStyleType.NormalStyle; draw.TextAlignment = TextAlignType.CenterAlign; draw.FontWeight = FontWeightType.RegularStyle; draw.TextAntialias = true; var fontSize = 30; var y = OffsetFromTopRightCorner + 11; if (text.Length == 1) { x += 1; } else if (text.Length == 2) { x += 1; } else if (text.Length >= 3) { //x += 1; y -= 2; fontSize = 24; } draw.FontSize = fontSize; draw.DrawAnnotation(x, y, text); draw.FillColor = pixel; wand.CurrentImage.DrawImage(draw); } } }
/// <summary> Round corners. </summary> /// <param name="wand"> The wand to act on. </param> /// <param name="cofactor"> The cofactor. </param> /// <returns> A MagickWand. </returns> public static MagickWand RoundCorners(this MagickWand wand, Double cofactor) { var currentWidth = wand.CurrentImage.Width; var currentHeight = wand.CurrentImage.Height; var newWand = new MagickWand(currentWidth, currentHeight, new PixelWand(ColorName.None, 1)); using (var whitePixelWand = new PixelWand(ColorName.White)) using (var draw = new DrawingWand(whitePixelWand)) { draw.DrawRoundRectangle(0, 0, currentWidth, currentHeight, cofactor, cofactor); newWand.CurrentImage.DrawImage(draw); newWand.CurrentImage.CompositeImage(wand, CompositeOperator.SrcInCompositeOp, 0, 0); return newWand; } }
public void DrawingWandCircleTest() { using (var wand = new MagickWand(TestImageBackdrop)) { //wand.NewImage(400, 200, new PixelWand("white")); //wand.OpenImage(TestImageBackdrop); using (var draw = new DrawingWand()) { using (PixelWand pixel = new PixelWand()) { pixel.Color = "red"; draw.StrokeColor = pixel; pixel.Color = "black"; pixel.Opacity = 0.3; draw.FillColor = pixel; draw.DrawCircle(400, 400, 300, 300); pixel.Color = "transparent"; draw.StrokeColor = pixel; pixel.Color = "white"; draw.FillColor = pixel; draw.Font = "Verdana"; draw.FontSize = 120; draw.FontStyle = FontStyleType.NormalStyle; draw.TextAlignment = TextAlignType.LeftAlign; draw.FontWeight = FontWeightType.BoldStyle; draw.TextAntialias = true; draw.DrawAnnotation(10, 100, "Media Browser"); draw.FillColor = pixel; wand.CurrentImage.DrawImage(draw); } } //Debug.WriteLine(wand.GetNumberImages()); //wand.Image.TrimImage(10); wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg")); } }
/// <summary> A MagickWand extension method that cover art stack. </summary> /// <param name="wand"> The wand. </param> /// <param name="xIncrement"> Amount to increment by. </param> /// <param name="yIncrement"> Amount to increment by. </param> /// <param name="width"> The width. </param> /// <param name="height"> The height. </param> /// <param name="images"> A variable-length parameters list containing images. </param> private static void CoverArtStack(this MagickWand wand, double xIncrement, double yIncrement, double width, double height, params string[] images) { using (var draw = new DrawingWand()) { double x = 0; double y = 0; using (var wandimages = new MagickWand(images)) { foreach (ImageWand imageWand in wandimages.ImageList) { using (var blackPixelWand = new PixelWand("black")) { imageWand.BorderImage(blackPixelWand, 2, 2); draw.DrawComposite(CompositeOperator.AtopCompositeOp, x, y, width, height, imageWand); x += xIncrement; y += yIncrement; } } } wand.CurrentImage.DrawImage(draw); } }
public void DrawingWandAnnotationTest() { //using (var wand = new MagickWand(TestImageBackdrop)) using (var wand = new MagickWand(400, 100, "#ffffff")) { //wand.NewImage(400, 200, new PixelWand("white")); //wand.OpenImage(TestImageBackdrop); using (var draw = new DrawingWand()) { using (PixelWand pixel = new PixelWand("black")) { draw.FillColor = pixel; draw.Font = "Arial"; draw.FontSize = 20; draw.FontStyle = FontStyleType.NormalStyle; draw.TextAlignment = TextAlignType.LeftAlign; draw.FontWeight = FontWeightType.BoldStyle; draw.TextAntialias = true; draw.DrawAnnotation(0, 20, "Media Browser"); draw.BorderColor = new PixelWand("red"); //draw.Font = "Times-New-Roman"; //pixel.Color = "Red"; //pixel.Opacity = 0.8; //draw.FillColor = pixel; //draw.DrawAnnotation(60, 120, "Tavares"); Debug.WriteLine(draw); wand.CurrentImage.DrawImage(draw); } } //Debug.WriteLine(wand.GetNumberImages()); //wand.Image.TrimImage(10); wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg")); } }
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.TextInterlineSpacing(Spacing);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.StrokeWidth(Width);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.PathSmoothCurveToAbs(_controlPoint, _end);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.StrokeOpacity((double)Opacity / 100);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.Color(X, Y, PaintMethod);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.StrokePatternUrl(Url);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.PathQuadraticCurveToAbs(_controlPoint, _end);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.PathSmoothQuadraticCurveToAbs(_end);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.FillColor(Color);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.Arc(StartX, StartY, EndX, EndY, StartDegrees, EndDegrees);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.Alpha(X, Y, PaintMethod);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.Viewbox(UpperLeftX, UpperLeftY, LowerRightX, LowerRightY);
internal static MagickWand MediaBrowserPosterCollectionImageWithText(MagickWand wandImages, string label, string font) { int width = 600; int height = 900; var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); using (var draw = new DrawingWand()) { using (var fcolor = new PixelWand(ColorName.White)) { draw.FillColor = fcolor; draw.Font = font; draw.FontSize = 60; draw.FontWeight = FontWeightType.LightStyle; draw.TextAntialias = true; } var fontMetrics = wand.QueryFontMetrics(draw, label); var textContainerY = Convert.ToInt32(height * .145); wand.CurrentImage.AnnotateImage(draw, (width - fontMetrics.TextWidth) / 2, textContainerY, 0.0, label); var iSlice = Convert.ToInt32(width * 0.225); int iTrans = Convert.ToInt32(height * 0.2); int iHeight = Convert.ToInt32(height * 0.48296296296296296296296296296296); var horizontalImagePadding = Convert.ToInt32(width * 0.0275); foreach (var element in wandImages.ImageList) { using (var nonePixelWand = new PixelWand("none", 1)) { int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height); element.Gravity = GravityType.CenterGravity; element.BackgroundColor = nonePixelWand; element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter); int ix = (int)Math.Abs((iWidth - iSlice) / 2); element.CropImage(iSlice, iHeight, ix, 0); element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0); } } wandImages.SetFirstIterator(); using (var wandList = wandImages.AppendImages()) { wandList.CurrentImage.TrimImage(1); using (var mwr = wandList.CloneMagickWand()) using (var blackPixelWand = new PixelWand(ColorName.Black)) using (var greyPixelWand = new PixelWand(ColorName.Grey60)) { mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1); mwr.CurrentImage.FlipImage(); mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel; mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand); using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans)) { mwg.OpenImage("gradient:black-none"); var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111); mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.DstInCompositeOp, 0, verticalSpacing); wandList.AddImage(mwr); int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2; wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * 0.24851851851851851851851851851852)); } } } } return wand; }
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.Circle(OriginX, OriginY, PerimeterX, PerimeterY);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.Composite(X, Y, Width, Height, Compose, _image);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.ClipRule(FillRule);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.Line(StartX, StartY, EndX, EndY);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.PathMoveToAbs(_coordinate.X, _coordinate.Y);
internal static MagickWand MediaBrowserPosterCollectionImage(MagickWand wandImages) { int width = 600; int height = 900; var wand = new MagickWand(width, height); wand.OpenImage("gradient:#000000-#202020"); using (var draw = new DrawingWand()) { var iSlice = Convert.ToInt32(width * 0.225); int iTrans = Convert.ToInt32(height * .25); int iHeight = Convert.ToInt32(height * .65); var horizontalImagePadding = Convert.ToInt32(width * 0.0275); foreach (var element in wandImages.ImageList) { using (var blackPixelWand = new PixelWand(ColorName.Black)) { int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height); element.Gravity = GravityType.CenterGravity; element.BackgroundColor = blackPixelWand; element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter); int ix = (int)Math.Abs((iWidth - iSlice) / 2); element.CropImage(iSlice, iHeight, ix, 0); element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0); } } wandImages.SetFirstIterator(); using (var wandList = wandImages.AppendImages()) using (var blackPixelWand = new PixelWand(ColorName.Black)) using (var greyPixelWand = new PixelWand(ColorName.Grey70)) { wandList.CurrentImage.TrimImage(1); using (var mwr = wandList.CloneMagickWand()) { mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1); mwr.CurrentImage.FlipImage(); mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel; mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand); using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans)) { mwg.OpenImage("gradient:black-none"); var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111); mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.CopyOpacityCompositeOp, 0, verticalSpacing); wandList.AddImage(mwr); int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2; wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * .05)); } } } } return wand; }
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.StrokeDashArray(_dash);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.PathLineToVerticalRel(Y);
private MagickWand BuildThumbCollageWandWithText(List <string> paths, string text, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 8); using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); using (var draw = new DrawingWand()) { using (var fcolor = new PixelWand(ColorName.White)) { draw.FillColor = fcolor; draw.Font = MontserratLightFont; draw.FontSize = 60; draw.FontWeight = FontWeightType.LightStyle; draw.TextAntialias = true; } var fontMetrics = wand.QueryFontMetrics(draw, text); var textContainerY = Convert.ToInt32(height * .165); wand.CurrentImage.AnnotateImage(draw, (width - fontMetrics.TextWidth) / 2, textContainerY, 0.0, text); var iSlice = Convert.ToInt32(width * .1166666667); int iTrans = Convert.ToInt32(height * 0.2); int iHeight = Convert.ToInt32(height * 0.46296296296296296296296296296296); var horizontalImagePadding = Convert.ToInt32(width * 0.0125); foreach (var element in wandImages.ImageList) { int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height); element.Gravity = GravityType.CenterGravity; element.BackgroundColor = new PixelWand("none", 1); element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter); int ix = (int)Math.Abs((iWidth - iSlice) / 2); element.CropImage(iSlice, iHeight, ix, 0); element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0); } wandImages.SetFirstIterator(); using (var wandList = wandImages.AppendImages()) { wandList.CurrentImage.TrimImage(1); using (var mwr = wandList.CloneMagickWand()) { using (var blackPixelWand = new PixelWand(ColorName.Black)) { using (var greyPixelWand = new PixelWand(ColorName.Grey70)) { mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1); mwr.CurrentImage.FlipImage(); mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel; mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand); using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans)) { mwg.OpenImage("gradient:black-none"); var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111); mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.DstInCompositeOp, 0, verticalSpacing); wandList.AddImage(mwr); int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2; wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * 0.26851851851851851851851851851852)); } } } } } } return(wand); } }
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.PopPattern();
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.TextKerning(Kerning);
private MagickWand BuildSquareCollageWand(List <string> paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 3); using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); using (var draw = new DrawingWand()) { var iSlice = Convert.ToInt32(width * .32); int iTrans = Convert.ToInt32(height * .25); int iHeight = Convert.ToInt32(height * .68); var horizontalImagePadding = Convert.ToInt32(width * 0.02); foreach (var element in wandImages.ImageList) { using (var blackPixelWand = new PixelWand(ColorName.Black)) { int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height); element.Gravity = GravityType.CenterGravity; element.BackgroundColor = blackPixelWand; element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter); int ix = (int)Math.Abs((iWidth - iSlice) / 2); element.CropImage(iSlice, iHeight, ix, 0); element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0); } } wandImages.SetFirstIterator(); using (var wandList = wandImages.AppendImages()) { wandList.CurrentImage.TrimImage(1); using (var mwr = wandList.CloneMagickWand()) { using (var blackPixelWand = new PixelWand(ColorName.Black)) { using (var greyPixelWand = new PixelWand(ColorName.Grey70)) { mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1); mwr.CurrentImage.FlipImage(); mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel; mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand); using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans)) { mwg.OpenImage("gradient:black-none"); var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111); mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.CopyOpacityCompositeOp, 0, verticalSpacing); wandList.AddImage(mwr); int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2; wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * .03)); } } } } } } return(wand); } }
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.Point(X, Y);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.SkewY(Angle);
private MagickWand BuildThumbCollageWandWithText(List<string> paths, string text, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 8); using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); using (var draw = new DrawingWand()) { using (var fcolor = new PixelWand(ColorName.White)) { draw.FillColor = fcolor; draw.Font = MontserratLightFont; draw.FontSize = 60; draw.FontWeight = FontWeightType.LightStyle; draw.TextAntialias = true; } var fontMetrics = wand.QueryFontMetrics(draw, text); var textContainerY = Convert.ToInt32(height * .165); wand.CurrentImage.AnnotateImage(draw, (width - fontMetrics.TextWidth) / 2, textContainerY, 0.0, text); var iSlice = Convert.ToInt32(width * .1166666667); int iTrans = Convert.ToInt32(height * 0.2); int iHeight = Convert.ToInt32(height * 0.46296296296296296296296296296296); var horizontalImagePadding = Convert.ToInt32(width * 0.0125); foreach (var element in wandImages.ImageList) { int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height); element.Gravity = GravityType.CenterGravity; element.BackgroundColor = new PixelWand("none", 1); element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter); int ix = (int)Math.Abs((iWidth - iSlice) / 2); element.CropImage(iSlice, iHeight, ix, 0); element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0); } wandImages.SetFirstIterator(); using (var wandList = wandImages.AppendImages()) { wandList.CurrentImage.TrimImage(1); using (var mwr = wandList.CloneMagickWand()) { using (var blackPixelWand = new PixelWand(ColorName.Black)) { using (var greyPixelWand = new PixelWand(ColorName.Grey70)) { mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1); mwr.CurrentImage.FlipImage(); mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel; mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand); using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans)) { mwg.OpenImage("gradient:black-none"); var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111); mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.DstInCompositeOp, 0, verticalSpacing); wandList.AddImage(mwr); int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2; wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * 0.26851851851851851851851851851852)); } } } } } } return wand; } }
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.ClipPath(ClipPath);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.PushGraphicContext();
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.TextDecoration(Decoration);
/// <summary> A MagickWand extension method that overlay image. </summary> /// <param name="wand"> The wand to act on. </param> /// <param name="compose"> The compose. </param> /// <param name="x"> The x coordinate. </param> /// <param name="y"> The y coordinate. </param> /// <param name="width"> The width. </param> /// <param name="height"> The height. </param> /// <param name="magickwand"> The magickwand. </param> internal static void OverlayImage(this ImageWand wand, CompositeOperator compose, double x, double y, double width, double height, MagickWand magickwand) { using (var draw = new DrawingWand()) { draw.DrawComposite(compose, x, y, width, height, magickwand.CurrentImage); wand.DrawImage(draw); } }
private MagickWand BuildSquareCollageWand(List<string> paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 3); using (var wandImages = new MagickWand(inputPaths.ToArray())) { var wand = new MagickWand(width, height); wand.OpenImage("gradient:#111111-#111111"); using (var draw = new DrawingWand()) { var iSlice = Convert.ToInt32(width * .3); int iTrans = Convert.ToInt32(height * .25); int iHeight = Convert.ToInt32(height * .63); var horizontalImagePadding = Convert.ToInt32(width * 0.02); foreach (var element in wandImages.ImageList) { using (var blackPixelWand = new PixelWand(ColorName.Black)) { int iWidth = (int)Math.Abs(iHeight * element.Width / element.Height); element.Gravity = GravityType.CenterGravity; element.BackgroundColor = blackPixelWand; element.ResizeImage(iWidth, iHeight, FilterTypes.LanczosFilter); int ix = (int)Math.Abs((iWidth - iSlice) / 2); element.CropImage(iSlice, iHeight, ix, 0); element.ExtentImage(iSlice, iHeight, 0 - horizontalImagePadding, 0); } } wandImages.SetFirstIterator(); using (var wandList = wandImages.AppendImages()) { wandList.CurrentImage.TrimImage(1); using (var mwr = wandList.CloneMagickWand()) { using (var blackPixelWand = new PixelWand(ColorName.Black)) { using (var greyPixelWand = new PixelWand(ColorName.Grey70)) { mwr.CurrentImage.ResizeImage(wandList.CurrentImage.Width, (wandList.CurrentImage.Height / 2), FilterTypes.LanczosFilter, 1); mwr.CurrentImage.FlipImage(); mwr.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel; mwr.CurrentImage.ColorizeImage(blackPixelWand, greyPixelWand); using (var mwg = new MagickWand(wandList.CurrentImage.Width, iTrans)) { mwg.OpenImage("gradient:black-none"); var verticalSpacing = Convert.ToInt32(height * 0.01111111111111111111111111111111); mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.CopyOpacityCompositeOp, 0, verticalSpacing); wandList.AddImage(mwr); int ex = (int)(wand.CurrentImage.Width - mwg.CurrentImage.Width) / 2; wand.CurrentImage.CompositeImage(wandList.AppendImages(true), CompositeOperator.AtopCompositeOp, ex, Convert.ToInt32(height * .07)); } } } } } } return wand; } }
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.PathCurveToRel(_controlPointStart, _controlPointEnd, _end);
/// <summary> /// Draws this instance with the drawing wand. /// </summary> /// <param name="wand">The want to draw on.</param> void IDrawingWand.Draw(DrawingWand wand) => wand?.TextAlignment(Alignment);
/// <summary> A MagickWand extension method that draw text. </summary> /// <param name="wand"> The wand to act on. </param> /// <param name="text"> The text. </param> /// <param name="x"> The x coordinate. </param> /// <param name="y"> The y coordinate. </param> /// <param name="fontName"> Name of the font. </param> /// <param name="fontSize"> Size of the font. </param> /// <param name="fontColor"> The font color. </param> /// <param name="fontWeight"> The font weight. </param> internal static void DrawText(this ImageWand wand, string text, double x, double y, string fontName, double fontSize, PixelWand fontColor, FontWeightType fontWeight) { using (var draw = new DrawingWand()) { using (fontColor) { draw.FillColor = fontColor; draw.Font = fontName; draw.FontSize = fontSize; draw.FontWeight = fontWeight; draw.TextAntialias = true; draw.DrawAnnotation(x, y, text); wand.DrawImage(draw); } } }