'''' This code is part of Document Solutions for Imaging demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystemImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.Imaging '' This sample loads a large PNG image, resizes it to several smaller sizes'' commonly used in icons, and creates a multi-frame .ICO from those.'' See also the ReadIco sample which renders the frames from the .ICO created by this sample.PublicClassMakeIcoPublicReadOnlyPropertyDefaultMimeAsStringGetReturn Util.MimeTypes.ICOEndGetEndProperty PublicFunctionGenerateImageStream(ByVal targetMime AsString,ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsStream If targetMime <> Util.MimeTypes.ICO ThenThrowNewException("This sample only supports ICO output format.")EndIf Dim srcPath = Path.Combine("Resources", "ImagesBis", "mescius-logomark-c.png")Dim srcBmp AsNewGcBitmap()Using s AsStream = File.OpenRead(srcPath) srcBmp.Load(s)EndUsing Using bmp16 AsGcBitmap = srcBmp.Resize(16, 16), bmp24 AsGcBitmap = srcBmp.Resize(24, 24), bmp32 AsGcBitmap = srcBmp.Resize(32, 32), bmp48 AsGcBitmap = srcBmp.Resize(48, 48), bmp256 AsGcBitmap = srcBmp.Resize(256, 256), ico AsNewGcIco() ico.Frames.Add(NewIcoFrame(bmp256, IcoFrameEncoding.Png)) ico.Frames.Add(NewIcoFrame(bmp48, IcoFrameEncoding.Png)) ico.Frames.Add(NewIcoFrame(bmp32, IcoFrameEncoding.Png)) ico.Frames.Add(NewIcoFrame(bmp24, IcoFrameEncoding.Png)) ico.Frames.Add(NewIcoFrame(bmp16, IcoFrameEncoding.Png)) Dim ms = NewMemoryStream() ico.Save(ms) ms.Seek(0, SeekOrigin.Begin)Return msEndUsingEndFunctionEndClass