Add code to decode OS/2 monochrome icons and pointers, and a separate Icon Viewer for debugging.

This commit is contained in:
2018-03-05 12:50:28 +00:00
parent 378cbd5d33
commit ec57e0fd03
11 changed files with 446 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>iconviewer</string>
<key>CFBundleIdentifier</key>
<string>com.example.iconviewer</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.7</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>CFBundleIconFile</key>
<string>MacIcon.icns</string>
</dict>
</plist>

Binary file not shown.

View File

@@ -0,0 +1,15 @@
using System;
using Eto.Forms;
using Eto.Drawing;
namespace iconviewer.Desktop
{
class Program
{
[STAThread]
static void Main(string[] args)
{
new Application(Eto.Platform.Detect).Run(new MainForm());
}
}
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Eto.Platform.Wpf" Version="2.4.1" />
<PackageReference Include="Eto.Platform.Gtk" Version="2.4.1" />
<PackageReference Include="Eto.Platform.Mac64" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\iconviewer\iconviewer.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<Form xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Icon Viewer" ClientSize="500, 500" Padding="10">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Top">
<StackLayout Orientation="Horizontal">
<StackLayoutItem HorizontalAlignment="Left">
<Label>Path</Label>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
<TextBox ID="txtPath" ReadOnly="True"/>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Right">
<Button ID="btnPath" Click="OnBtnPathClick">Open</Button>
</StackLayoutItem>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
<ImageView ID="imgIcon"/>
</StackLayoutItem>
</StackLayout>
<Form.Menu>
<MenuBar>
<MenuBar.QuitItem>
<ButtonMenuItem Text="Quit" Shortcut="CommonModifier+Q" Click="HandleQuit" />
</MenuBar.QuitItem>
<MenuBar.AboutItem>
<ButtonMenuItem Text="About..." Click="HandleAbout" />
</MenuBar.AboutItem>
</MenuBar>
</Form.Menu>
</Form>

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using Eto.Forms;
using Eto.Drawing;
using Eto.Serialization.Xaml;
using Bitmap = libexeinfo.Os2.Bitmap;
namespace iconviewer
{
public class MainForm : Form
{
ImageView imgIcon;
TextBox txtPath;
public MainForm()
{
XamlReader.Load(this);
}
protected void OnBtnPathClick(object sender, EventArgs e)
{
OpenFileDialog dlgOpenFileDialog = new OpenFileDialog {MultiSelect = false};
dlgOpenFileDialog.Filters.Add(new FileFilter {Extensions = new[] {".ico"}});
DialogResult result = dlgOpenFileDialog.ShowDialog(this);
if(result != DialogResult.Ok)
{
txtPath.Text = "";
imgIcon.Image = null;
return;
}
txtPath.Text = dlgOpenFileDialog.FileName;
FileStream fstream = new FileStream(dlgOpenFileDialog.FileName, FileMode.Open);
byte[] data = new byte[fstream.Length];
fstream.Read(data, 0, data.Length);
fstream.Dispose();
Bitmap.DecodedBitmap[] icons = libexeinfo.Os2.Bitmap.DecodeBitmap(data);
imgIcon.Image = new Eto.Drawing.Bitmap((int)icons[0].Width, (int)icons[0].Height, PixelFormat.Format32bppRgba,
icons[0].Pixels);
}
protected void HandleAbout(object sender, EventArgs e)
{
new AboutDialog().ShowDialog(this);
}
protected void HandleQuit(object sender, EventArgs e)
{
Application.Instance.Quit();
}
}
}

View File

@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>iconviewer</RootNamespace>
<PackageVersion>1.0</PackageVersion>
<Title>iconviewer</Title>
<Copyright>Copyright © 2018</Copyright>
<Description>Description of iconviewer</Description>
<ReleaseVersion>0.2</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<NoStdLib>false</NoStdLib>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoStdLib>false</NoStdLib>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Eto.Forms" Version="2.4.1" />
<PackageReference Include="Eto.Serialization.Xaml" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\libexeinfo\libexeinfo.csproj" />
</ItemGroup>
</Project>