mirror of
https://github.com/claunia/libexeinfo.git
synced 2025-12-16 19:14:24 +00:00
Add GUI to decode BeOS icons.
This commit is contained in:
19
exeinfogui/BeOS/PanelBeIcon.xeto
Normal file
19
exeinfogui/BeOS/PanelBeIcon.xeto
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Panel xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<Label ID="lblSize">Size</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<TextBox ID="txtSize" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
|
||||
<ImageView ID="imgIcon"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
|
||||
<Panel ID="pnlPanel"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</Panel>
|
||||
73
exeinfogui/BeOS/PanelBeIcon.xeto.cs
Normal file
73
exeinfogui/BeOS/PanelBeIcon.xeto.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Eto.Drawing;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
using libexeinfo.BeOS;
|
||||
|
||||
namespace exeinfogui.BeOS
|
||||
{
|
||||
public class PanelBeIcon : Panel
|
||||
{
|
||||
ImageView imgIcon;
|
||||
Label lblSize;
|
||||
PanelHexDump panelHexDump;
|
||||
Panel pnlPanel;
|
||||
TextBox txtSize;
|
||||
|
||||
public PanelBeIcon()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
panelHexDump = new PanelHexDump();
|
||||
pnlPanel.Content = panelHexDump;
|
||||
}
|
||||
|
||||
public void Update(byte[] data, string type)
|
||||
{
|
||||
bool recognized = type == Consts.B_LARGE_ICON_TYPE || type == Consts.B_MINI_ICON_TYPE ||
|
||||
type == Consts.B_PNG_FORMAT;
|
||||
|
||||
if(type == Consts.B_PNG_FORMAT)
|
||||
{
|
||||
Bitmap png = new Bitmap(data);
|
||||
if(png.Width == 0 || png.Height == 0)
|
||||
{
|
||||
txtSize.Text = $"{png.Width}x{png.Height} pixels";
|
||||
imgIcon.Image = png;
|
||||
|
||||
lblSize.Text = "Size";
|
||||
lblSize.Visible = true;
|
||||
txtSize.Visible = true;
|
||||
pnlPanel.Visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
recognized = false;
|
||||
}
|
||||
|
||||
if(data == null || !recognized)
|
||||
{
|
||||
imgIcon.Image = null;
|
||||
lblSize.Text = "No data";
|
||||
lblSize.Visible = false;
|
||||
txtSize.Visible = false;
|
||||
pnlPanel.Visible = false;
|
||||
panelHexDump.Update(data);
|
||||
return;
|
||||
}
|
||||
|
||||
int width = type == Consts.B_LARGE_ICON_TYPE ? 32 : 16;
|
||||
int height = width;
|
||||
|
||||
List<int> pixels = data.Select(p => (int)Consts.ArgbSystemPalette[p]).ToList();
|
||||
|
||||
txtSize.Text = $"{width}x{height} pixels";
|
||||
imgIcon.Image = new Bitmap(width, height, PixelFormat.Format32bppRgba, pixels);
|
||||
|
||||
lblSize.Text = "Size";
|
||||
lblSize.Visible = true;
|
||||
txtSize.Visible = true;
|
||||
pnlPanel.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ namespace exeinfogui.BeOS
|
||||
PanelText panelText;
|
||||
Panel pnlResource;
|
||||
TreeGridView treeResources;
|
||||
PanelBeIcon panelBeIcon;
|
||||
|
||||
public TabBeResources()
|
||||
{
|
||||
@@ -54,6 +55,7 @@ namespace exeinfogui.BeOS
|
||||
|
||||
panelHexDump = new PanelHexDump();
|
||||
panelText = new PanelText();
|
||||
panelBeIcon = new PanelBeIcon();
|
||||
}
|
||||
|
||||
public void Update(IEnumerable<ResourceTypeBlock> resources)
|
||||
@@ -99,7 +101,12 @@ namespace exeinfogui.BeOS
|
||||
{
|
||||
case Consts.B_MIME_STRING_TYPE:
|
||||
pnlResource.Content = panelText;
|
||||
panelText.Update(data, Encoding.UTF8);
|
||||
panelText.Update(data, Encoding.ASCII);
|
||||
break;
|
||||
case Consts.B_LARGE_ICON_TYPE:
|
||||
case Consts.B_MINI_ICON_TYPE:
|
||||
pnlResource.Content = panelBeIcon;
|
||||
panelBeIcon.Update(data, type);
|
||||
break;
|
||||
default:
|
||||
pnlResource.Content = panelHexDump;
|
||||
|
||||
Reference in New Issue
Block a user