From c7baff19981e394ceabcb855d7a763b56d0cd10d Mon Sep 17 00:00:00 2001 From: Maxim Maslennikov Date: Tue, 9 May 2017 22:47:45 +0500 Subject: [PATCH 1/8] [feature] add first version --- .gitattributes | 63 +++++ .gitignore | 261 ++++++++++++++++++ SpriteSheetPacker/SpriteSheetPacker.sln | 22 ++ .../SpriteSheetPacker/App.config | 6 + SpriteSheetPacker/SpriteSheetPacker/App.xaml | 17 ++ .../SpriteSheetPacker/App.xaml.cs | 6 + .../Extensions/BitmapExtensions.cs | 21 ++ .../SpriteSheetPacker/Images/images.png | Bin 0 -> 2679 bytes .../SpriteSheetPacker/MainWindow.xaml | 168 +++++++++++ .../SpriteSheetPacker/MainWindow.xaml.cs | 10 + .../SpriteSheetPacker/MainWindowViewModel.cs | 93 +++++++ .../SpriteSheetPacker/Model/ForeignPacker.cs | 34 +++ .../SpriteSheetPacker/Model/IPacker.cs | 10 + .../SpriteSheetPacker/Model/PackParameters.cs | 22 ++ .../Service/ForeignFunctionCaller.cs | 6 + .../SpriteSheetPacker.csproj | 130 +++++++++ .../SpriteSheetPacker/packages.config | 7 + 17 files changed, 876 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 SpriteSheetPacker/SpriteSheetPacker.sln create mode 100644 SpriteSheetPacker/SpriteSheetPacker/App.config create mode 100644 SpriteSheetPacker/SpriteSheetPacker/App.xaml create mode 100644 SpriteSheetPacker/SpriteSheetPacker/App.xaml.cs create mode 100644 SpriteSheetPacker/SpriteSheetPacker/Extensions/BitmapExtensions.cs create mode 100644 SpriteSheetPacker/SpriteSheetPacker/Images/images.png create mode 100644 SpriteSheetPacker/SpriteSheetPacker/MainWindow.xaml create mode 100644 SpriteSheetPacker/SpriteSheetPacker/MainWindow.xaml.cs create mode 100644 SpriteSheetPacker/SpriteSheetPacker/MainWindowViewModel.cs create mode 100644 SpriteSheetPacker/SpriteSheetPacker/Model/ForeignPacker.cs create mode 100644 SpriteSheetPacker/SpriteSheetPacker/Model/IPacker.cs create mode 100644 SpriteSheetPacker/SpriteSheetPacker/Model/PackParameters.cs create mode 100644 SpriteSheetPacker/SpriteSheetPacker/Service/ForeignFunctionCaller.cs create mode 100644 SpriteSheetPacker/SpriteSheetPacker/SpriteSheetPacker.csproj create mode 100644 SpriteSheetPacker/SpriteSheetPacker/packages.config diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/SpriteSheetPacker/SpriteSheetPacker.sln b/SpriteSheetPacker/SpriteSheetPacker.sln new file mode 100644 index 0000000..f4a9609 --- /dev/null +++ b/SpriteSheetPacker/SpriteSheetPacker.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.7 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpriteSheetPacker", "SpriteSheetPacker\SpriteSheetPacker.csproj", "{C982C4E3-4DC5-4159-91DF-C59383B2BD36}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C982C4E3-4DC5-4159-91DF-C59383B2BD36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C982C4E3-4DC5-4159-91DF-C59383B2BD36}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C982C4E3-4DC5-4159-91DF-C59383B2BD36}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C982C4E3-4DC5-4159-91DF-C59383B2BD36}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SpriteSheetPacker/SpriteSheetPacker/App.config b/SpriteSheetPacker/SpriteSheetPacker/App.config new file mode 100644 index 0000000..bae5d6d --- /dev/null +++ b/SpriteSheetPacker/SpriteSheetPacker/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/SpriteSheetPacker/SpriteSheetPacker/App.xaml b/SpriteSheetPacker/SpriteSheetPacker/App.xaml new file mode 100644 index 0000000..e2be4a0 --- /dev/null +++ b/SpriteSheetPacker/SpriteSheetPacker/App.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SpriteSheetPacker/SpriteSheetPacker/App.xaml.cs b/SpriteSheetPacker/SpriteSheetPacker/App.xaml.cs new file mode 100644 index 0000000..02a4bca --- /dev/null +++ b/SpriteSheetPacker/SpriteSheetPacker/App.xaml.cs @@ -0,0 +1,6 @@ +namespace SpriteSheetPacker +{ + public partial class App + { + } +} diff --git a/SpriteSheetPacker/SpriteSheetPacker/Extensions/BitmapExtensions.cs b/SpriteSheetPacker/SpriteSheetPacker/Extensions/BitmapExtensions.cs new file mode 100644 index 0000000..71a194f --- /dev/null +++ b/SpriteSheetPacker/SpriteSheetPacker/Extensions/BitmapExtensions.cs @@ -0,0 +1,21 @@ +using System; +using System.Drawing; +using System.Windows.Interop; +using System.Windows.Media.Imaging; + +namespace SpriteSheetPacker.Extensions +{ + internal static class BitmapExtensions + { + public static BitmapSource ToBitmapSource(this Bitmap bitmap) + { + var bitmapSourceFromHBitmap = Imaging.CreateBitmapSourceFromHBitmap( + bitmap.GetHbitmap(), + IntPtr.Zero, + System.Windows.Int32Rect.Empty, + BitmapSizeOptions.FromWidthAndHeight(bitmap.Width, bitmap.Height)); + + return bitmapSourceFromHBitmap; + } + } +} diff --git a/SpriteSheetPacker/SpriteSheetPacker/Images/images.png b/SpriteSheetPacker/SpriteSheetPacker/Images/images.png new file mode 100644 index 0000000000000000000000000000000000000000..81e4a7e07113c192acf3be81555ef9ae21928cfe GIT binary patch literal 2679 zcmZuzYdq5n82)d=He1%@wy>CzLXKSU*I~?q7PHrps9}!~P zy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 0 HcmV?d00001 diff --git a/SpriteSheetPacker/SpriteSheetPacker/MainWindow.xaml b/SpriteSheetPacker/SpriteSheetPacker/MainWindow.xaml new file mode 100644 index 0000000..9729f12 --- /dev/null +++ b/SpriteSheetPacker/SpriteSheetPacker/MainWindow.xaml @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +