'''' 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 loads an existing GIF with true color frames'' (produced by the MakeGif sample) and converts its frames'' to indexed 8bpp images. It also adds a global palette to the'' resulting GIF (the palette is taken from the first frame).PublicClassIndexedGifFunctionGenerateImageStream(ByVal targetMime AsString,ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,Optional sampleParams AsString() = Nothing) AsStream IfNot targetMime = MimeTypes.GIF ThenThrowNew Exception("This sample only supports GIF output format.")EndIf Dim ms = NewMemoryStream()'' Read frames from the source GIF, convert them to 8bpp And save in the target GIFUsing gr = NewGcGifReader(Path.Combine("Resources", "Gifs", "goldfish.gif")), gw = NewGcGifWriter(ms)For i = 0To gr.Frames.Count - 1'' Add a global palette to the target GIF based on the first frameIf i = 0ThenUsing tbmp = gr.Frames(i).ToGcBitmap() gw.GlobalPalette = tbmp.GenerateOctreePalette(256)EndUsingEndIfDim indexedBmp = gr.Frames(i).ReadAsIndexed8bppBitmap() gw.AppendFrame(indexedBmp, 0, 0, GifDisposalMethod.DoNotDispose, 16)NextEndUsing ms.Seek(0, SeekOrigin.Begin)Return msEndFunction PublicReadOnlyPropertyDefaultMime() AsStringGetReturn MimeTypes.GIFEndGetEndPropertyEndClass