Skip to content

Commit

Permalink
Merge 26b123b into 186d61d
Browse files Browse the repository at this point in the history
  • Loading branch information
m-tmatma authored Jan 4, 2020
2 parents 186d61d + 26b123b commit 0943b72
Show file tree
Hide file tree
Showing 16 changed files with 555 additions and 0 deletions.
125 changes: 125 additions & 0 deletions build-bmp-tools.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
set configuration=%1
if "%configuration%" == "Release" (
@rem OK
) else if "%configuration%" == "Debug" (
@rem OK
) else (
call :showhelp %0
exit /b 1
)

if not defined CMD_MSBUILD call %~dp0tools\find-tools.bat
if not defined CMD_MSBUILD (
echo msbuild.exe was not found.
exit /b 1
)

set "TOOL_SLN_FILE=%~dp0tools\ToolBarTools\ToolBarTools.sln"
@echo "%CMD_MSBUILD%" %TOOL_SLN_FILE% "/p:Platform=Any CPU" /p:Configuration=%configuration% /t:"Build" /v:q
"%CMD_MSBUILD%" %TOOL_SLN_FILE% "/p:Platform=Any CPU" /p:Configuration=%configuration% /t:"Build" /v:q
if errorlevel 1 (echo error && exit /b 1)

set MUXER=%~dp0tools\ToolBarTools\ToolBarImageMuxer\bin\%configuration%\ToolBarImageMuxer.exe
set SPLITTER=%~dp0tools\ToolBarTools\ToolBarImageSplitter\bin\%configuration%\ToolBarImageSplitter.exe

set SRC_BMP1=%~dp0resource\mytool.bmp
set SRC_BMP2=%~dp0resource\my_icons.bmp

set DST_DIR1=%~dp0resource\mytool
set DST_DIR2=%~dp0resource\my_icons

if exist %DST_DIR1% rmdir /s /q %DST_DIR1%
if exist %DST_DIR2% rmdir /s /q %DST_DIR2%
if exist %DST_DIR1% rmdir /s /q %DST_DIR1%
if exist %DST_DIR2% rmdir /s /q %DST_DIR2%

@rem split input bmp
%SPLITTER% %SRC_BMP1% %DST_DIR1%
if errorlevel 1 (
echo fail %SPLITTER% %SRC_BMP1% %DST_DIR1%
exit /b 1
)

%SPLITTER% %SRC_BMP2% %DST_DIR2%
if errorlevel 1 (
echo fail %SPLITTER% %SRC_BMP2% %DST_DIR2%
exit /b 1
)

@rem these steps are for tests.
set OUT1_BMP1=%~dp0resource\out1-mytool.bmp
set OUT1_BMP2=%~dp0resource\out1-my_icons.bmp
set OUT2_BMP1=%~dp0resource\out2-mytool.bmp
set OUT2_BMP2=%~dp0resource\out2-my_icons.bmp

set OUT_DIR1=%~dp0resource\mytool
set OUT_DIR2=%~dp0resource\my_icons

@rem merge multiple bmp to one bmp
%MUXER% %DST_DIR1% %OUT1_BMP1%
if errorlevel 1 (
echo fail %MUXER% %DST_DIR1% %OUT1_BMP1%
exit /b 1
)

%MUXER% %DST_DIR2% %OUT1_BMP2%
if errorlevel 1 (
echo fail %MUXER% %DST_DIR2% %OUT1_BMP2%
exit /b 1
)

%SPLITTER% %OUT1_BMP1% %OUT_DIR1%
if errorlevel 1 (
echo fail %SPLITTER% %OUT1_BMP1% %OUT_DIR1%
exit /b 1
)

%SPLITTER% %OUT1_BMP2% %OUT_DIR2%
if errorlevel 1 (
echo fail %SPLITTER% %OUT1_BMP2% %OUT_DIR2%
exit /b 1
)

%MUXER% %OUT_DIR1% %OUT2_BMP1%
if errorlevel 1 (
echo fail %MUXER% %OUT_DIR1% %OUT2_BMP1%
exit /b 1
)

%MUXER% %OUT_DIR2% %OUT2_BMP2%
if errorlevel 1 (
echo fail %MUXER% %OUT_DIR2% %OUT2_BMP2%
exit /b 1
)

fc /a /b %OUT1_BMP1% %OUT2_BMP1% >NUL
if errorlevel 1 (
echo fail fc /a /b %OUT1_BMP1% %OUT2_BMP1%
exit /b 1
)

fc /a /b %OUT1_BMP2% %OUT2_BMP2% >NUL
if errorlevel 1 (
echo fail fc /a /b %OUT1_BMP2% %OUT2_BMP2%
exit /b 1
)

echo Success
exit /b 0

@rem ------------------------------------------------------------------------------
@rem show help
@rem see http://orangeclover.hatenablog.com/entry/20101004/1286120668
@rem ------------------------------------------------------------------------------
:showhelp
@echo off
@echo usage
@echo %~nx1 configuration
@echo.
@echo parameter
@echo configuration : Release or Debug
@echo.
@echo example
@echo %~nx1 Release
@echo %~nx1 Debug
exit /b 0
4 changes: 4 additions & 0 deletions ci/azure-pipelines/template.job.build-unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
- script: build-sln.bat $(BuildPlatform) $(Configuration)
displayName: Build solution

# Toolbar Bitmap Split/Mux
- script: build-bmp-tools.bat $(Configuration)
displayName: Bitmap Split/Mux

# # Build HTML Help
# - script: build-chm.bat
# displayName: Build HTML Help
Expand Down
6 changes: 6 additions & 0 deletions tools/ToolBarTools/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.cs text
*.config text
*.settings text

*.csproj binary
*.sln binary
5 changes: 5 additions & 0 deletions tools/ToolBarTools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/bin
**/obj
**/packages
**/TestResults
.vs
6 changes: 6 additions & 0 deletions tools/ToolBarTools/ToolBarImageMuxer/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
36 changes: 36 additions & 0 deletions tools/ToolBarTools/ToolBarImageMuxer/BmpFileComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.Text.RegularExpressions;

namespace ToolBarImageMuxer
{
public class BmpFileComparer : IComparer<string>
{
static Regex regex = new Regex(@"(\d+)(\D*)\.bmp", RegexOptions.Compiled);

public int Compare(string x, string y)
{
var matchX = regex.Match(x);
var matchY = regex.Match(y);

if (matchX.Success && matchY.Success)
{
var indexX = int.Parse(matchX.Groups[1].Value);
var indexY = int.Parse(matchY.Groups[1].Value);

// 数値だけのファイルの場合、数値として比較する
if (indexX != indexY)
{
return indexX - indexY;
}

// 数値の部分が同じ場合、文字列として比較する。
}
return x.CompareTo(y);
}
}
}
47 changes: 47 additions & 0 deletions tools/ToolBarTools/ToolBarImageMuxer/BmpMuxer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace ToolBarImageMuxer
{
public class BmpMuxer
{
static public void Mux(string[] fileNames, string outFile, int countPerLine)
{
// 一番最初の BMP の情報を取得する
var bmp = (Bitmap)Image.FromFile(fileNames[0]);
var sx = bmp.Size.Width;
var sy = bmp.Size.Height;

var lines = (fileNames.Length + countPerLine - 1) / countPerLine;
var width = sx * countPerLine;
var height = sy * lines;

// フルカラーのビットマップを作成する (Graphics がフルカラーを必要とする)
var imgMerge = new Bitmap(width, height);
Graphics g = Graphics.FromImage(imgMerge);

var index = 0;
for (var y = 0; y < height; y += sy)
{
for (var x = 0; x < width; x += sx)
{
using (var bmpTmp = (Bitmap)Image.FromFile(fileNames[index]))
{
var cloneRect = new RectangleF(x, y, sx, sy);
g.DrawImage(bmpTmp, cloneRect);
}
index++;
}
}

// 入力のビットマップと同じ形式で保存する (減色処理含む)
var outRect = new RectangleF(0, 0, width, height);
var imgSave = imgMerge.Clone(outRect, bmp.PixelFormat);
imgSave.Save(outFile, System.Drawing.Imaging.ImageFormat.Bmp);
}
}
}
29 changes: 29 additions & 0 deletions tools/ToolBarTools/ToolBarImageMuxer/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ToolBarImageMuxer
{
class Program
{
static void Main(string[] args)
{
if (args.Length < 2)
{
return;
}
var inputDir = args[0];
var outfile = args[1];
var files = Directory.GetFiles(inputDir, "*.bmp", SearchOption.TopDirectoryOnly);

var compare = new BmpFileComparer();
Array.Sort<string>(files, compare);

var countPerLine = 32 + 1;
BmpMuxer.Mux(files, outfile, countPerLine);
}
}
}
36 changes: 36 additions & 0 deletions tools/ToolBarTools/ToolBarImageMuxer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ToolBarImageMuxer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ToolBarImageMuxer")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("abf37460-f080-4f1a-9f7a-f166154072ff")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
56 changes: 56 additions & 0 deletions tools/ToolBarTools/ToolBarImageMuxer/ToolBarImageMuxer.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{ABF37460-F080-4F1A-9F7A-F166154072FF}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ToolBarImageMuxer</RootNamespace>
<AssemblyName>ToolBarImageMuxer</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BmpFileComparer.cs" />
<Compile Include="BmpMuxer.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
6 changes: 6 additions & 0 deletions tools/ToolBarTools/ToolBarImageSplitter/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
Loading

0 comments on commit 0943b72

Please sign in to comment.