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:
19
exeinfogui/GEM/GemColorIcon.cs
Normal file
19
exeinfogui/GEM/GemColorIcon.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Eto.Drawing;
|
||||
|
||||
namespace exeinfogui.GEM
|
||||
{
|
||||
public static class GemColorIcon
|
||||
{
|
||||
public static Bitmap GemColorIconToEto(libexeinfo.GEM.ColorIconPlane icon, int width, int height, bool selected)
|
||||
{
|
||||
if(selected && icon.SelectedData == null) return null;
|
||||
|
||||
byte[] data = selected ? icon.SelectedData : icon.Data;
|
||||
byte[] mask = selected ? icon.SelectedMask : icon.Mask;
|
||||
|
||||
int[] pixels = libexeinfo.GEM.PlaneToRaster(data, mask, width, height, icon.Planes);
|
||||
|
||||
return new Bitmap(width, height, PixelFormat.Format32bppRgba, pixels);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
125
exeinfogui/GEM/PanelGemColorIcon.xeto
Normal file
125
exeinfogui/GEM/PanelGemColorIcon.xeto
Normal file
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Panel xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="500" Height="500">
|
||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Top">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblFlags">Flags</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtFlags" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblState">State</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtState" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblCoordinates">Coordinates</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtCoordinates" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblSize">Size</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtSize" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblCharacter">Character</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtCharater" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblCharCoordinates">Character coordinates</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtCharCoordinates" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblFgColor">Character foreground color</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtFgColor" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblBgColor">Character background color</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtBgColor" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblTextCoordinates">Text coordinates</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtTextCoordinates" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblTextBoxSize">Text box size</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtTextBoxSize" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem>
|
||||
<Label ID="lblText">Text</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtText" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label ID="lblMonochrome">Monochrome icon</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<ImageView ID="imgIcon"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label ID="lblColor">Color icons</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
|
||||
<GridView ID="treePlanes"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center" VerticalAlignment="Top" Expand="True">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label ID="lblColorIcon">Normal</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<ImageView ID="imgColorIcon"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label ID="lblSelectedIcon">Selected</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<ImageView ID="imgSelectedIcon"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</Panel>
|
||||
88
exeinfogui/GEM/PanelGemColorIcon.xeto.cs
Normal file
88
exeinfogui/GEM/PanelGemColorIcon.xeto.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
|
||||
namespace exeinfogui.GEM
|
||||
{
|
||||
public class PanelGemColorIcon : Panel
|
||||
{
|
||||
int iconHeight;
|
||||
|
||||
int iconWidth;
|
||||
ImageView imgColorIcon;
|
||||
ImageView imgIcon;
|
||||
ImageView imgSelectedIcon;
|
||||
GridView treePlanes;
|
||||
TextBox txtBgColor;
|
||||
TextBox txtCharater;
|
||||
TextBox txtCharCoordinates;
|
||||
TextBox txtCoordinates;
|
||||
TextBox txtFgColor;
|
||||
TextBox txtFlags;
|
||||
TextBox txtSize;
|
||||
TextBox txtState;
|
||||
TextBox txtText;
|
||||
TextBox txtTextBoxSize;
|
||||
TextBox txtTextCoordinates;
|
||||
|
||||
public PanelGemColorIcon()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
|
||||
treePlanes.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell
|
||||
{
|
||||
Binding = Binding.Property<libexeinfo.GEM.ColorIconPlane, string>(i => $"{i.Planes}")
|
||||
},
|
||||
HeaderText = "Planes"
|
||||
});
|
||||
treePlanes.AllowMultipleSelection = false;
|
||||
treePlanes.SelectedItemsChanged += TreePlanesOnSelectedItemsChanged;
|
||||
}
|
||||
|
||||
void TreePlanesOnSelectedItemsChanged(object sender, EventArgs eventArgs)
|
||||
{
|
||||
if(!(treePlanes.SelectedItem is libexeinfo.GEM.ColorIconPlane cicon))
|
||||
{
|
||||
imgColorIcon.Image = null;
|
||||
imgSelectedIcon.Image = null;
|
||||
return;
|
||||
}
|
||||
|
||||
imgColorIcon.Image = GemColorIcon.GemColorIconToEto(cicon, iconWidth, iconHeight, false);
|
||||
imgSelectedIcon.Image = GemColorIcon.GemColorIconToEto(cicon, iconWidth, iconHeight, true);
|
||||
}
|
||||
|
||||
public void Update(libexeinfo.GEM.TreeObjectNode node, libexeinfo.GEM.ColorIcon colorIcon)
|
||||
{
|
||||
txtFlags.Text = node.flags == 0 ? "None" : node.flags.ToString();
|
||||
txtState.Text = node.state == 0 ? "Normal" : node.state.ToString();
|
||||
txtCoordinates.Text = $"{colorIcon.Monochrome.X},{colorIcon.Monochrome.Y}";
|
||||
txtSize.Text = $"{colorIcon.Monochrome.Width}x{colorIcon.Monochrome.Height} pixels";
|
||||
txtCharater.Text = $"{colorIcon.Monochrome.Character}";
|
||||
txtCharCoordinates.Text = $"{colorIcon.Monochrome.CharX},{colorIcon.Monochrome.CharY}";
|
||||
txtFgColor.Text = $"{colorIcon.Monochrome.ForegroundColor}";
|
||||
txtBgColor.Text = $"{colorIcon.Monochrome.BackgroundColor}";
|
||||
txtTextCoordinates.Text = $"{colorIcon.Monochrome.TextX},{colorIcon.Monochrome.TextY}";
|
||||
txtTextBoxSize.Text = $"{colorIcon.Monochrome.TextWidth}x{colorIcon.Monochrome.TextHeight} pixels";
|
||||
txtText.Text = colorIcon.Monochrome.Text;
|
||||
imgIcon.Image = GemIcon.GemIconToEto(colorIcon.Monochrome);
|
||||
treePlanes.DataStore = colorIcon.Color;
|
||||
iconWidth = colorIcon.Monochrome.Width;
|
||||
iconHeight = colorIcon.Monochrome.Height;
|
||||
treePlanes.SelectRow(0);
|
||||
if(colorIcon.Color != null && colorIcon.Color.Length >= 1 && colorIcon.Color[0] != null)
|
||||
{
|
||||
imgColorIcon.Image =
|
||||
GemColorIcon.GemColorIconToEto(colorIcon.Color[0], iconWidth, iconHeight, false);
|
||||
imgSelectedIcon.Image = GemColorIcon.GemColorIconToEto(colorIcon.Color[0], iconWidth, iconHeight, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
imgColorIcon.Image = null;
|
||||
imgSelectedIcon.Image = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Eto.Drawing;
|
||||
using Eto.Forms;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
|
||||
namespace exeinfogui.GEM
|
||||
@@ -38,67 +36,7 @@ namespace exeinfogui.GEM
|
||||
txtTextCoordinates.Text = $"{node.IconBlock.TextX},{node.IconBlock.TextY}";
|
||||
txtTextBoxSize.Text = $"{node.IconBlock.TextWidth}x{node.IconBlock.TextHeight} pixels";
|
||||
txtText.Text = node.IconBlock.Text;
|
||||
imgIcon.Image = GemIconToEto(node);
|
||||
}
|
||||
|
||||
static Bitmap GemIconToEto(libexeinfo.GEM.TreeObjectNode node)
|
||||
{
|
||||
const uint COLOR = 0x00000000;
|
||||
const uint BACKGROUND = 0x00FFFFFF;
|
||||
const uint ALPHAMASK = 0xFF000000;
|
||||
List<int> pixels = new List<int>();
|
||||
|
||||
byte[] data = new byte[node.IconBlock.Data.Length];
|
||||
int pos = 0;
|
||||
int w = node.IconBlock.Width / 8;
|
||||
// This flips the image.
|
||||
while(pos < data.Length)
|
||||
{
|
||||
for(int i = 0; i < w; i++)
|
||||
{
|
||||
byte b = node.IconBlock.Data[pos + i];
|
||||
data[pos + i] = (byte)(b >> 7);
|
||||
data[pos + i] += (byte)((b >> 5) & 0x02);
|
||||
data[pos + i] += (byte)((b >> 3) & 0x04);
|
||||
data[pos + i] += (byte)((b >> 1) & 0x08);
|
||||
data[pos + i] += (byte)((b << 1) & 0x10);
|
||||
data[pos + i] += (byte)((b << 3) & 0x20);
|
||||
data[pos + i] += (byte)((b << 5) & 0x40);
|
||||
data[pos + i] += (byte)(b << 7);
|
||||
}
|
||||
|
||||
pos += w;
|
||||
}
|
||||
|
||||
byte[] mask = new byte[node.IconBlock.Mask.Length];
|
||||
pos = 0;
|
||||
// This flips the mask.
|
||||
while(pos < data.Length)
|
||||
{
|
||||
for(int i = 0; i < w; i++)
|
||||
{
|
||||
byte b = node.IconBlock.Mask[pos + i];
|
||||
mask[pos + i] = (byte)(b >> 7);
|
||||
mask[pos + i] += (byte)((b >> 5) & 0x02);
|
||||
mask[pos + i] += (byte)((b >> 3) & 0x04);
|
||||
mask[pos + i] += (byte)((b >> 1) & 0x08);
|
||||
mask[pos + i] += (byte)((b << 1) & 0x10);
|
||||
mask[pos + i] += (byte)((b << 3) & 0x20);
|
||||
mask[pos + i] += (byte)((b << 5) & 0x40);
|
||||
mask[pos + i] += (byte)(b << 7);
|
||||
}
|
||||
|
||||
pos += w;
|
||||
}
|
||||
|
||||
for(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(node.IconBlock.Width, node.IconBlock.Height, PixelFormat.Format32bppRgba, pixels);
|
||||
imgIcon.Image = GemIcon.GemIconToEto(node.IconBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,17 @@ namespace exeinfogui.GEM
|
||||
{
|
||||
public class TabGemResources : TabPage
|
||||
{
|
||||
PanelGemBox panelBox;
|
||||
PanelGemGeneric panelGeneric;
|
||||
PanelGemIcon panelIcon;
|
||||
PanelGemImage panelImage;
|
||||
PanelGemString panelString;
|
||||
PanelGemText panelText;
|
||||
Panel pnlResource;
|
||||
TreeGridItemCollection treeData;
|
||||
TreeGridView treeResources;
|
||||
libexeinfo.GEM.ColorIcon[] colorIcons;
|
||||
PanelGemBox panelBox;
|
||||
PanelGemColorIcon panelColorIcon;
|
||||
PanelGemGeneric panelGeneric;
|
||||
PanelGemIcon panelIcon;
|
||||
PanelGemImage panelImage;
|
||||
PanelGemString panelString;
|
||||
PanelGemText panelText;
|
||||
Panel pnlResource;
|
||||
TreeGridItemCollection treeData;
|
||||
TreeGridView treeResources;
|
||||
|
||||
public TabGemResources()
|
||||
{
|
||||
@@ -25,15 +27,16 @@ namespace exeinfogui.GEM
|
||||
treeResources.AllowMultipleSelection = false;
|
||||
treeResources.SelectionChanged += TreeResourcesOnSelectionChanged;
|
||||
|
||||
panelGeneric = new PanelGemGeneric();
|
||||
panelString = new PanelGemString();
|
||||
panelText = new PanelGemText();
|
||||
panelBox = new PanelGemBox();
|
||||
panelImage = new PanelGemImage();
|
||||
panelIcon = new PanelGemIcon();
|
||||
panelGeneric = new PanelGemGeneric();
|
||||
panelString = new PanelGemString();
|
||||
panelText = new PanelGemText();
|
||||
panelBox = new PanelGemBox();
|
||||
panelImage = new PanelGemImage();
|
||||
panelIcon = new PanelGemIcon();
|
||||
panelColorIcon = new PanelGemColorIcon();
|
||||
}
|
||||
|
||||
public void Update(libexeinfo.GEM.TreeObjectNode[] roots)
|
||||
public void Update(libexeinfo.GEM.TreeObjectNode[] roots, libexeinfo.GEM.ColorIcon[] cicons)
|
||||
{
|
||||
treeData = new TreeGridItemCollection();
|
||||
|
||||
@@ -47,6 +50,7 @@ namespace exeinfogui.GEM
|
||||
}
|
||||
|
||||
treeResources.DataStore = treeData;
|
||||
colorIcons = cicons;
|
||||
}
|
||||
|
||||
void TreeResourcesOnSelectionChanged(object sender, EventArgs eventArgs)
|
||||
@@ -86,8 +90,14 @@ namespace exeinfogui.GEM
|
||||
panelIcon.Update(node);
|
||||
pnlResource.Content = panelIcon;
|
||||
break;
|
||||
/* case libexeinfo.GEM.ObjectTypes.G_USERDEF: break;
|
||||
case libexeinfo.GEM.ObjectTypes.G_CICON: break;*/
|
||||
/* case libexeinfo.GEM.ObjectTypes.G_USERDEF: break;*/
|
||||
case libexeinfo.GEM.ObjectTypes.G_CICON:
|
||||
if(colorIcons == null || node.data >= colorIcons.Length || colorIcons[node.data] == null)
|
||||
goto default;
|
||||
|
||||
panelColorIcon.Update(node, colorIcons[node.data]);
|
||||
pnlResource.Content = panelColorIcon;
|
||||
break;
|
||||
default:
|
||||
panelGeneric.Update(node);
|
||||
pnlResource.Content = panelGeneric;
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace exeinfogui
|
||||
recognizedExe = mzExe;
|
||||
if(((MZ)mzExe).ResourceObjectRoots != null && ((MZ)mzExe).ResourceObjectRoots.Any())
|
||||
{
|
||||
tabGemResources.Update(((MZ)mzExe).ResourceObjectRoots);
|
||||
tabGemResources.Update(((MZ)mzExe).ResourceObjectRoots, ((MZ)mzExe).GemColorIcons);
|
||||
tabGemResources.Visible = true;
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace exeinfogui
|
||||
recognizedExe = stExe;
|
||||
if(((AtariST)stExe).ResourceObjectRoots != null && ((AtariST)stExe).ResourceObjectRoots.Any())
|
||||
{
|
||||
tabGemResources.Update(((AtariST)stExe).ResourceObjectRoots);
|
||||
tabGemResources.Update(((AtariST)stExe).ResourceObjectRoots, ((AtariST)stExe).GemColorIcons);
|
||||
tabGemResources.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user