Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Drawing text

$
0
0
Hi,

I'm trying to draw text onto a transparent image and then crop the image to the text's bounding box. I have the following code (please see below) but (a) I'm specifying the image size which I'd like to avoid as I wont know the text size in advance and (b) I'm not cropping the image although the area I'm interested in is represented by the (bounding) box. Any help would be greatly appreciated.
Using image As New MagickImage(System.Drawing.Color.Transparent, 500, 150)
   image.Format = MagickFormat.Png
   Dim font As New DrawableFont("Arial")
   Dim pointSize As New DrawablePointSize(50)
   Dim fillColor As New DrawableFillColor(System.Drawing.Color.Black)
   Dim strokeColor As New DrawableStrokeColor(System.Drawing.Color.Red)
   Dim strokeWidth As New DrawableStrokeWidth(1)
   Dim strokeAntialias As New DrawableStrokeAntialias(True)
   Dim textAntialias As New DrawableTextAntialias(True)
   Dim text As New DrawableText(10, 100, "Hello World")
   Dim params() As ImageMagick.Drawable = {font, pointSize, strokeColor, fillColor, strokeWidth, strokeAntialias, textAntialias, text}
   image.Draw(params)
   Dim box As ImageMagick.MagickGeometry = image.BoundingBox
   image.Write("helloworld.png")
End Using
Thanks

Viewing all articles
Browse latest Browse all 3693

Trending Articles