mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Add full support for Gem color icons.
This commit is contained in:
28
exeinfogui/GEM/GemIcon.cs
Normal file
28
exeinfogui/GEM/GemIcon.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using Eto.Drawing;
|
||||
|
||||
namespace exeinfogui.GEM
|
||||
{
|
||||
public static class GemIcon
|
||||
{
|
||||
public static Bitmap GemIconToEto(libexeinfo.GEM.Icon icon)
|
||||
{
|
||||
const uint COLOR = 0x00000000;
|
||||
const uint BACKGROUND = 0x00FFFFFF;
|
||||
const uint ALPHAMASK = 0xFF000000;
|
||||
List<int> pixels = new List<int>();
|
||||
|
||||
byte[] data = libexeinfo.GEM.FlipPlane(icon.Data, icon.Width);
|
||||
byte[] mask = libexeinfo.GEM.FlipPlane(icon.Mask, icon.Width);
|
||||
|
||||
for(int pos = 0; pos < data.Length; pos++)
|
||||
{
|
||||
for(int i = 0; i < 8; i++)
|
||||
pixels.Add((int)(((data[pos] & (1 << i)) != 0 ? COLOR : BACKGROUND) +
|
||||
((mask[pos] & (1 << i)) != 0 ? ALPHAMASK : 0)));
|
||||
}
|
||||
|
||||
return new Bitmap(icon.Width, icon.Height, PixelFormat.Format32bppRgba, pixels);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user