OSDN Git Service

Add a test program
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Thu, 11 May 2017 23:09:52 +0000 (08:09 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Thu, 11 May 2017 23:09:52 +0000 (08:09 +0900)
BurageSnap.sln
BurageSnap/Capture.cs
CaptureTest/App.config [new file with mode: 0644]
CaptureTest/CaptureTest.csproj [new file with mode: 0644]
CaptureTest/Program.cs [new file with mode: 0644]
CaptureTest/Properties/AssemblyInfo.cs [new file with mode: 0644]

index 8847e54..d2b9901 100644 (file)
@@ -1,10 +1,12 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.23107.0
+# Visual Studio 15
+VisualStudioVersion = 15.0.26430.4
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BurageSnap", "BurageSnap\BurageSnap.csproj", "{16E7C5B7-745E-43B8-8C06-A79D76E52E08}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaptureTest", "CaptureTest\CaptureTest.csproj", "{1CB4540E-2010-476C-BA9D-B7528BB0EABC}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
                {16E7C5B7-745E-43B8-8C06-A79D76E52E08}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {16E7C5B7-745E-43B8-8C06-A79D76E52E08}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {16E7C5B7-745E-43B8-8C06-A79D76E52E08}.Release|Any CPU.Build.0 = Release|Any CPU
+               {1CB4540E-2010-476C-BA9D-B7528BB0EABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {1CB4540E-2010-476C-BA9D-B7528BB0EABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {1CB4540E-2010-476C-BA9D-B7528BB0EABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {1CB4540E-2010-476C-BA9D-B7528BB0EABC}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index 07e708f..bca7e8c 100644 (file)
@@ -151,7 +151,7 @@ namespace BurageSnap
             }
         }
 
-        private Rectangle DetectGameScreen(Bitmap bmp)
+        public Rectangle DetectGameScreen(Bitmap bmp)
         {
             var height = bmp.Height;
             var width = bmp.Width;
diff --git a/CaptureTest/App.config b/CaptureTest/App.config
new file mode 100644 (file)
index 0000000..88fa402
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
+    </startup>
+</configuration>
\ No newline at end of file
diff --git a/CaptureTest/CaptureTest.csproj b/CaptureTest/CaptureTest.csproj
new file mode 100644 (file)
index 0000000..a37a18d
--- /dev/null
@@ -0,0 +1,54 @@
+<?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>{1CB4540E-2010-476C-BA9D-B7528BB0EABC}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>CaptureTest</RootNamespace>
+    <AssemblyName>CaptureTest</AssemblyName>
+    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </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="Microsoft.CSharp" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\BurageSnap\BurageSnap.csproj">
+      <Project>{16e7c5b7-745e-43b8-8c06-a79d76e52e08}</Project>
+      <Name>BurageSnap</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>
\ No newline at end of file
diff --git a/CaptureTest/Program.cs b/CaptureTest/Program.cs
new file mode 100644 (file)
index 0000000..51399a5
--- /dev/null
@@ -0,0 +1,30 @@
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
+using BurageSnap;
+
+namespace CaptureTest
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length == 0)
+                return;
+            var capture = new Capture();
+            using (var bmp = new Bitmap(args[0]))
+            {
+                var rectangle = capture.DetectGameScreen(bmp);
+                if (rectangle.IsEmpty)
+                {
+                    Console.WriteLine(@"extract error");
+                    return;
+                }
+                using (var file = File.Create(Path.Combine(Path.GetDirectoryName(args[0]) ?? "", Path.GetFileNameWithoutExtension(args[0]) + "_result" + Path.GetExtension(args[0]))))
+                using (var cripped = bmp.Clone(rectangle, bmp.PixelFormat))
+                    cripped.Save(file, ImageFormat.Png);
+            }
+        }
+    }
+}
diff --git a/CaptureTest/Properties/AssemblyInfo.cs b/CaptureTest/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..d373bfd
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
+// アセンブリに関連付けられている情報を変更するには、
+// これらの属性値を変更してください。
+[assembly: AssemblyTitle("CaptureTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CaptureTest")]
+[assembly: AssemblyCopyright("Copyright ©  2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
+// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
+// その型の ComVisible 属性を true に設定してください。
+[assembly: ComVisible(false)]
+
+// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
+[assembly: Guid("1cb4540e-2010-476c-ba9d-b7528bb0eabc")]
+
+// アセンブリのバージョン情報は次の 4 つの値で構成されています:
+//
+//      メジャー バージョン
+//      マイナー バージョン
+//      ビルド番号
+//      Revision
+//
+// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
+// 既定値にすることができます:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]