//// This code is part of Document Solutions for Imaging demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem;usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Imaging; namespaceDsImagingWeb.Demos{// 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.publicclassMakeIco {publicstringDefaultMime { get => Common.Util.MimeTypes.ICO; } publicStreamGenerateImageStream(string targetMime, Size pixelSize, float dpi, bool opaque, string[] sampleParams = null) {if (targetMime != Common.Util.MimeTypes.ICO)thrownewException("This sample only supports ICO output format."); var srcPath = Path.Combine("Resources", "ImagesBis", "mescius-logomark-c.png");var srcBmp = newGcBitmap(); using (var s = File.OpenRead(srcPath)) srcBmp.Load(s); using (var bmp16 = srcBmp.Resize(16, 16))using (var bmp24 = srcBmp.Resize(24, 24))using (var bmp32 = srcBmp.Resize(32, 32))using (var bmp48 = srcBmp.Resize(48, 48))using (var bmp256 = srcBmp.Resize(256, 256))using (var ico = newGcIco()) { 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)); var ms = newMemoryStream(); ico.Save(ms); ms.Seek(0, SeekOrigin.Begin);return ms; } } }}