'''' This code is part of Document Solutions for Imaging demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystemImportsSystem.IOImportsSystem.DrawingImportsSystem.Collections.GenericImportsSystem.LinqImportsSystem.NumericsImportsGrapeCity.Documents.DrawingImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.ImagingImports GCTEXT = GrapeCity.Documents.TextImports GCDRAW = GrapeCity.Documents.Drawing '' This sample demonstrates how to create a Glow effect using DsImaging.'' The Glow effect inflates all non-transparent areas of an image by a specified amount,'' then applies a Gaussian blur to make the border smooth. It is one of the effects'' that are found in MS Word for example.'' '' To achieve this effect in DsImaging, the GrayscaleBitmap.ApplyGlow() method is used'' on the transparency mask built from the color image on which we want the glow to appear,'' along with a few other simple steps as illustrated by this code.'''' This example shows how to achieve the glow effect without drawing the content'' (text and image) twice. See @{Glow} for an alternative way to achieve the same effect.PublicClassGlowAltPrivate_fontAsGCTEXT.Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "FreeSans.ttf")) PublicFunctionGenerateImage(ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsGcBitmap '' Draw text and logo on a transparent bitmap:Using bmpTemp AsNewGcBitmap(pixelSize.Width, pixelSize.Height, False) bmpTemp.Clear(Color.Transparent) Dim renderer = bmpTemp.EnsureRendererCreated()DrawText(renderer, pixelSize, dpi)DrawLogo(renderer, NewPointF(pixelSize.Width / 2, CInt(pixelSize.Height * 0.8)), pixelSize.Width / 2) '' Convert the image to a transparency mask:Using gs = bmpTemp.ToGrayscaleBitmap(ColorChannel.Alpha) '' Apply the Glow effect; for Glow the inflation radius is positive (6), blur radius is 9: gs.ApplyGlow(6, 9) '' Map a shadow from the transparency mask to a new bitmap,'' drawing opaque pixels with glow color (Yellow) and some additional transparency:Dim bmp = gs.ToShadowBitmap(Color.Yellow, 0.8F) '' Draw the text and logo over the glow. bmp.AlphaBlend(bmpTemp, 0, 0) '' Fill the background: bmp.ConvertToOpaque(Color.Gray) '' DoneReturn bmpEndUsingEndUsingEndFunction PrivateSubDrawText(ByVal renderer AsBitmapRenderer, ByVal pixelSize AsSize, ByVal dpi AsSingle)Dim f1 = NewTextFormatWith { .Font = _font, .FontSize = pixelSize.Height / 7, .ForeColor = Color.DarkOrchid, .FontBold = True }Dim f2 = NewTextFormat(f1) With { .ForeColor = Color.White, .StrokePen = NewGCDRAW.Pen(Color.DarkOrchid, 3) }Dim tl = NewTextLayout(dpi) With { .MaxWidth = pixelSize.Width, .MaxHeight = pixelSize.Height, .ParagraphAlignment = ParagraphAlignment.Near, .TextAlignment = TextAlignment.Center, .MarginTop = dpi * 2, .LineSpacingScaleFactor = 0.7F } tl.AppendLine("Document", f1) tl.AppendLine("Solutions", f2) '' Draw the text: renderer.SlowAntialiasing = True renderer.DrawTextLayout(tl, 0, 0)EndSub PrivateSubDrawLogo(ByVal renderer AsBitmapRenderer, ByVal center AsPointF, ByVal width AsSingle)Dim pb = NewPathBuilder() pb.BeginFigure(100, 350) pb.AddLine(210, 310)Dim arc = NewArcSegmentWith { .Size = NewSizeF(183, 173), .SweepDirection = SweepDirection.Clockwise, .Point = NewPointF(550, 205) } pb.AddArc(arc) pb.AddLine(650, 170) pb.AddLine(680, 250) pb.AddLine(575, 285) arc.Point = NewPointF(240, 390) pb.AddArc(arc) pb.AddLine(130, 430) pb.EndFigure(True) pb.Figures.Add(NewEllipticFigure(NewRectangleF(295, 197, 200, 190)))Dim gpFill = pb.ToPath()Dim gpStroke = gpFill.Widen(NewGCDRAW.Pen(Color.Black, 20)) '' Our 'base' size is 800 x 600 pixels:Dim scale AsSingle = width / 800 renderer.Transform = Matrix3x2.CreateScale(scale) *Matrix3x2.CreateTranslation(center.X - 400 * scale, center.Y - 300 * scale) renderer.FillPath(gpFill, Color.CornflowerBlue) renderer.FillPath(gpStroke, Color.DarkOrchid) renderer.Transform = Matrix3x2.IdentityEndSubEndClass