diff options
author | WlodekM <[email protected]> | 2024-06-16 10:35:45 +0300 |
---|---|---|
committer | WlodekM <[email protected]> | 2024-06-16 10:35:45 +0300 |
commit | abef6da56913f1c55528103e60a50451a39628b1 (patch) | |
tree | b3c8092471ecbb73e568cd0d336efa0e7871ee8d /misc/linux/linux_icon_gen.cs |
initial commit
Diffstat (limited to 'misc/linux/linux_icon_gen.cs')
-rw-r--r-- | misc/linux/linux_icon_gen.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/misc/linux/linux_icon_gen.cs b/misc/linux/linux_icon_gen.cs new file mode 100644 index 0000000..a48344d --- /dev/null +++ b/misc/linux/linux_icon_gen.cs @@ -0,0 +1,42 @@ +using System.Drawing.Imaging; +using System.Drawing; +using System.IO; + +namespace test +{ + public static class Program + { + const string src = "CCicon.ico"; + const string dst = "_CCIcon_X11.h"; + + static void DumpIcon(StreamWriter sw, int width, int height) { + sw.WriteLine(width + "," + height + ","); + + using (Icon icon = new Icon(src, width, height)) { + using (Bitmap bmp = icon.ToBitmap()) { + for (int y = 0; y < bmp.Height; y++) { + for (int x = 0; x < bmp.Width; x++) { + Color c = bmp.GetPixel(x, y); + int p = (c.A << 24) | (c.R << 16) | (c.G << 8) | c.B; + sw.Write("0x" + ((uint)p).ToString("X8") + ","); + } + sw.WriteLine(); + } + } + } + } + + public static void Main(string[] args) { + using (StreamWriter sw = new StreamWriter(dst)) { + sw.WriteLine("/* Generated using misc/linux_icon_gen.cs */"); + sw.WriteLine(""); + sw.WriteLine("static const unsigned long CCIcon_Data[] = {"); + DumpIcon(sw, 64, 64); + DumpIcon(sw, 32, 32); + DumpIcon(sw, 16, 16); + sw.WriteLine("};"); + sw.WriteLine("static const int CCIcon_Size = sizeof(CCIcon_Data) / sizeof(unsigned long);"); + } + } + } +} |