public void ThreadSplitOneByOne(object o) { ThreadParameter tp = (ThreadParameter)o; this.SetEnableInvoke(false); namedProgressBar1.ResetMaximum(); namedProgressBar2.ResetMaximum(); namedProgressBar1.Text = "Lettura Frame"; namedProgressBar2.Text = "Salvataggio Frame"; GifSplitter g = new GifSplitter(); g.ProgressChange += (GifSplitter Self, int Now, int Total) => { ProgressChangeGeneral(Self, Now, Total, namedProgressBar1); }; g.StateChange += (GifSplitter This, State state) => { StateChangeGeneral(This, state, namedProgressBar1); }; String path = Directory.GetParent(tp.Sorgente).FullName; String FileName = Path.GetFileNameWithoutExtension(tp.Sorgente); String PathOut = Path.Combine(path, FileName); if (!Directory.Exists(PathOut)) { Directory.CreateDirectory(PathOut); } int i = 0; int MaxElement = tp.Righe * tp.Colonne; ImageCollection ic = new ImageCollection(); ImageCollectionManager icm = new ImageCollectionManager(ic); icm.Colonne = tp.Colonne; icm.ProgressChange += (ImageCollectionManager Self, int Now, int Total) => { ProgressChangeGeneral(Self, Now, Total, namedProgressBar2); }; icm.StateChange += (ImageCollectionManager This2, State state) => { if (state == State.Finish) { namedProgressBar2.Value = 0; } }; g.ElementFinish += (Image This) => { /* * TODO: se si vuole implementare un ottimizzazione di frame ( controllo se il frame precedente è uguale al successivo * if (ic.Count != 0) * { * if( !This.EqualImage(ic.Collection.Last())) * ic.Collection.Add(This.CloneFast()); * } * else * ic.Collection.Add(This.CloneFast());*/ ic.Collection.Add(This.CloneFast()); if (ic.Count >= MaxElement) { namedProgressBar2.ResetMaximum(); icm.SetCollection(ic); icm.Export(Path.Combine(PathOut, FileName + "_" + i + "." + tp.formatoOut), tp.formatoOut); ic.Dispose(); ic = new ImageCollection(); i++; } }; g.StateChange += (GifSplitter This, State state) => { if (state == State.Finish) { icm.SetCollection(ic); /*icm.StateChange += (ImageCollectionManager This2, State state2) => * { * StateChangeGeneral(This2, state2, namedProgressBar2); * };*/ icm.Export(Path.Combine(PathOut, FileName + "_" + i + "." + tp.formatoOut), tp.formatoOut); ic.Dispose(); this.SetEnableInvoke(true); } }; g.SplitOneByOne(tp.Sorgente); }