private static void WriteLabelAndBoundingBox(IMagickImage outputImage, int imageHeight, string text, double[] bb, string drawColor) { DrawableStrokeColor strokeColor = new DrawableStrokeColor(new MagickColor(drawColor)); DrawableStrokeWidth strokeWidth = new DrawableStrokeWidth(3); DrawableFillColor fillColor = new DrawableFillColor(new MagickColor(50, 50, 50, 128)); DrawableRectangle dr = new DrawableRectangle(bb[0], bb[1], bb[4], bb[5]); DrawableText dt = new DrawableText(bb[0], bb[1], text); outputImage.Draw(strokeColor, strokeWidth, fillColor, dr, dt); }
public static string AddTextToImage(string imageFile, string text) { var image = new MagickImage(imageFile); using (var imgText = new MagickImage()) { var drawable = new DrawableText(0, 10, text); var gravity = new DrawableGravity(Gravity.North); var font = new DrawableFont("Arial"); var antialias = new DrawableTextAntialias(true); var size = new DrawableFontPointSize(50); var color = new DrawableFillColor(Color.Snow); var strokeColor = new DrawableStrokeColor(Color.OrangeRed); image.Draw(drawable, gravity, font, antialias, size, color, strokeColor); } // Save the result string outputImage = TempFolder + "\\waterMark_" + Path.GetFileName(imageFile); image.Write(outputImage); return(outputImage); }
public void Stamp(ThumbnailSheetCreateRequest request, string filePath, TimeSpan time) { var stampText = time.ToString(request.VideoDurationInSeconds >= 3600 ? @"hh\:mm\:ss" : @"mm\:ss"); var tempFilePath = filePath + ".tmp.png"; using (var imgText = new MagickImage(filePath)) { var drawable = new DrawableText(5, 5, stampText); var gravity = new DrawableGravity(Gravity.Southeast); var font = new DrawableFont("Tahoma"); var antialias = new DrawableTextAntialias(true); var size = new DrawableFontPointSize(48); var color = new DrawableFillColor(MagickColors.Black); var strokecolor = new DrawableStrokeColor(MagickColors.AliceBlue); imgText.Draw(drawable, gravity, font, antialias, size, color, strokecolor); imgText.Write(tempFilePath); } File.Delete(filePath); File.Move(tempFilePath, filePath); }
public void Test_Constructor_Color() { DrawableStrokeColor strokeColor = new DrawableStrokeColor(Color.GhostWhite); ColorAssert.AreEqual(MagickColors.GhostWhite, strokeColor.Color); }
public void Constructor_WithColor_ColorPropertyIsCorrect() { DrawableStrokeColor strokeColor = new DrawableStrokeColor(Color.GhostWhite); ColorAssert.AreEqual(MagickColors.GhostWhite, strokeColor.Color); }
public void ShouldSetTheProperties() { DrawableStrokeColor strokeColor = new DrawableStrokeColor(Color.GhostWhite); ColorAssert.AreEqual(MagickColors.GhostWhite, strokeColor.Color); }