//// This code is part of Document Solutions for Imaging demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Drawing;usingGrapeCity.Documents.Text;usingGrapeCity.Documents.Imaging;usingGCTEXT = GrapeCity.Documents.Text;usingGCDRAW = GrapeCity.Documents.Drawing; namespaceDsImagingWeb.Demos{// 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.publicclassWatermark {publicGcBitmapGenerateImage(Size pixelSize, float dpi, bool opaque, string[] sampleParams = null) {var Inch = dpi;var bmp = newGcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi);using (var g = bmp.CreateGraphics(Color.LightGray))using (var image = GCDRAW.Image.FromFile(Path.Combine("Resources", "Images", "reds.jpg"))) {var rc = newRectangleF((pixelSize.Width - image.Width) / 2, (pixelSize.Height - image.Height) / 2, image.Width, image.Height); g.DrawImage(image, rc, null, ImageAlign.Default); g.DrawString("Watermark",newTextFormat() {Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "FreeSansBold.ttf")),FontSize = Inch,ForeColor = Color.FromArgb(128, Color.Yellow), }, rc, TextAlignment.Center, ParagraphAlignment.Center, false); }return bmp; } }}