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

Added Modularity via Folders, Added Save Functionality to Model

parent e48dd86b
No related branches found
No related tags found
No related merge requests found
......@@ -50,17 +50,17 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<Compile Include="View_Models\Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<Compile Include="View_Models\Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="GifImage.cs" />
<Compile Include="GifModel.cs" />
<Compile Include="Models\GifImage.cs" />
<Compile Include="Models\GifModel.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<EmbeddedResource Include="View_Models\Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
......@@ -86,6 +86,9 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Transformation\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
......@@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Gifitti
namespace Gifitti.Models
{
class GifImage
{
......
......@@ -7,10 +7,11 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Gifitti
namespace Gifitti.Models
{
class GifModel
{
public Image gifImage { get; set; }
public Image originalGif { get; private set; }
private FrameDimension dimension;
public int numberOfFrames { get; private set; }
......@@ -26,6 +27,7 @@ namespace Gifitti
{
//Save the original Gif
originalGif = Image.FromFile(path);
this.gifImage = originalGif.Clone() as Image;
dimension = new FrameDimension(originalGif.FrameDimensionsList[0]);
frameConstruction(originalGif);
}
......@@ -43,6 +45,39 @@ namespace Gifitti
}
}
public void resetToOriginalGif()
{
gifImage = originalGif;
}
/// <summary>
/// Takes the full path of a GIF save location,
/// extension included
/// </summary>
/// <param name="path">String representation of path to save the gif to.
/// Name and extension of gif mandatory.
/// </param>
public void saveGif(string path)
{
//TODO take in image setting components as well as frames being viewed etc.
//Build GIF
using (MagickImageCollection collection = new MagickImageCollection())
{
for (int i = 0; i < frames.Length; i++)
collection.Add(new MagickImage(frames[i] as Bitmap));
// Maximize Colour saturation
QuantizeSettings settings = new QuantizeSettings();
settings.Colors = 256;
collection.Quantize(settings);
// Optimized the GIF being exported
collection.Optimize();
// Save GIF to path
collection.Write(path);
}
}
public void resizeGif(int newWidth, int newHeight)
{
using (MagickImageCollection collection = new MagickImageCollection())
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using Gifitti.View_Models;
namespace Gifitti
{
......
namespace Gifitti
namespace Gifitti.View_Models
{
partial class Form1
{
......
......@@ -9,8 +9,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Gifitti.Models;
namespace Gifitti
namespace Gifitti.View_Models
{
public partial class Form1 : Form
{
......@@ -43,7 +44,7 @@ namespace Gifitti
gm = new GifModel(file);
gm.ReverseAtEnd = false;
Image loadedGif = Image.FromFile(file);
Image loadedGif = gm.gifImage;
globalGif = loadedGif;
//gifView.Image = loadedGif;
......
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