'''' 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 the effects of different blend modes'' when drawing on a GcGraphics. Note that the current blend mode'' set on an instance of GcGraphics (including GcBitmapGraphics)'' affects not only images but all drawing operations.'' See also BlendText and BlendingModes samples.PublicClassBlendImagesPrivateConstc_keyOrchidAsString = "orchid"PrivateConstc_keySpectrumAsString = "spectrum" PublicFunctionGenerateImage(ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsGcBitmap Dim iorchid = GCDRAW.Image.FromFile(Path.Combine("Resources", "ImagesBis", "orchid.jpg"))Dim ispectr = GCDRAW.Image.FromFile(Path.Combine("Resources", "ImagesBis", "spectrum-pastel-500x500.png"))Dim ifore AsGCDRAW.Image, iback AsGCDRAW.Image If sampleParams IsNotNothingAndAlso sampleParams.Length > 3AndAlso sampleParams(3) = c_keyOrchidThen ifore = iorchid iback = ispectrElse ifore = ispectr iback = iorchidEndIf ConstmarginAsInteger = 36ConstNCOLSAsInteger = 4Dim w AsInteger = CInt((pixelSize.Width - margin * 2) / NCOLS)Dim h AsInteger = CInt((iorchid.Height * w) / iorchid.Width)Dim row AsInteger = 0, col AsInteger = 0 Dim bmp = NewGcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi)Using g = bmp.CreateGraphics(Color.White)'' Text layout for captions:Dim tl = g.CreateTextLayout() tl.DefaultFormat.Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "FreeMono.ttf")) tl.DefaultFormat.FontSize = 12 tl.ParagraphAlignment = ParagraphAlignment.Center tl.TextAlignment = TextAlignment.Center tl.MaxWidth = w tl.MaxHeight = h tl.MarginTop = h - g.MeasureString("QWERTY", tl.DefaultFormat).Height * 1.4F '' Render all blend modes in a grid:ForEach modeObj InSystem.Enum.GetValues(GetType(BlendMode))Dim blendMode = CType(modeObj, BlendMode)IfNot g.IsBlendModeSupported(blendMode) ThenContinueFor Dim x AsInteger = margin + w * colDim y AsInteger = margin + h * rowDim r AsNewRectangleF(x, y, w, h) g.BlendMode = BlendMode.Normal g.DrawImage(iback, r, Nothing, ImageAlign.StretchImage) g.BlendMode = blendMode g.DrawImage(ifore, r, Nothing, ImageAlign.StretchImage) g.BlendMode = BlendMode.Normal '' Caption: tl.Clear() tl.Append(blendMode.ToString()) tl.PerformLayout(True)Dim rc = tl.ContentRectangle rc.Offset(x, y) rc.Inflate(4, 2) g.FillRectangle(rc, Color.White) g.DrawTextLayout(tl, NewPointF(x, y)) col += 1If col = NCOLSThen col = 0 row += 1EndIfNextEndUsing Return bmpEndFunction PublicSharedFunctionGetSampleParamsList() As List(OfString())ReturnNew List(OfString()) From {NewString() {"Blend Orchid","Draw the orchid image over the spectrum image using all supported blend modes","We draw the tiles in this image by composing two images (an orchid and a spectrum) using the " &"different blend modes supported by GcBitmapGraphics. " &"The spectrum image is drawn using BlendMode.Normal, then the current blend mode on GcBitmapGraphics " &"is set to one of the supported blend modes, and the orchid image is drawn using it. " &"The name of the used blend mode is shown below each tile." &"Note that the blend mode set on the graphics affects not only images but any drawing on this graphics. ",c_keyOrchid },NewString() {"Blend Spectrum","Draw the spectrum image over the orchid image using all supported blend modes","We draw the tiles in this image by composing two images (a spectrum and an orchid) using the " &"different blend modes supported by GcBitmapGraphics. " &"The orchid image is drawn using BlendMode.Normal, then the current blend mode on GcBitmapGraphics " &"is set to one of the supported blend modes, and the spectrum image is drawn using it. " &"The name of the used blend mode is shown below each tile." &"Note that the blend mode set on the graphics affects not only images but any drawing on this graphics. ",c_keySpectrum } }EndFunctionEndClass