'''' 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.Imaging '' This sample takes a color JPEG, converts it to different image types'' (such as b/w and grayscale) and creates a multi-frame TIFF from those'' images.PublicClassImageTypesInTiffFunctionGenerateImageStream(ByVal targetMime AsString,ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,Optional sampleParams AsString() = Nothing) AsStream IfNot targetMime = MimeTypes.TIFF ThenThrowNew Exception("This sample only supports TIFF output format.")EndIf Dim pth = Path.Combine("Resources", "Images", "minerva.jpg") Dim ms = NewMemoryStream()Using tw = NewGcTiffWriter(ms), bmp = NewGcBitmap(pth)'' Using the green channel produces a marginally better result for this photo. '' For a much better bilevel image produced by dithering, see DitheringInTiff.Using f = bmp.ToBilevelBitmap(ColorChannel.Green) tw.AppendFrame(f)EndUsingUsing f = bmp.ToGrayscaleBitmap() tw.AppendFrame(f)EndUsing'' 4bpp allows from 8 to 16 colors, we use max (16)Using f = bmp.ToIndexed4bppBitmap(16) tw.AppendFrame(f)EndUsing'' 8bpp allows from 8 to 256 colors, we use max (256)Using f = bmp.ToIndexed8bppBitmap(256) tw.AppendFrame(f)EndUsing tw.AppendFrame(bmp)EndUsing ms.Seek(0, SeekOrigin.Begin)Return msEndFunction PublicReadOnlyPropertyDefaultMime() AsStringGetReturn MimeTypes.TIFFEndGetEndPropertyEndClass