Skip to content
Snippets Groups Projects
Commit 80b11de7 authored by Riley Mcgee's avatar Riley Mcgee
Browse files

Code clarity made in Main Form

parent 0ab4728e
No related branches found
No related tags found
No related merge requests found
......@@ -166,6 +166,7 @@ namespace Gifitti.Models
}
}
/// <summary>
/// Whether the gif should play backwards when it reaches the end
/// </summary>
......
......@@ -79,30 +79,7 @@ namespace Gifitti.View_Models
/// <param name="e"> Event arguments associated with this event. </param>
private void MenuItemExportJPEG(object sender, EventArgs e)
{
if(chkImage())
{
String x = "";
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
x = folderBrowserDialog.SelectedPath;
}
List<Image> IMGs = new List<Image>();
Image test;
int Length = globalGif.GetFrameCount(FrameDimension.Time);
if (x != "")
{
for (int i = gm.startFrame; i < gm.endFrame; i++)
{
globalGif.SelectActiveFrame(FrameDimension.Time, i);
test = globalGif;
String y = "\\tmpj-" + i + ".jpg";
String xy = x + y;
test.Save(@xy, ImageFormat.Jpeg);
}
}
}
exportFrames(ImageFormat.Jpeg);
}
/// <summary>
......@@ -112,31 +89,17 @@ namespace Gifitti.View_Models
/// <param name="e"> Event arguments associated with this event. </param>
private void MenuItemExportPNG(object sender, EventArgs e)
{
if (chkImage())
{
String x = "";
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
x = folderBrowserDialog.SelectedPath;
}
List<Image> IMGs = new List<Image>();
Image test;
int Length = globalGif.GetFrameCount(FrameDimension.Time);
if (x != "")
{
for (int i = gm.startFrame; i < gm.endFrame; i++)
{
globalGif.SelectActiveFrame(FrameDimension.Time, i);
test = globalGif;
String y = "\\tmpp-" + i + ".png";
String xy = x + y;
test.Save(@xy, ImageFormat.Png);
}
}
}
exportFrames(ImageFormat.Png);
}
private static Dictionary<ImageFormat, string> IMAGE_TO_EXTENSION = new Dictionary<ImageFormat, string>()
{
{ImageFormat.Bmp, "bmp" },
{ImageFormat.Tiff, "tiff" },
{ImageFormat.Jpeg, "jpeg" },
{ImageFormat.Png, "png" }
};
/// <summary>
/// On event invocation the loaded gif is decomposed into its frames and saved to a specified folder as BMP (Bitmap) images.
/// </summary>
......@@ -144,28 +107,24 @@ namespace Gifitti.View_Models
/// <param name="e"> Event arguments associated with this event. </param>
private void MenuItemExportBMP(object sender, EventArgs e)
{
if (chkImage())
{
String x = "";
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
x = folderBrowserDialog.SelectedPath;
}
exportFrames(ImageFormat.Bmp);
}
List<Image> IMGs = new List<Image>();
Image test;
int Length = globalGif.GetFrameCount(FrameDimension.Time);
if (x != "")
{
for (int i = gm.startFrame; i < gm.endFrame; i++)
{
globalGif.SelectActiveFrame(FrameDimension.Time, i);
test = new Bitmap(globalGif);
String y = "\\tmpb-" + i + ".bmp";
String xy = x + y;
test.Save(@xy);
}
}
public void exportFrames(ImageFormat format)
{
if (!chkImage())
return;
String path = "";
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
path = folderBrowserDialog.SelectedPath;
for (int i = 0; i < gm.numberOfFrames; i++)
{
var a = gm.GetFrame(i);
a.Save(path + @"\frame" + i + @"." + IMAGE_TO_EXTENSION[format], format);
}
}
......@@ -176,29 +135,7 @@ namespace Gifitti.View_Models
/// <param name="e"> Event arguments associated with this event. </param>
private void MenuItemExportTIFF(object sender, EventArgs e)
{
if (chkImage())
{
String x = "";
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
x = folderBrowserDialog.SelectedPath;
}
List<Image> IMGs = new List<Image>();
Image test;
int Length = globalGif.GetFrameCount(FrameDimension.Time);
if (x != "")
{
for (int i = gm.startFrame; i < gm.endFrame; i++)
{
globalGif.SelectActiveFrame(FrameDimension.Time, i);
test = globalGif;
String y = "\\tmpt-" + i + ".tiff";
String xy = x + y;
test.Save(@xy, ImageFormat.Tiff);
}
}
}
exportFrames(ImageFormat.Tiff);
}
/// <summary>
......@@ -352,10 +289,10 @@ namespace Gifitti.View_Models
//set the initial frames in textbox
textBox1.Text = "0";
textBox2.Text = gm.numberOfFrames.ToString();
textBox2.Text = gm.numberOfFrames.ToString(); //TODO: remove tem
}
}
}
/// <summary>
/// Loads the Help Menu Form.
/// </summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment