Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed May 23, 2022
1 parent 80f569f commit 759a84f
Show file tree
Hide file tree
Showing 9 changed files with 709 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ColorRegionMaskCreator.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32510.428
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorRegionMaskCreator", "ColorRegionMaskCreator\ColorRegionMaskCreator.csproj", "{49C17CC8-3602-45EE-B8B6-C328A58528D2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{49C17CC8-3602-45EE-B8B6-C328A58528D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49C17CC8-3602-45EE-B8B6-C328A58528D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49C17CC8-3602-45EE-B8B6-C328A58528D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49C17CC8-3602-45EE-B8B6-C328A58528D2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EC640D85-3A2D-4AE2-8219-A8F3688DDF5C}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions ColorRegionMaskCreator/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.8" />
</startup>
</configuration>
61 changes: 61 additions & 0 deletions ColorRegionMaskCreator/ColorRegionMaskCreator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?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>{49C17CC8-3602-45EE-B8B6-C328A58528D2}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ColorRegionMaskCreator</RootNamespace>
<AssemblyName>ColorRegionMaskCreator</AssemblyName>
<TargetFrameworkVersion>v4.8</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>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</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>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</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="Config.cs" />
<Compile Include="ImageMasks.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="config.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
79 changes: 79 additions & 0 deletions ColorRegionMaskCreator/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System.IO;
using System.Text.RegularExpressions;

namespace ColorRegionMaskCreator
{
public class Config
{
public bool Load()
{
const string filePath = "config.ini";
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
return false;

var lines = File.ReadAllLines(filePath);
foreach (var l in lines)
{
var t = l.TrimStart();
if (string.IsNullOrEmpty(t) || t.StartsWith(";")) continue;

ReadSetting(t);
}

return true;
}

private void ReadSetting(string line)
{
var m = RegexSettingLine.Match(line);
if (!m.Success) return;

switch (m.Groups[1].Value.ToLowerInvariant())
{
case "maxwidth":
if (int.TryParse(m.Groups[2].Value, out var i))
MaxWidth = i;
break;
case "maxheight":
if (int.TryParse(m.Groups[2].Value, out i))
MaxHeight = i;
break;
case "colorr":
if (byte.TryParse(m.Groups[2].Value, out var b))
ColorR = b;
break;
case "colorg":
if (byte.TryParse(m.Groups[2].Value, out b))
ColorG = b;
break;
case "colorb":
if (byte.TryParse(m.Groups[2].Value, out b))
ColorB = b;
break;
case "greenscreenmingreen":
if (byte.TryParse(m.Groups[2].Value, out b))
GreenScreenMinGreen = b;
break;
case "greenscreenfactorglargerthanrb":
if (double.TryParse(m.Groups[2].Value, out var d))
GreenScreenFactorGLargerThanRB = d;
break;
case "greenscreengreenlargerthanrb":
if (byte.TryParse(m.Groups[2].Value, out b))
GreenScreenGreenLargerThanRB = b;
break;
}
}

public int MaxWidth = 256;
public int MaxHeight = 256;
public byte ColorR = 255;
public byte ColorG = 0;
public byte ColorB = 0;
public byte GreenScreenMinGreen = 50;
public byte GreenScreenGreenLargerThanRB = 50;
public double GreenScreenFactorGLargerThanRB = 2;

private static Regex RegexSettingLine = new Regex(@"(\w+) *= *(.*)");
}
}
Loading

0 comments on commit 759a84f

Please sign in to comment.