Skip to content

Commit d0910ca

Browse files
author
MelonSpeedruns
committed
Base Upload
1 parent 7f40084 commit d0910ca

42 files changed

Lines changed: 2685 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ImgSplit.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.23107.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImgSplit", "ImgSplit\ImgSplit.csproj", "{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

ImgSplit/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>
109 KB
Binary file not shown.

ImgSplit/Form1.Designer.cs

Lines changed: 143 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ImgSplit/Form1.cs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using System.Windows.Forms;
11+
12+
namespace ImgSplit
13+
{
14+
public partial class Form1 : Form
15+
{
16+
public Form1()
17+
{
18+
InitializeComponent();
19+
}
20+
21+
private void button2_Click(object sender, EventArgs e)
22+
{
23+
openFileDialog1.Filter = "Image Files (*.bmp, *.jpg, *.png)|*.bmp;*.jpg;*.png";
24+
DialogResult result = openFileDialog1.ShowDialog();
25+
if (result == DialogResult.OK) // Test result.
26+
{
27+
textBox3.Text = openFileDialog1.FileName;
28+
}
29+
}
30+
31+
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
32+
{
33+
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
34+
(e.KeyChar != '.'))
35+
{
36+
e.Handled = true;
37+
}
38+
39+
// only allow one decimal point
40+
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
41+
{
42+
e.Handled = true;
43+
}
44+
}
45+
46+
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
47+
{
48+
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
49+
(e.KeyChar != '.'))
50+
{
51+
e.Handled = true;
52+
}
53+
54+
// only allow one decimal point
55+
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
56+
{
57+
e.Handled = true;
58+
}
59+
}
60+
61+
private static Image cropImage(Image img, Rectangle cropArea)
62+
{
63+
Bitmap bmpImage = new Bitmap(img);
64+
Bitmap bmpCrop = bmpImage.Clone(cropArea, System.Drawing.Imaging.PixelFormat.DontCare);
65+
return (Image)(bmpCrop);
66+
}
67+
68+
private void button1_Click(object sender, EventArgs e)
69+
{
70+
71+
if (textBox3.Text != "" && textBox2.Text != "" && textBox1.Text != "" && int.Parse(textBox1.Text) > 1 && int.Parse(textBox2.Text) > 1) {
72+
List<Image> list = new List<Image>();
73+
74+
Image img = new Bitmap(openFileDialog1.FileName);
75+
76+
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
77+
{
78+
79+
for (int i = 0; i < int.Parse(textBox1.Text); i++)
80+
{
81+
for (int y = 0; y < int.Parse(textBox2.Text); y++)
82+
{
83+
Rectangle r = new Rectangle(i * (img.Width / int.Parse(textBox1.Text)),
84+
y * (img.Height / int.Parse(textBox2.Text)),
85+
img.Width / int.Parse(textBox1.Text),
86+
img.Height / int.Parse(textBox2.Text));
87+
88+
cropImage(img, r).Save(folderBrowserDialog1.SelectedPath + "/Splitted Image " + i + "-" + y + ".png");
89+
90+
}
91+
}
92+
93+
}
94+
95+
MessageBox.Show("Images splitted successfully!");
96+
}
97+
98+
}
99+
}
100+
}

0 commit comments

Comments
 (0)