├── ImageShrinker ├── WP_IconMaker.ico ├── app.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── app.manifest │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── App.xaml ├── App.xaml.cs ├── Window1.xaml ├── WP_IconMaker.csproj └── Window1.xaml.cs ├── .gitattributes ├── WP_IconMaker.sln ├── .gitignore └── README.md /ImageShrinker/WP_IconMaker.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavidBurela/WindowsMarketplaceIconMaker/HEAD/ImageShrinker/WP_IconMaker.ico -------------------------------------------------------------------------------- /ImageShrinker/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ImageShrinker/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ImageShrinker/App.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /WP_IconMaker.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WP_IconMaker", "ImageShrinker\WP_IconMaker.csproj", "{945A2F41-1EEB-4D77-8516-D7A757ACE0D8}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {945A2F41-1EEB-4D77-8516-D7A757ACE0D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {945A2F41-1EEB-4D77-8516-D7A757ACE0D8}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {945A2F41-1EEB-4D77-8516-D7A757ACE0D8}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {945A2F41-1EEB-4D77-8516-D7A757ACE0D8}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /ImageShrinker/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Windows; 7 | using System.Globalization; 8 | 9 | namespace ImageShrinker 10 | { 11 | /// 12 | /// App.xaml の相互作用ロジック 13 | /// 14 | public partial class App : Application 15 | { 16 | public static string Language; 17 | /// 18 | /// コマンドラインを処理するスタートアップ 19 | /// 20 | void app_Startup(object sender, StartupEventArgs e) 21 | { 22 | if (e.Args.Length == 0) return; 23 | foreach (string argument in e.Args) 24 | { 25 | if (argument.Contains("-E") || argument.Contains("-e")) 26 | { 27 | Language = "English"; 28 | //vga.Save(); 29 | } 30 | else if (argument.Contains("-J") || argument.Contains("-j")) 31 | { 32 | Language = "Japanese"; 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ImageShrinker/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18010 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace IconMaker.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ImageShrinker/Properties/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ImageShrinker/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 8 | // アセンブリに関連付けられている情報を変更するには、 9 | // これらの属性値を変更してください。 10 | [assembly: AssemblyTitle("ImageShrinker")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("Microsoft")] 14 | [assembly: AssemblyProduct("ImageShrinker")] 15 | [assembly: AssemblyCopyright("Copyright © Microsoft 2009")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから 20 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、 21 | // その型の ComVisible 属性を true に設定してください。 22 | [assembly: ComVisible(false)] 23 | 24 | //ローカライズ可能なアプリケーションのビルドを開始するには、 25 | //.csproj ファイルの CultureYouAreCodingWith を 26 | // 内部で設定します。たとえば、 27 | //ソース ファイルで英語を使用している場合、 を en-US に設定します。次に、 28 | //下の NeutralResourceLanguage 属性のコメントを解除します。下の行の "en-US" を 29 | //プロジェクト ファイルの UICulture 設定と一致するよう更新します。 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //テーマ固有のリソース ディクショナリが置かれている場所 36 | //(リソースがページ、 37 | //またはアプリケーション リソース ディクショナリに見つからない場合に使用されます) 38 | ResourceDictionaryLocation.SourceAssembly //汎用リソース ディクショナリが置かれている場所 39 | //(リソースがページ、 40 | //アプリケーション、またはいずれのテーマ固有のリソース ディクショナリにも見つからない場合に使用されます) 41 | )] 42 | 43 | 44 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を 52 | // 既定値にすることができます: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.1.0.0")] 55 | [assembly: AssemblyFileVersion("1.1.0.0")] 56 | [assembly: NeutralResourcesLanguageAttribute("ja-JP")] 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Windows Store Icon Maker 2 | ============= 3 | 4 | When creating applications for the Windows stores (RT & Phone), there are numerous icons that need to be created. This utility to help generate all the required icon sizes, including the scaled versions for higher DPI devices. 5 | 6 | Downloading 7 | -------- 8 | Compiled versions can be found under [releases](https://github.com/DavidBurela/WindowsMarketplaceIconMaker/releases) 9 | 10 | Usage 11 | -------- 12 | 1. Drag and drop an image onto the workspace. 13 | 2. Select the region of the image you want to crop 14 | 3. Click *Save* to have the icons be generated 15 | 16 | It is recommended to use an image that is at least 300x300 for best results. 17 | 18 | Features 19 | -------- 20 | * Automatically generate icons for: 21 | * Windows Phone 7 22 | * Windows Phone 8 23 | * Windows Store Applications 24 | 25 | ###Generated icons 26 | **Windows Phone 7** 27 | 28 | * StoreTile.png (300x300) 29 | * BackgroundImage.png (173x173) 30 | * ApplicationIcon.png (62x62) 31 | 32 | 33 | **Windows Phone 8** 34 | 35 | * ApplicationIcon.png (100x100) 36 | * ~~FlipCycleTileLarge.png (691x336)~~ 37 | * FlipCycleTileMedium.png (336x336) 38 | * FlipCycleTileSmall.png (159x159) 39 | * ~~IconicTileMediumLarge.png (134x202)~~ 40 | * ~~IconicTileSmall.png (71x110)~~ 41 | 42 | **Windows Store Application** 43 | 44 | * Logo 45 | * Logo.scale-180.png (270x270) 46 | * Logo.scale-140.png (210x210) 47 | * Logo.scale-100.png (150x150) 48 | * Logo.scale-80.png (120x12) 49 | * SmallLogo 50 | * SmallLogo.scale-180.png (54x54) 51 | * SmallLogo.scale-140.png (42x42) 52 | * SmallLogo.scale-100.png (30x30) 53 | * SmallLogo.scale-80.png (24x24) 54 | * SmallLogo.target-256.png (256x256) 55 | * SmallLogo.target-48.png (48x48) 56 | * SmallLogo.target-32.png (32x32) 57 | * SmallLogo.target-16.png (16x16) 58 | * StoreLogo 59 | * StoreLogo.scale-180.png (90x90) 60 | * StoreLogo.scale-140.png (70x70) 61 | * StoreLogo.scale-100.png (50x50) 62 | 63 | Building 64 | -------- 65 | I develop and compile this using Visual Studio 2012 Ultimate. 66 | However if you are using Visual Studio Express to developer, there are reports that you can use [Visual Studio Express 2012 for Desktop](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-desktop) to compile it. 67 | 68 | Acknowledgments 69 | -------- 70 | This utility is based off the original source code of [Windows Phone Icons Maker](http://wpiconmaker.codeplex.com/) by [Hiroyuki Kawanishi](http://www.codeplex.com/site/users/view/hiroyuk). The source code had not been updated since September 2011, so I decided to fork it and update it to support the new platforms (WP7/WP8/WinRT). 71 | 72 | License 73 | -------- 74 | The code is MS-PL as that is what the original source code was licensed as. 75 | [http://wpiconmaker.codeplex.com/license](http://wpiconmaker.codeplex.com/license) 76 | 77 | -------------------------------------------------------------------------------- /ImageShrinker/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18010 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace IconMaker.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IconMaker.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /ImageShrinker/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /ImageShrinker/Window1.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Logo.scale-___.png 72 | 73 | 74 | 75 | 76 | 77 | SmallLogo.scale-___.png 78 | 79 | 80 | 81 | 82 | SmallLogo.target-___.png 83 | 84 | 85 | 86 | 87 | 88 | StoreLogo.scale-___.png 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /ImageShrinker/WP_IconMaker.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {945A2F41-1EEB-4D77-8516-D7A757ACE0D8} 9 | WinExe 10 | Properties 11 | IconMaker 12 | WP_IconMaker 13 | v4.5 14 | 512 15 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 16 | 4 17 | false 18 | C8C09AD85DEF54C699E5C745FE12CE697086BB7B 19 | ImageShrinker_TemporaryKey.pfx 20 | false 21 | LocalIntranet 22 | false 23 | WP_IconMaker.ico 24 | Properties\app.manifest 25 | 26 | 27 | 3.5 28 | 29 | 30 | 31 | publish\ 32 | true 33 | Disk 34 | false 35 | Foreground 36 | 7 37 | Days 38 | false 39 | false 40 | true 41 | 1 42 | 2.2.0.%2a 43 | false 44 | true 45 | 46 | 47 | true 48 | full 49 | false 50 | bin\Debug\ 51 | DEBUG;TRACE 52 | prompt 53 | 4 54 | AllRules.ruleset 55 | false 56 | 57 | 58 | pdbonly 59 | true 60 | bin\Release\ 61 | TRACE 62 | prompt 63 | 4 64 | AllRules.ruleset 65 | false 66 | 67 | 68 | 69 | 70 | 71 | 3.5 72 | 73 | 74 | 75 | 76 | 77 | 78 | 3.5 79 | 80 | 81 | 3.5 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | MSBuild:Compile 95 | Designer 96 | MSBuild:Compile 97 | Designer 98 | 99 | 100 | MSBuild:Compile 101 | Designer 102 | MSBuild:Compile 103 | Designer 104 | 105 | 106 | App.xaml 107 | Code 108 | 109 | 110 | Window1.xaml 111 | Code 112 | 113 | 114 | 115 | 116 | Code 117 | 118 | 119 | True 120 | True 121 | Resources.resx 122 | 123 | 124 | True 125 | Settings.settings 126 | True 127 | 128 | 129 | ResXFileCodeGenerator 130 | Resources.Designer.cs 131 | Designer 132 | 133 | 134 | 135 | 136 | SettingsSingleFileGenerator 137 | Settings.Designer.cs 138 | 139 | 140 | 141 | 142 | 143 | False 144 | .NET Framework 3.5 SP1 Client Profile 145 | false 146 | 147 | 148 | False 149 | .NET Framework 2.0 %28x86%29 150 | false 151 | 152 | 153 | False 154 | .NET Framework 3.0 %28x86%29 155 | false 156 | 157 | 158 | False 159 | .NET Framework 3.5 160 | true 161 | 162 | 163 | False 164 | .NET Framework 3.5 SP1 165 | false 166 | 167 | 168 | False 169 | Windows インストーラー 3.1 170 | true 171 | 172 | 173 | 174 | 175 | 176 | 177 | 184 | -------------------------------------------------------------------------------- /ImageShrinker/Window1.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Windows.Input; 7 | using System.IO; 8 | using System.Windows.Media; 9 | using System.Windows.Media.Imaging; 10 | using System.Windows.Shapes; 11 | using System.Globalization; 12 | using System.Windows.Media.Animation; 13 | 14 | namespace ImageShrinker 15 | { 16 | /// 17 | /// Window1.xaml の相互作用ロジック 18 | /// 19 | public partial class Window1 : Window 20 | { 21 | public Window1() 22 | { 23 | InitializeComponent(); 24 | 25 | RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality); 26 | } 27 | 28 | #region InitializeText 29 | private string notice1 = "Trim area to be Icon by Mouse"; 30 | private string notice2 = "Click [Save Icons] button if satisfied"; 31 | private string notice3 = "Created folder and Save Completed"; 32 | private string openFilter = "Image Files (*.png, *.jpg)|*.png;*.jpg|All files (*.*)|*.*"; 33 | private string openFolder = "Icons with same project name are already exist, please change your project name"; 34 | private string notice4 = "Please load .PNG or .JPG"; 35 | private string notice5 = "Fail to make icons, Trim area to be Icon by Mouse"; 36 | private bool IsPasted = false; 37 | private bool IsJapanese = false; 38 | 39 | private void Window_Loaded(object sender, RoutedEventArgs e) 40 | { 41 | if (CultureInfo.CurrentUICulture.Name == "ja-JP" || App.Language == "Japanese") IsJapanese = true; 42 | if (App.Language == "English") IsJapanese = false; 43 | if (IsJapanese) 44 | { 45 | Save.Content = "アイコン保存"; 46 | Open.Content = "画像を開く"; 47 | projectLabel.Content = "プロジェクト名"; 48 | CompleteNotice.Content = "クリップボードからコピー&貼り付けするか、画像をドラッグ&ドロップするか、[画像を開く]をクリック"; 49 | notice1 = "アイコンにしたい部分をマウスで囲む"; 50 | notice2 = "気に入ったら[アイコン保存]ボタンをクリック"; 51 | notice3 = "フォルダーを作成し、保存しました"; 52 | notice4 = "PNG ファイルか JPG ファイルをロードしてください"; 53 | notice5 = "アイコン作成に失敗、" + notice1; 54 | openFilter = "画像ファイル (*.png, *.jpg)|*.png;*.jpg|すべてのファイル (*.*)|*.*"; 55 | openFolder = "同じプロジェクト名のアイコンが既にあります、別のプロジェクト名に変更してください"; 56 | } 57 | } 58 | #endregion InitializeText 59 | 60 | #region OpenImage 61 | 62 | private void Open_Click(object sender, RoutedEventArgs e) 63 | { 64 | Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); 65 | dlg.Filter = openFilter; 66 | 67 | Nullable result = dlg.ShowDialog(); 68 | 69 | if (result.Value) 70 | { 71 | ShowImage(dlg.FileName); 72 | } 73 | IsPasted = false; 74 | } 75 | 76 | /// 77 | /// Handle Copy & Past (ctrl+V) 78 | /// 79 | /// 80 | /// 81 | private void Window_PreviewKeyDown(object sender, KeyEventArgs e) 82 | { 83 | if ((e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl)) && (e.Key == Key.V)) 84 | { 85 | if (Clipboard.ContainsImage()) 86 | { 87 | BitmapSource source = Clipboard.GetImage(); 88 | ShowImage(source); 89 | } 90 | } 91 | 92 | } 93 | #endregion OpenImage 94 | 95 | #region ShowImage 96 | 97 | // Show Image for Copy & Paste 98 | private void ShowImage(BitmapSource source) 99 | { 100 | projectName.Text = "MyProject"; 101 | fileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\MyProject"; 102 | BmpBitmapEncoder encoder = new BmpBitmapEncoder(); 103 | MemoryStream memoryStream = new MemoryStream(); 104 | imageSource = new BitmapImage(); 105 | encoder.Frames.Add(BitmapFrame.Create(source)); 106 | encoder.Save(memoryStream); 107 | imageSource.BeginInit(); 108 | imageSource.StreamSource = new MemoryStream(memoryStream.ToArray()); 109 | imageSource.EndInit(); memoryStream.Close(); 110 | 111 | grayImage.Source = imageSource; 112 | if (imageSource.PixelHeight < 600 && imageSource.PixelWidth < 800) 113 | { 114 | grayImage.Width = imageSource.PixelWidth; 115 | grayImage.Height = imageSource.PixelHeight; 116 | } 117 | else 118 | { 119 | grayImage.Width = 800; 120 | grayImage.Height = 600; 121 | } 122 | NewImageDisplayed(); 123 | } 124 | 125 | // Show Image for file load and drag 126 | private void ShowImage(string filename) 127 | { 128 | fileName = filename; 129 | imageSource = new BitmapImage(); 130 | imageSource.BeginInit(); 131 | imageSource.UriSource = new Uri(fileName); 132 | imageSource.EndInit(); 133 | 134 | grayImage.Source = imageSource; 135 | if (imageSource.PixelHeight < 600 && imageSource.PixelWidth < 800) 136 | { 137 | grayImage.Width = imageSource.PixelWidth; 138 | grayImage.Height = imageSource.PixelHeight; 139 | } 140 | else 141 | { 142 | grayImage.Width = 800; 143 | grayImage.Height = 600; 144 | } 145 | NewImageDisplayed(); 146 | } 147 | 148 | #endregion ShowImage 149 | 150 | #region SaveIcons 151 | private async void Save_Click(object sender, RoutedEventArgs e) 152 | { 153 | if (Wp7Icon300.Fill != null) 154 | { 155 | // due to virtualisation, WPF doesn't render each tab until the SelectedIndex changes 156 | // This is a little hack using .Net 4.5 awaitable, it will change the tab, yield back to the UI renderer, then continue. 157 | var currentIndex = iconTabControl.SelectedIndex; 158 | iconTabControl.SelectedIndex = 0; 159 | await Task.Delay(100); 160 | iconTabControl.SelectedIndex = 1; 161 | await Task.Delay(100); 162 | iconTabControl.SelectedIndex = 2; 163 | await Task.Delay(100); 164 | iconTabControl.SelectedIndex = currentIndex; 165 | 166 | string path = System.IO.Path.GetDirectoryName(this.fileName); 167 | GenerateWp7Icons(path); 168 | GenerateWp8Icons(path); 169 | GenerateWin8Icons(path); 170 | 171 | string folder = "On same folder with your image"; 172 | if (IsPasted) folder = "On your desktop"; 173 | if (IsJapanese) 174 | { 175 | folder = "画像と同じフォルダーに"; 176 | if (IsPasted) folder = "デスクトップに"; 177 | } 178 | 179 | CompleteNotice.Content = folder + projectName.Text + " Icons" + notice3; 180 | CompleteNotice.Visibility = Visibility.Visible; 181 | 182 | Storyboard effect = (Storyboard)this.FindResource("Storyboard1"); 183 | BeginStoryboard(effect); 184 | } 185 | else 186 | { 187 | CompleteNotice.Content = notice5; 188 | } 189 | 190 | } 191 | 192 | private void GenerateWp7Icons(string path) 193 | { 194 | // Create the folder if needed 195 | path = path + "\\" + projectName.Text + " WP7 Icons"; 196 | if (!Directory.Exists(path)) 197 | { 198 | Directory.CreateDirectory(path); 199 | } 200 | 201 | // Generate the icons 202 | EncodeAndSave(Wp7Icon300, "StoreIcon.png", path); 203 | EncodeAndSave(Wp7Icon173, "Background.png", path); 204 | EncodeAndSave(Wp7Icon62, "ApplicationIcon.png", path); 205 | } 206 | 207 | private void GenerateWp8Icons(string path) 208 | { 209 | // Create the folder if needed 210 | path = path + "\\" + projectName.Text + " WP8 Icons"; 211 | if (!Directory.Exists(path)) 212 | { 213 | Directory.CreateDirectory(path); 214 | } 215 | 216 | // Generate the icons 217 | EncodeAndSave(Wp8AppIcon, "ApplicationIcon.png", path); 218 | EncodeAndSave(Wp8FlipMedium, "FlipCycleTileMedium.png", path); 219 | EncodeAndSave(Wp8FlipSmall, "FlipCycleTileSmall.png", path); 220 | } 221 | 222 | private void GenerateWin8Icons(string path) 223 | { 224 | // Create the folder if needed 225 | path = path + "\\" + projectName.Text + " Win8 Icons"; 226 | if (!Directory.Exists(path)) 227 | { 228 | Directory.CreateDirectory(path); 229 | } 230 | 231 | // Generate the icons 232 | EncodeAndSave(Win8Logo180, "Logo.scale-180.png", path); 233 | EncodeAndSave(Win8Logo140, "Logo.scale-140.png", path); 234 | EncodeAndSave(Win8Logo100, "Logo.scale-100.png", path); 235 | EncodeAndSave(Win8Logo80, "Logo.scale-80.png", path); 236 | 237 | EncodeAndSave(Win8SmallLogo180, "SmallLogo.scale-180.png", path); 238 | EncodeAndSave(Win8SmallLogo140, "SmallLogo.scale-140.png", path); 239 | EncodeAndSave(Win8SmallLogo100, "SmallLogo.scale-100.png", path); 240 | EncodeAndSave(Win8SmallLogo80, "SmallLogo.scale-80.png", path); 241 | 242 | EncodeAndSave(Win8SmallLogoTarget256, "SmallLogo.target-256.png", path); 243 | EncodeAndSave(Win8SmallLogoTarget48, "SmallLogo.target-48.png", path); 244 | EncodeAndSave(Win8SmallLogoTarget32, "SmallLogo.target-32.png", path); 245 | EncodeAndSave(Win8SmallLogoTarget16, "SmallLogo.target-16.png", path); 246 | 247 | EncodeAndSave(Win8StoreLogo180, "StoreLogo.scale-180.png", path); 248 | EncodeAndSave(Win8StoreLogo140, "StoreLogo.scale-140.png", path); 249 | EncodeAndSave(Win8StoreLogo100, "StoreLogo.scale-100.png", path); 250 | } 251 | 252 | private void EncodeAndSave(FrameworkElement icon, string name, string filePath) 253 | { 254 | // Create BitmapFrame for Icon 255 | var rtb = new RenderTargetBitmap((int)icon.Width, (int)icon.Height, 96.0, 96.0, PixelFormats.Pbgra32); 256 | 257 | // Use DrawingGroup for high quality rendering 258 | // See: http://www.olsonsoft.com/blogs/stefanolson/post/Workaround-for-low-quality-bitmap-resizing-in-WPF-4.aspx 259 | var group = new DrawingGroup(); 260 | RenderOptions.SetBitmapScalingMode(group, BitmapScalingMode.HighQuality); 261 | group.Children.Add(new ImageDrawing(imageSource, new Rect(new Point(), new Size((int)icon.Width, (int)icon.Height)))); 262 | 263 | var dv = new DrawingVisual(); 264 | using (DrawingContext dc = dv.RenderOpen()) 265 | dc.DrawDrawing(group); 266 | 267 | rtb.Render(dv); 268 | BitmapFrame bmf = BitmapFrame.Create(rtb); 269 | bmf.Freeze(); 270 | //Icon200.Fill = new ImageBrush(bmf) ; 271 | //string filePath = System.IO.Path.GetDirectoryName(this.fileName); 272 | string fileOut = filePath + "\\" + name; 273 | FileStream stream = new FileStream(fileOut, FileMode.Create); 274 | 275 | // PNGにエンコード 276 | PngBitmapEncoder encoder = new PngBitmapEncoder(); 277 | encoder.Frames.Add(bmf); 278 | encoder.Save(stream); 279 | stream.Close(); 280 | } 281 | 282 | #endregion SaveIcons 283 | 284 | #region DragAndDrop 285 | 286 | private string fileName; 287 | BitmapImage imageSource; 288 | double scale = 1.0; 289 | 290 | private void myImage_Drop(object sender, DragEventArgs e) 291 | { 292 | e.Handled = true; 293 | string draggedFileName = IsSingleFile(e); 294 | 295 | if (draggedFileName.Contains(".png") || draggedFileName.Contains(".PNG") || draggedFileName.Contains(".jpg") || draggedFileName.Contains(".JPG")) 296 | { 297 | //MessageBoxResult mbr = MessageBoxResult.OK; 298 | //if (fileName != null) 299 | // mbr = System.Windows.MessageBox.Show("表示されている画像と入れ替えますか?", "relace ?", MessageBoxButton.OKCancel); 300 | 301 | //if (mbr == MessageBoxResult.OK) 302 | //{ 303 | ShowImage(draggedFileName); 304 | //} 305 | IsPasted = false; 306 | } 307 | else 308 | { 309 | System.Windows.MessageBox.Show(notice4, "Please drag png/jpg file", MessageBoxButton.OK); 310 | } 311 | 312 | } 313 | 314 | private void grayImage_SizeChanged(object sender, SizeChangedEventArgs e) 315 | { 316 | NewImageDisplayed(); 317 | } 318 | private void NewImageDisplayed() 319 | { 320 | scale = imageSource.Width / grayImage.ActualWidth; 321 | string name = System.IO.Path.GetFileNameWithoutExtension(fileName); 322 | projectName.Text = name; 323 | CompleteNotice.Content = notice1; 324 | 325 | // WP7 326 | Wp7Icon300.Fill = null; 327 | Wp7Icon173.Fill = null; 328 | Wp7Icon62.Fill = null; 329 | 330 | // WP8 331 | Wp8AppIcon.Fill = null; 332 | Wp8FlipMedium.Fill = null; 333 | Wp8FlipSmall.Fill = null; 334 | 335 | // Win8 336 | Win8Logo180.Fill = null; 337 | Win8Logo140.Fill = null; 338 | Win8Logo100.Fill = null; 339 | Win8Logo80.Fill = null; 340 | 341 | Win8SmallLogo180.Fill = null; 342 | Win8SmallLogo140.Fill = null; 343 | Win8SmallLogo100.Fill = null; 344 | Win8SmallLogo80.Fill = null; 345 | Win8SmallLogoTarget256.Fill = null; 346 | Win8SmallLogoTarget48.Fill = null; 347 | Win8SmallLogoTarget32.Fill = null; 348 | Win8SmallLogoTarget16.Fill = null; 349 | 350 | Win8StoreLogo180.Fill = null; 351 | Win8StoreLogo140.Fill = null; 352 | Win8StoreLogo100.Fill = null; 353 | 354 | myCanvas.Children.Remove(rectFrame); 355 | 356 | UpdatePreviewIcons(new Point(0, 0), new Point(imageSource.Width, imageSource.Height)); 357 | } 358 | 359 | private string IsSingleFile(DragEventArgs args) 360 | { 361 | // データオブジェクト内のファイルをチェック 362 | if (args.Data.GetDataPresent(DataFormats.FileDrop, true)) 363 | { 364 | string[] fileNames = args.Data.GetData(DataFormats.FileDrop, true) as string[]; 365 | // 単一ファイル/フォルダをチェック 366 | if (fileNames.Length == 1) 367 | { 368 | // ファイルをチェック(ディレクトリはfalseを返す) 369 | if (File.Exists(fileNames[0])) 370 | { 371 | // この時点で単一ファイルであることが分かる 372 | return fileNames[0]; 373 | } 374 | } 375 | } 376 | return null; 377 | } 378 | 379 | private void myImage_PreviewDragOver(object sender, DragEventArgs args) 380 | { 381 | // 単一ファイルだけを処理したい 382 | if (IsSingleFile(args) != null) args.Effects = DragDropEffects.Copy; 383 | else args.Effects = DragDropEffects.None; 384 | 385 | // イベントをHandledに、するとDragOverハンドラがキャンセルされる 386 | args.Handled = true; 387 | } 388 | #endregion DragAndDrop 389 | 390 | #region MouseMove 391 | private Point p1 = new Point(); 392 | private Point p2 = new Point(); 393 | 394 | 395 | private void myCanvas_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) 396 | { 397 | CompleteNotice.Content = notice2; 398 | } 399 | /// 400 | /// マウス左ボタン押下用のコールバック 401 | /// 402 | private void UC_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 403 | { 404 | p1 = e.GetPosition(grayImage); 405 | CompleteNotice.Content = notice1; 406 | } 407 | private Rectangle rectFrame = new Rectangle(); 408 | 409 | /// 410 | /// マウス移動用のコールバック 411 | /// 412 | private void UC_MouseMove(object sender, MouseEventArgs e) 413 | { 414 | p2 = e.GetPosition(grayImage); 415 | if (e.LeftButton == MouseButtonState.Pressed) 416 | { 417 | double w = Math.Abs(p1.X - p2.X); 418 | double h = Math.Abs(p1.Y - p2.Y); 419 | if (w > h) 420 | p2.Y = (p2.Y > p1.Y) ? p1.Y + w : p1.Y - w; 421 | else 422 | p2.X = (p2.X > p1.X) ? p1.X + h : p1.X - w; 423 | 424 | Point lt = new Point((p1.X > p2.X) ? p2.X : p1.X, (p1.Y > p2.Y) ? p2.Y : p1.Y); 425 | Point rb = new Point((p1.X > p2.X) ? p1.X : p2.X, (p1.Y > p2.Y) ? p1.Y : p2.Y); 426 | 427 | // rabber band 428 | myCanvas.Children.Remove(rectFrame); 429 | rectFrame.Stroke = Brushes.Gray; 430 | rectFrame.StrokeThickness = 1.0; 431 | rectFrame.Width = rb.X - lt.X; 432 | rectFrame.Height = rb.Y - lt.Y; 433 | rectFrame.RenderTransform = new TranslateTransform(lt.X, lt.Y); 434 | myCanvas.Children.Add(rectFrame); 435 | 436 | UpdatePreviewIcons(lt, rb); 437 | } 438 | } 439 | 440 | private void UpdatePreviewIcons(Point lt, Point rb) { 441 | // Icon Images 442 | Point sourceLt = new Point(lt.X*scale, lt.Y*scale); 443 | Point sourceRb = new Point(rb.X*scale, rb.Y*scale); 444 | 445 | ImageBrush brush = new ImageBrush(); 446 | brush.ImageSource = imageSource; 447 | brush.Viewbox = new Rect(sourceLt, sourceRb); 448 | brush.ViewboxUnits = BrushMappingMode.Absolute; 449 | brush.Stretch = Stretch.Fill; 450 | 451 | // WP7 452 | Wp7Icon300.Fill = brush; 453 | Wp7Icon173.Fill = brush; 454 | Wp7Icon62.Fill = brush; 455 | 456 | // WP8 457 | Wp8AppIcon.Fill = brush; 458 | Wp8FlipMedium.Fill = brush; 459 | Wp8FlipSmall.Fill = brush; 460 | 461 | // Win8 462 | Win8Logo180.Fill = brush; 463 | Win8Logo140.Fill = brush; 464 | Win8Logo100.Fill = brush; 465 | Win8Logo80.Fill = brush; 466 | 467 | Win8SmallLogo180.Fill = brush; 468 | Win8SmallLogo140.Fill = brush; 469 | Win8SmallLogo100.Fill = brush; 470 | Win8SmallLogo80.Fill = brush; 471 | Win8SmallLogoTarget256.Fill = brush; 472 | Win8SmallLogoTarget48.Fill = brush; 473 | Win8SmallLogoTarget32.Fill = brush; 474 | Win8SmallLogoTarget16.Fill = brush; 475 | 476 | Win8StoreLogo180.Fill = brush; 477 | Win8StoreLogo140.Fill = brush; 478 | Win8StoreLogo100.Fill = brush; 479 | } 480 | 481 | #endregion MouseMove 482 | 483 | } 484 | } 485 | --------------------------------------------------------------------------------