'''' This code is part of Document Solutions for Imaging demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.DrawingImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.ImagingImports GCTEXT = GrapeCity.Documents.TextImports GCDRAW = GrapeCity.Documents.Drawing '' This sample demonstrates how to add a text watermark'' to an image. The image is rendered using its native'' resolution on a GcBitmap, then the watermark text'' is drawn on top using a semitransparent color.'' The resulting bitmap with the added watermark'' can be saved to any of the supported image formats.PublicClassWatermarkFunctionGenerateImage(ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsGcBitmap Dim Inch = dpiDim bmp = NewGcBitmap(pixelSize.Width, pixelSize.Height, True, dpi, dpi)Using g = bmp.CreateGraphics(Color.White)Using img = GCDRAW.Image.FromFile(Path.Combine("Resources", "Images", "reds.jpg"))Dim rc = NewRectangleF(0, 0, img.Width, img.Height) g.DrawImage(img, rc, Nothing, ImageAlign.Default) g.DrawString("Watermark",NewTextFormat() With { .Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "FreeSansBold.ttf")), .FontSize = Inch, .ForeColor = Color.FromArgb(128, Color.Yellow) }, rc, TextAlignment.Center, ParagraphAlignment.Center, False) Util.AddNote("The image above has a watermark added to it using text drawn with a semitransparent color.", g, NewRectangleF(Inch / 2, img.Height + Inch / 4, pixelSize.Width - Inch, pixelSize.Height - img.Height - Inch / 4)) '' Draw border around the whole image g.DrawRectangle(NewRectangleF(0, 0, bmp.Width, bmp.Height), Color.DarkSlateBlue, 4)EndUsing EndUsing'' DoneReturn bmpEndFunctionEndClass