Skip to content

Instantly share code, notes, and snippets.

View Willy-Kimura's full-sized avatar
🎯
Building front-end experiences

Willy Kimura Willy-Kimura

🎯
Building front-end experiences
View GitHub Profile
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Threading;
namespace ICTest
{
// Destination object for touch/mouse/pen gestures.
@Willy-Kimura
Willy-Kimura / gist:d3d3541dee057c583f39005b25df65c8
Created May 15, 2019 17:09 — forked from darkfall/gist:1656050
A simple class that converts a image to a icon in c# without losing image color data, unlike System.Drawing.Icon; ico with png data requires Windows Vista or above
class PngIconConverter
{
/* input image with width = height is suggested to get the best result */
/* png support in icon was introduced in Windows Vista */
public static bool Convert(System.IO.Stream input_stream, System.IO.Stream output_stream, int size, bool keep_aspect_ratio = false)
{
System.Drawing.Bitmap input_bit = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(input_stream);
if (input_bit != null)
{
int width, height;