Skip to content

Commit 6f83f9c

Browse files
MarkavianMarkavian
Markavian
authored and
Markavian
committed
Updated from version b1 to version c2
0 parents  commit 6f83f9c

14 files changed

+889
-0
lines changed

AssemblyInfo.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Assembly TileMerger, Version 1.0.0.0
2+
3+
[assembly: System.Reflection.AssemblyVersion("1.0.0.0")]
4+
[assembly: System.Runtime.InteropServices.ComVisible(false)]
5+
[assembly: System.Reflection.AssemblyTrademark("")]
6+
[assembly: System.Reflection.AssemblyCopyright("Copyright \x00a9 2008")]
7+
[assembly: System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows=true)]
8+
[assembly: System.Reflection.AssemblyFileVersion("1.0.0.0")]
9+
[assembly: System.Runtime.InteropServices.Guid("449142ad-3e48-4183-a0a9-8ed39a4b5ea8")]
10+
[assembly: System.Reflection.AssemblyConfiguration("")]
11+
[assembly: System.Reflection.AssemblyProduct("ImageMerger")]
12+
[assembly: System.Reflection.AssemblyCompany("")]
13+
[assembly: System.Reflection.AssemblyTitle("ImageMerger")]
14+
[assembly: System.Runtime.CompilerServices.CompilationRelaxations(8)]
15+
[assembly: System.Reflection.AssemblyDescription("")]
16+
[assembly: System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
17+

Global.cs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


ImageMerger.MainForm.resources

180 Bytes
Binary file not shown.
180 Bytes
Binary file not shown.

ImageMerger/ImageLoader.cs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
namespace ImageMerger
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Drawing;
6+
using System.IO;
7+
8+
public class ImageLoader
9+
{
10+
private ImageLoader()
11+
{
12+
throw new Exception("No need to create an object of this class, all its methods are static.");
13+
}
14+
15+
public static void DisposeImages(List<Bitmap> images)
16+
{
17+
foreach (Bitmap bitmap in images)
18+
{
19+
bitmap.Dispose();
20+
}
21+
}
22+
23+
public static List<string> ListFiles(string folderPath, string filter)
24+
{
25+
string[] files = Directory.GetFiles(folderPath);
26+
Array.Sort<string>(files);
27+
List<string> list = new List<string>();
28+
foreach (string str in files)
29+
{
30+
if (filter.Length > 0)
31+
{
32+
if (str.ToLower().Contains(filter))
33+
{
34+
list.Add(str);
35+
}
36+
}
37+
else
38+
{
39+
list.Add(str);
40+
}
41+
}
42+
return list;
43+
}
44+
45+
public static List<Bitmap> LoadImages(List<string> sortedFiles)
46+
{
47+
List<Bitmap> list = new List<Bitmap>();
48+
foreach (string str in sortedFiles)
49+
{
50+
if (File.Exists(str))
51+
{
52+
try
53+
{
54+
Bitmap item = new Bitmap(str);
55+
list.Add(item);
56+
}
57+
catch (Exception)
58+
{
59+
}
60+
Console.WriteLine("{0} loaded.", str);
61+
}
62+
else
63+
{
64+
Console.WriteLine("{0} is not a valid file or directory.", str);
65+
}
66+
}
67+
return list;
68+
}
69+
}
70+
}
71+

ImageMerger/MainForm.cs

+468
Large diffs are not rendered by default.

ImageMerger/Program.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace ImageMerger
2+
{
3+
using System;
4+
using System.Windows.Forms;
5+
6+
internal static class Program
7+
{
8+
[STAThread]
9+
private static void Main()
10+
{
11+
Application.EnableVisualStyles();
12+
Application.SetCompatibleTextRenderingDefault(false);
13+
Application.Run(new MainForm());
14+
}
15+
}
16+
}
17+

ImageMerger/Properties/Resources.cs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
namespace ImageMerger.Properties
2+
{
3+
using System;
4+
using System.CodeDom.Compiler;
5+
using System.ComponentModel;
6+
using System.Diagnostics;
7+
using System.Globalization;
8+
using System.Resources;
9+
using System.Runtime.CompilerServices;
10+
11+
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0"), DebuggerNonUserCode, CompilerGenerated]
12+
internal class Resources
13+
{
14+
private static CultureInfo resourceCulture;
15+
private static System.Resources.ResourceManager resourceMan;
16+
17+
internal Resources()
18+
{
19+
}
20+
21+
[EditorBrowsable(EditorBrowsableState.Advanced)]
22+
internal static CultureInfo Culture
23+
{
24+
get
25+
{
26+
return resourceCulture;
27+
}
28+
set
29+
{
30+
resourceCulture = value;
31+
}
32+
}
33+
34+
[EditorBrowsable(EditorBrowsableState.Advanced)]
35+
internal static System.Resources.ResourceManager ResourceManager
36+
{
37+
get
38+
{
39+
if (object.ReferenceEquals(resourceMan, null))
40+
{
41+
System.Resources.ResourceManager manager = new System.Resources.ResourceManager("ImageMerger.Properties.Resources", typeof(Resources).Assembly);
42+
resourceMan = manager;
43+
}
44+
return resourceMan;
45+
}
46+
}
47+
}
48+
}
49+

ImageMerger/Properties/Settings.cs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace ImageMerger.Properties
2+
{
3+
using System.CodeDom.Compiler;
4+
using System.Configuration;
5+
using System.Runtime.CompilerServices;
6+
7+
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0"), CompilerGenerated]
8+
internal sealed class Settings : ApplicationSettingsBase
9+
{
10+
private static Settings defaultInstance = ((Settings) SettingsBase.Synchronized(new Settings()));
11+
12+
public static Settings Default
13+
{
14+
get
15+
{
16+
return defaultInstance;
17+
}
18+
}
19+
}
20+
}
21+

ImageMerger/TileMerger.cs

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
namespace ImageMerger
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Drawing;
6+
using System.Drawing.Imaging;
7+
using System.IO;
8+
using System.Windows.Forms;
9+
10+
public class TileMerger
11+
{
12+
private int mergedImageCount = 0;
13+
14+
public static Bitmap MergeBitmaps(List<Bitmap> listOfTileBitmaps, int columnCount, bool horizontalTiling)
15+
{
16+
int width = 1;
17+
int height = 1;
18+
foreach (Bitmap sourceTile in listOfTileBitmaps)
19+
{
20+
if (sourceTile.Width > width)
21+
{
22+
width = sourceTile.Width;
23+
}
24+
if (sourceTile.Height > height)
25+
{
26+
height = sourceTile.Height;
27+
}
28+
}
29+
if (columnCount > listOfTileBitmaps.Count)
30+
{
31+
columnCount = listOfTileBitmaps.Count;
32+
}
33+
int rowCount = (int)Math.Ceiling((double)(((double)listOfTileBitmaps.Count) / ((double)columnCount)));
34+
if (!horizontalTiling)
35+
{
36+
int temp = rowCount;
37+
rowCount = columnCount;
38+
columnCount = temp;
39+
}
40+
Bitmap image = new Bitmap(columnCount * width, rowCount * height, PixelFormat.Format32bppArgb);
41+
Graphics graphics = Graphics.FromImage(image);
42+
SolidBrush brush = new SolidBrush(Color.FromArgb(0, 0xff, 240, 200));
43+
graphics.FillRectangle(brush, 0, 0, image.Width, image.Height);
44+
int n = 0;
45+
if (horizontalTiling)
46+
{
47+
foreach (Bitmap tileBitmap in listOfTileBitmaps)
48+
{
49+
int col = (int)Math.Floor((double)(((double)n) / ((double)columnCount)));
50+
int row = n % columnCount;
51+
Point location = new Point(((row * width) + (width / 2)) - (tileBitmap.Width / 2), ((col * height) + (height / 2)) - (tileBitmap.Height / 2));
52+
Size size = new Size(tileBitmap.Width, tileBitmap.Height);
53+
Graphics.FromImage(image).DrawImage(tileBitmap, new Rectangle(location, size));
54+
n++;
55+
}
56+
}
57+
else
58+
{
59+
foreach (Bitmap tileBitmap in listOfTileBitmaps)
60+
{
61+
int row = (int)Math.Floor((double)(((double)n) / ((double)rowCount)));
62+
int col = n % rowCount;
63+
Point location = new Point(((row * width) + (width / 2)) - (tileBitmap.Width / 2), ((col * height) + (height / 2)) - (tileBitmap.Height / 2));
64+
Size size = new Size(tileBitmap.Width, tileBitmap.Height);
65+
Graphics.FromImage(image).DrawImage(tileBitmap, new Rectangle(location, size));
66+
n++;
67+
}
68+
}
69+
return image;
70+
}
71+
72+
public bool ProcessDirectoryToFile(Form parentForm, string directory, string fileTarget, int columnCount, string filter, bool horizontalTiling=true)
73+
{
74+
Bitmap bitmap;
75+
this.mergedImageCount = 0;
76+
if (!Directory.Exists(directory))
77+
{
78+
MessageBox.Show(parentForm, "The specified source directory " + directory + " does not exist.", "Folder not found error", MessageBoxButtons.OK);
79+
return false;
80+
}
81+
if (fileTarget == "")
82+
{
83+
MessageBox.Show(parentForm, "An invalid target file was set.", "Operation stopped", MessageBoxButtons.OK);
84+
return false;
85+
}
86+
List<Bitmap> bitmaps = ImageLoader.LoadImages(ImageLoader.ListFiles(directory, filter));
87+
if (bitmaps.Count == 0)
88+
{
89+
MessageBox.Show(parentForm, "No images were found, could not create merged image.", "Operation stopped", MessageBoxButtons.OK);
90+
return false;
91+
}
92+
try
93+
{
94+
bitmap = MergeBitmaps(bitmaps, columnCount, horizontalTiling);
95+
}
96+
catch (Exception exception)
97+
{
98+
MessageBox.Show(parentForm, exception.Message, "Merge Bitmaps Exception", MessageBoxButtons.OK);
99+
ImageLoader.DisposeImages(bitmaps);
100+
return false;
101+
}
102+
try
103+
{
104+
SaveImage(bitmap, fileTarget);
105+
}
106+
catch (Exception exception2)
107+
{
108+
MessageBox.Show(parentForm, exception2.Message, "Save Image Exception", MessageBoxButtons.OK);
109+
return false;
110+
}
111+
this.mergedImageCount = bitmaps.Count;
112+
ImageLoader.DisposeImages(bitmaps);
113+
return true;
114+
}
115+
116+
public static void SaveImage(Bitmap image, string fileTarget)
117+
{
118+
image.Save(fileTarget, ImageFormat.Png);
119+
}
120+
121+
public int MergedImageCount
122+
{
123+
get
124+
{
125+
return this.mergedImageCount;
126+
}
127+
}
128+
}
129+
}
130+

TileMerger.csproj

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
3+
<PropertyGroup>
4+
<ProjectType>local</ProjectType>
5+
<ProjectVersion>7.10.377</ProjectVersion>
6+
<SchemaVersion>2.0</SchemaVersion>
7+
<ProjectGuid>{BC67FDF1-9E02-4F19-8811-F73FB096A343}</ProjectGuid>
8+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
9+
<AssemblyName>TileMerger</AssemblyName>
10+
<OutputType>WinExe</OutputType>
11+
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
12+
<PublishUrl>publish\</PublishUrl>
13+
<Install>true</Install>
14+
<InstallFrom>Disk</InstallFrom>
15+
<UpdateEnabled>false</UpdateEnabled>
16+
<UpdateMode>Foreground</UpdateMode>
17+
<UpdateInterval>7</UpdateInterval>
18+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
19+
<UpdatePeriodically>false</UpdatePeriodically>
20+
<UpdateRequired>false</UpdateRequired>
21+
<MapFileExtensions>true</MapFileExtensions>
22+
<ApplicationRevision>0</ApplicationRevision>
23+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
24+
<IsWebBootstrapper>false</IsWebBootstrapper>
25+
<UseApplicationTrust>false</UseApplicationTrust>
26+
<BootstrapperEnabled>true</BootstrapperEnabled>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
29+
<PlatformTarget>x86</PlatformTarget>
30+
<DebugSymbols>true</DebugSymbols>
31+
<DebugType>full</DebugType>
32+
<Optimize>false</Optimize>
33+
<OutputPath>bin\Debug\</OutputPath>
34+
<DefineConstants>DEBUG;TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
39+
<PlatformTarget>x86</PlatformTarget>
40+
<DebugType>pdbonly</DebugType>
41+
<Optimize>true</Optimize>
42+
<OutputPath>bin\Release\</OutputPath>
43+
<DefineConstants>TRACE</DefineConstants>
44+
<ErrorReport>prompt</ErrorReport>
45+
<WarningLevel>4</WarningLevel>
46+
</PropertyGroup>
47+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
48+
<ItemGroup>
49+
<Reference Include="System.Windows.Forms" />
50+
<Reference Include="System" />
51+
<Reference Include="System.Drawing" />
52+
<Compile Include="AssemblyInfo.cs" />
53+
<Compile Include="Global.cs" />
54+
<Compile Include="ImageMerger\Program.cs" />
55+
<Compile Include="ImageMerger\MainForm.cs">
56+
<SubType>Form</SubType>
57+
</Compile>
58+
<Compile Include="ImageMerger\Properties\Resources.cs" />
59+
<Compile Include="ImageMerger\ImageLoader.cs" />
60+
<Compile Include="ImageMerger\TileMerger.cs" />
61+
<Compile Include="ImageMerger\Properties\Settings.cs" />
62+
<EmbeddedResource Include="ImageMerger.Properties.Resources.resources" />
63+
<EmbeddedResource Include="ImageMerger.MainForm.resources" />
64+
</ItemGroup>
65+
<ItemGroup>
66+
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
67+
<Visible>False</Visible>
68+
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
69+
<Install>false</Install>
70+
</BootstrapperPackage>
71+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
72+
<Visible>False</Visible>
73+
<ProductName>.NET Framework 3.5 SP1</ProductName>
74+
<Install>true</Install>
75+
</BootstrapperPackage>
76+
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
77+
<Visible>False</Visible>
78+
<ProductName>Windows Installer 3.1</ProductName>
79+
<Install>true</Install>
80+
</BootstrapperPackage>
81+
</ItemGroup>
82+
</Project>

0 commit comments

Comments
 (0)