public bool addFrameToSpriteSheet(String filename) { //Create Frame from filename Image img1 = Image.FromFile(filename); // //Trick to allow Annimated Gif importation // FrameDimension dimension = new FrameDimension(img1.FrameDimensionsList[0]); // Get Frame count of Image File int frameCount = img1.GetFrameCount(dimension); // Browse frame list for (int i = 0; i < frameCount; i++) { // Select current frame img1.SelectActiveFrame(dimension, i); // Add normaly the image to the spritesheet Image img = new Bitmap(img1); SpriteFrame newFrame = new SpriteFrame(filename, this.sheet.Frames.Count, img, sheet); this.sheet.Frames.Add(newFrame); } //Clean img1.Dispose(); return true; }
public List <SpriteFrame> checkFramesIntegrity() { List <SpriteFrame> framesToReturn = new List <SpriteFrame>(); for (int i = 0; i < this.Frames.Count; i++) { SpriteFrame frame = this.Frames[i]; if (!frame.SpriteSheetParent.Frames.Contains(frame)) { framesToReturn.Add(frame); } } if (framesToReturn.Count > 0) { return(framesToReturn); } else { framesToReturn = null; return(null); } }
//--------------------------------------------------- //-------------------Methodes------------------------ //--------------------------------------------------- public void addFrame(SpriteFrame frame) { this.Frames.Add(frame); }
public CoronaSpriteSet CloneInstance() { CoronaSpriteSet newSet = new CoronaSpriteSet(this.Name); List<CoronaSpriteSheet> sheetUsed = new List<CoronaSpriteSheet>(); for (int i = 0; i < this.Frames.Count; i++) { if (!sheetUsed.Contains(this.Frames[i].SpriteSheetParent)) sheetUsed.Add(this.Frames[i].SpriteSheetParent); } for (int i = 0; i < sheetUsed.Count; i++) { CoronaSpriteSheet sheet = new CoronaSpriteSheet(sheetUsed[i].Name); sheet.FramesFactor = sheetUsed[i].FramesFactor; for (int j = 0; j < sheetUsed[i].Frames.Count; j++) { SpriteFrame frame = new SpriteFrame(sheetUsed[i].Frames[j].NomFrame, j, sheetUsed[i].Frames[j].Image, sheet); sheet.addFrame(frame); } } return null; }
private void spriteSheetSplitterBt_Click(object sender, EventArgs e) { Form form = new Form(); form.Icon = this.mainForm.Icon; form.Text = "Sprite Sheet Splitter"; SpriteSheetSplitter splitterControl = new SpriteSheetSplitter(); form.Controls.Add(splitterControl); splitterControl.Dock = DockStyle.Fill; form.Size = this.mainForm.Size; form.WindowState = this.mainForm.WindowState; form.Location = this.mainForm.Location; DialogResult rs = form.ShowDialog(this.mainForm); if (rs == DialogResult.OK) { for (int i = 0; i < splitterControl.Frames.Count; i++) { SpriteFrame newFrame = new SpriteFrame(this.sheet.Name, this.sheet.Frames.Count, splitterControl.Frames[i], sheet); this.sheet.Frames.Add(newFrame); } this.refreshFramesListView(); } splitterControl.Dispose(); form.Dispose(); splitterControl = null; form = null; }