Skip to content

Commit 759a84f

Browse files
committed
first commit
1 parent 80f569f commit 759a84f

File tree

9 files changed

+709
-0
lines changed

9 files changed

+709
-0
lines changed

ColorRegionMaskCreator.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.32510.428
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorRegionMaskCreator", "ColorRegionMaskCreator\ColorRegionMaskCreator.csproj", "{49C17CC8-3602-45EE-B8B6-C328A58528D2}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{49C17CC8-3602-45EE-B8B6-C328A58528D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{49C17CC8-3602-45EE-B8B6-C328A58528D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{49C17CC8-3602-45EE-B8B6-C328A58528D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{49C17CC8-3602-45EE-B8B6-C328A58528D2}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {EC640D85-3A2D-4AE2-8219-A8F3688DDF5C}
24+
EndGlobalSection
25+
EndGlobal

ColorRegionMaskCreator/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
</configuration>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{49C17CC8-3602-45EE-B8B6-C328A58528D2}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>ColorRegionMaskCreator</RootNamespace>
10+
<AssemblyName>ColorRegionMaskCreator</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="System" />
39+
<Reference Include="System.Core" />
40+
<Reference Include="System.Drawing" />
41+
<Reference Include="System.Xml.Linq" />
42+
<Reference Include="System.Data.DataSetExtensions" />
43+
<Reference Include="Microsoft.CSharp" />
44+
<Reference Include="System.Data" />
45+
<Reference Include="System.Net.Http" />
46+
<Reference Include="System.Xml" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="Config.cs" />
50+
<Compile Include="ImageMasks.cs" />
51+
<Compile Include="Program.cs" />
52+
<Compile Include="Properties\AssemblyInfo.cs" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<None Include="App.config" />
56+
<None Include="config.ini">
57+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
58+
</None>
59+
</ItemGroup>
60+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
61+
</Project>

ColorRegionMaskCreator/Config.cs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System.IO;
2+
using System.Text.RegularExpressions;
3+
4+
namespace ColorRegionMaskCreator
5+
{
6+
public class Config
7+
{
8+
public bool Load()
9+
{
10+
const string filePath = "config.ini";
11+
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
12+
return false;
13+
14+
var lines = File.ReadAllLines(filePath);
15+
foreach (var l in lines)
16+
{
17+
var t = l.TrimStart();
18+
if (string.IsNullOrEmpty(t) || t.StartsWith(";")) continue;
19+
20+
ReadSetting(t);
21+
}
22+
23+
return true;
24+
}
25+
26+
private void ReadSetting(string line)
27+
{
28+
var m = RegexSettingLine.Match(line);
29+
if (!m.Success) return;
30+
31+
switch (m.Groups[1].Value.ToLowerInvariant())
32+
{
33+
case "maxwidth":
34+
if (int.TryParse(m.Groups[2].Value, out var i))
35+
MaxWidth = i;
36+
break;
37+
case "maxheight":
38+
if (int.TryParse(m.Groups[2].Value, out i))
39+
MaxHeight = i;
40+
break;
41+
case "colorr":
42+
if (byte.TryParse(m.Groups[2].Value, out var b))
43+
ColorR = b;
44+
break;
45+
case "colorg":
46+
if (byte.TryParse(m.Groups[2].Value, out b))
47+
ColorG = b;
48+
break;
49+
case "colorb":
50+
if (byte.TryParse(m.Groups[2].Value, out b))
51+
ColorB = b;
52+
break;
53+
case "greenscreenmingreen":
54+
if (byte.TryParse(m.Groups[2].Value, out b))
55+
GreenScreenMinGreen = b;
56+
break;
57+
case "greenscreenfactorglargerthanrb":
58+
if (double.TryParse(m.Groups[2].Value, out var d))
59+
GreenScreenFactorGLargerThanRB = d;
60+
break;
61+
case "greenscreengreenlargerthanrb":
62+
if (byte.TryParse(m.Groups[2].Value, out b))
63+
GreenScreenGreenLargerThanRB = b;
64+
break;
65+
}
66+
}
67+
68+
public int MaxWidth = 256;
69+
public int MaxHeight = 256;
70+
public byte ColorR = 255;
71+
public byte ColorG = 0;
72+
public byte ColorB = 0;
73+
public byte GreenScreenMinGreen = 50;
74+
public byte GreenScreenGreenLargerThanRB = 50;
75+
public double GreenScreenFactorGLargerThanRB = 2;
76+
77+
private static Regex RegexSettingLine = new Regex(@"(\w+) *= *(.*)");
78+
}
79+
}

0 commit comments

Comments
 (0)