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

Playback is proper, resize fixed

parent 15a6ad4f
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,8 @@ namespace Gifitti.Models
private bool reverse;
public int startFrame = 0;
public int endFrame = 0;
internal int originalDelay;
public int delay { get; set; } = 0;
/// <summary>
......@@ -36,6 +38,10 @@ namespace Gifitti.Models
{
//Save the original Gif
originalGif = Image.FromFile(path);
PropertyItem item = originalGif.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
// Time is in 1/100ths of a second
originalDelay = (item.Value[0] + item.Value[1] * 256) * 10;
delay = originalDelay;
this.gifImage = originalGif.Clone() as Image;
dimension = new FrameDimension(originalGif.FrameDimensionsList[0]);
frameConstruction(originalGif);
......@@ -186,10 +192,12 @@ namespace Gifitti.Models
/// </summary>
/// <param name="index">Frame number to fetch</param>
/// <returns>Frame number index in the model</returns>
public Image GetFrame(int index)
public Image GetFrame(int index, bool isResize = false)
{
originalGif.SelectActiveFrame(dimension, index);
//find the frame
if(isResize)
return (Image)originalGif.Clone();
return originalGif;
//return a copy of it
}
......
......@@ -26,10 +26,9 @@ namespace Gifitti.Transformation
{
for (int i = 0; i < gm.numberOfFrames; i++)
{
collection.Add(new MagickImage(gm.GetFrame(i) as Bitmap));
//collection[i].AnimationDelay = (delay / 8);
collection.Add(new MagickImage(gm.GetFrame(i, true) as Bitmap));
collection[i].Resize(newWidth, newHeight);
gm.SetFrameFromImage(collection[i].ToBitmap(), i);
gm.SetFrameFromImage(collection[i].ToBitmap() as Bitmap, i);
}
}
}
......@@ -41,8 +40,6 @@ namespace Gifitti.Transformation
{
collection.Add(new MagickImage(gm.GetFrame(i) as Bitmap));
collection[i].AnimationDelay = (delay/10);
}
//return collection;
......
......@@ -289,7 +289,6 @@ namespace Gifitti.View_Models
//set the initial frames in textbox
textBox1.Text = "0";
textBox2.Text = gm.numberOfFrames.ToString();
//Transformation.TransformGif.resizeGif(this.gm, 100, 100); //TODO: remove temporarily used for testing
}
}
......@@ -314,7 +313,7 @@ namespace Gifitti.View_Models
/// <param name="e"> Event arguments associated with this event. </param>
private void GifFPSSliderUpdate(object sender, EventArgs e)
{
gm.delay = (10-trackBar1.Value)*10;
gm.delay = (11-trackBar1.Value)*gm.originalDelay;
}
private void MenuItemResize(object sender, EventArgs e)
......
......@@ -48,13 +48,15 @@ namespace Gifitti.View_Models
Console.WriteLine(path);
try
{
TransformGif.resizeGif(gm, width, height);
gm.saveGif(path);
}
catch (DirectoryNotFoundException)
{
TransformGif.resizeGif(gm, orignalWidth, originalHeight);
MessageBox.Show("Save Path Invalid!");
}
TransformGif.resizeGif(gm, orignalWidth, originalHeight);
this.Close();
}
......
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