'''' This code is part of Document Solutions for Imaging demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsSystem.Collections.GenericImportsSystem.LinqImportsSystem.NumericsImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.ImagingImports GCTEXT = GrapeCity.Documents.Text '' This sample demonstrates how to render a watermark on an image'' at an angle using a rotation transformation on the bitmap graphics.PublicClassWatermark2FunctionGenerateImage(ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsGcBitmap '' Note: we can use Color.Transparent instead Of a solid background,'' but the resulting image format must support transparency for this'' to work as expected:Dim backColor = Color.FromArgb(&HFF0066CC)Dim foreColor = Color.FromArgb(&HFFFFCC00)Dim angle = -30Dim rad = (angle * Math.PI) / 180.0F Dim bmp = NewGcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi)Using bmpSrc = NewGcBitmap(Path.Combine("Resources", "ImagesBis", "alpamayo-sq.jpg"))'' BitBlt requires the opacity of both images to be the same: bmpSrc.Opaque = opaque'' Render source image onto the target bitmap'' (generally we might want to resize the source image first,'' but in this case we just know that the source image has'' the same size as the target, so skip this step): bmp.BitBlt(bmpSrc, 0, 0)EndUsing Using g = bmp.CreateGraphics()'' Draw watermark text in a loop over all image at an angle: g.Transform = Matrix3x2.CreateRotation((angle * Math.PI) / 180.0F, NewVector2(pixelSize.Width / 2, pixelSize.Height / 2))Dim tf = NewTextFormat() With { .Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "FreeSansBold.ttf")), .FontSize = 14, .ForeColor = Color.FromArgb(64, Color.White) }Dim tl = g.CreateTextLayout() tl.Append("Copyright (c) MESCIUS", tf) tl.PerformLayout(True)Dim dx = tl.ContentWidth * 3Dim dy = tl.ContentHeight * 5Dim n = 0Dim offX = -(Math.Cos(rad) * pixelSize.Height / 2)Dim offY = (Math.Sin(rad) * pixelSize.Width / 2)For y = offY To pixelSize.Height - offY Step dyFor x = offX + dx / 2 * (n Mod2) To pixelSize.Width - offX Step dx g.DrawTextLayout(tl, NewPointF(x, y))Next n += 1NextEndUsingReturn bmpEndFunctionEndClass