-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MelonSpeedruns
committed
May 31, 2016
1 parent
7f40084
commit d0910ca
Showing
42 changed files
with
2,685 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.23107.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImgSplit", "ImgSplit\ImgSplit.csproj", "{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{0FE6C802-C5C4-49E8-A79A-E9CBAD37EC08}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
</configuration> |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace ImgSplit | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void button2_Click(object sender, EventArgs e) | ||
{ | ||
openFileDialog1.Filter = "Image Files (*.bmp, *.jpg, *.png)|*.bmp;*.jpg;*.png"; | ||
DialogResult result = openFileDialog1.ShowDialog(); | ||
if (result == DialogResult.OK) // Test result. | ||
{ | ||
textBox3.Text = openFileDialog1.FileName; | ||
} | ||
} | ||
|
||
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) | ||
{ | ||
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && | ||
(e.KeyChar != '.')) | ||
{ | ||
e.Handled = true; | ||
} | ||
|
||
// only allow one decimal point | ||
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1)) | ||
{ | ||
e.Handled = true; | ||
} | ||
} | ||
|
||
private void textBox2_KeyPress(object sender, KeyPressEventArgs e) | ||
{ | ||
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && | ||
(e.KeyChar != '.')) | ||
{ | ||
e.Handled = true; | ||
} | ||
|
||
// only allow one decimal point | ||
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1)) | ||
{ | ||
e.Handled = true; | ||
} | ||
} | ||
|
||
private static Image cropImage(Image img, Rectangle cropArea) | ||
{ | ||
Bitmap bmpImage = new Bitmap(img); | ||
Bitmap bmpCrop = bmpImage.Clone(cropArea, System.Drawing.Imaging.PixelFormat.DontCare); | ||
return (Image)(bmpCrop); | ||
} | ||
|
||
private void button1_Click(object sender, EventArgs e) | ||
{ | ||
|
||
if (textBox3.Text != "" && textBox2.Text != "" && textBox1.Text != "" && int.Parse(textBox1.Text) > 1 && int.Parse(textBox2.Text) > 1) { | ||
List<Image> list = new List<Image>(); | ||
|
||
Image img = new Bitmap(openFileDialog1.FileName); | ||
|
||
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) | ||
{ | ||
|
||
for (int i = 0; i < int.Parse(textBox1.Text); i++) | ||
{ | ||
for (int y = 0; y < int.Parse(textBox2.Text); y++) | ||
{ | ||
Rectangle r = new Rectangle(i * (img.Width / int.Parse(textBox1.Text)), | ||
y * (img.Height / int.Parse(textBox2.Text)), | ||
img.Width / int.Parse(textBox1.Text), | ||
img.Height / int.Parse(textBox2.Text)); | ||
|
||
cropImage(img, r).Save(folderBrowserDialog1.SelectedPath + "/Splitted Image " + i + "-" + y + ".png"); | ||
|
||
} | ||
} | ||
|
||
} | ||
|
||
MessageBox.Show("Images splitted successfully!"); | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.