Last active
May 25, 2018 10:30
-
-
Save kusma/6e554aed947b0905761491a932f61243 to your computer and use it in GitHub Desktop.
alpha channel test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>{6561C4EB-18A8-482D-8C28-C5C7C6E9BF07}</ProjectGuid> | |
<OutputType>Exe</OutputType> | |
<RootNamespace>ConsoleApp2</RootNamespace> | |
<AssemblyName>ConsoleApp2</AssemblyName> | |
<TargetFrameworkVersion>v4.6.1</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="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="Program.cs" /> | |
</ItemGroup> | |
<ItemGroup> | |
<Folder Include="Properties\" /> | |
</ItemGroup> | |
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| |
Microsoft Visual Studio Solution File, Format Version 12.00 | |
# Visual Studio 15 | |
VisualStudioVersion = 15.0.26730.16 | |
MinimumVisualStudioVersion = 10.0.40219.1 | |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2.csproj", "{6561C4EB-18A8-482D-8C28-C5C7C6E9BF07}" | |
EndProject | |
Global | |
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |
Debug|Any CPU = Debug|Any CPU | |
Release|Any CPU = Release|Any CPU | |
EndGlobalSection | |
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |
{6561C4EB-18A8-482D-8C28-C5C7C6E9BF07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
{6561C4EB-18A8-482D-8C28-C5C7C6E9BF07}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
{6561C4EB-18A8-482D-8C28-C5C7C6E9BF07}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
{6561C4EB-18A8-482D-8C28-C5C7C6E9BF07}.Release|Any CPU.Build.0 = Release|Any CPU | |
EndGlobalSection | |
GlobalSection(SolutionProperties) = preSolution | |
HideSolutionNode = FALSE | |
EndGlobalSection | |
GlobalSection(ExtensibilityGlobals) = postSolution | |
SolutionGuid = {8585E7F7-679D-4957-87C8-0258DB0EAC28} | |
EndGlobalSection | |
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using System.Drawing.Drawing2D; | |
using System.IO; | |
namespace ConsoleApp2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var width = 256; | |
var height = 256; | |
var filenames = new string[] { | |
"opaque.png", | |
"transparent.png" | |
}; | |
Directory.CreateDirectory("output"); | |
foreach (var filename in filenames) | |
{ | |
var src = Path.Combine("..", "..", filename); | |
var dst = Path.Combine("output", filename); | |
using (var originalImg = Image.FromFile(src)) | |
{ | |
using (var resizedImg = new Bitmap(width, height)) | |
{ | |
using (var graphics = Graphics.FromImage(resizedImg)) | |
{ | |
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; | |
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; | |
graphics.DrawImage(originalImg, new Rectangle(0, 0, width, height)); | |
resizedImg.Save(dst); | |
} | |
Console.WriteLine("input: " + originalImg.PixelFormat + ", output: " + resizedImg.PixelFormat); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment