'''' 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.DrawingImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.ImagingImports GCTEXT = GrapeCity.Documents.Text '' This sample demonstrates composing two images using the available blending modes.'' The sample uses the same approach as the BlendingModes sample,'' but instead of showing a few of the available modes that produce'' a nice looking result, demonstrates all of them in smaller scale.'' The base and the blended images used as the same as in the BlendingModes sample.PublicClassAllBlendingModesFunctionGenerateImage(ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsGcBitmap Dim bmp = NewGcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi)Using origBmp = NewGcBitmap(), spectrumBmp = NewGcBitmap()'' Load a sample photo:Dim imagePath = Path.Combine("Resources", "ImagesBis", "orchid.jpg")Using stm = NewFileStream(imagePath, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, FileOptions.RandomAccess) origBmp.Load(stm)EndUsing '' Blending source:Dim spectrumPath = Path.Combine("Resources", "ImagesBis", "spectrum-pastel-500x500.png")Using stm = NewFileStream(spectrumPath, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, FileOptions.RandomAccess) spectrumBmp.Load(stm) spectrumBmp.Opaque = opaque origBmp.Opaque = opaque '' Resize the original photo so we can place 4 samples of it'' on the resulting bitmap:Dim w = pixelSize.Width / 4Dim h = pixelSize.Height / 4Using g = bmp.CreateGraphics()'' Prepare 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 16 blending modes in a 4x4 gridUsing sizedBmp = origBmp.Resize(w, h, InterpolationMode.Cubic), sizedSpectrumBmp = spectrumBmp.Resize(w, h)For row = 0To3For col = 0To3'' Sample:Dim blendMode = CType(row * 4 + col, BlendMode)Dim x = w * col, y = h * row bmp.BitBlt(sizedBmp, x, y) bmp.CompositeAndBlend(sizedSpectrumBmp, x, y, CompositeMode.SourceOver, blendMode)'' 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))NextNextEndUsingEndUsingEndUsingEndUsingReturn bmpEndFunctionEndClass