private void UpdatePictureBox() { Image i = pictureBox1.Image; if (currentShape != null) { Frame currentFrame = currentShape.Frames[(int)numericUpDown1.Value]; //pictureBox1.Image = currentFrame.GetFrame(Sprite.GetAbstractSpriteFromIso(iso), paletteIndex); Bitmap image = currentFrame.GetFrame(Sprite.GetAbstractSpriteFromIso(iso), paletteIndex); pictureBox1.Image = zoom.GetZoomedBitmap(image); if (tabControl1.SelectedTab == framesTabPage) { spriteViewer1.HighlightTiles(currentFrame.Tiles); } else { spriteViewer1.HighlightTiles(new Tile[0]); } } else { pictureBox1.Image = null; } if (i != null) { i.Dispose(); } }
public void BuildAnimation(AbstractSprite sprite, out IList <System.Drawing.Bitmap> bitmaps, out IList <double> delays, int paletteIndex, Zoom zoom) { // Given the set of unique frame indices, build the minimal amount of Bitmaps necessary Dictionary <int, System.Drawing.Bitmap> frameToBitmap = new Dictionary <int, System.Drawing.Bitmap>(uniqueFrames.Count); foreach (int frame in uniqueFrames) { if (sprite != null) { frameToBitmap[frame] = sprite.Shape.Frames[frame].GetFrame(sprite, paletteIndex); } else { frameToBitmap[frame] = null; } } List <System.Drawing.Bitmap> result = new List <System.Drawing.Bitmap>(); List <double> ourDelays = new List <double>(); foreach (AnimationFrame frame in frames) { //result.Add( frameToBitmap[frame.Index] ); result.Add(zoom.GetZoomedBitmap(frameToBitmap[frame.Index])); ourDelays.Add(((double)frame.Delay) / 60); } bitmaps = result.ToArray(); delays = ourDelays.ToArray(); }
public void RefreshPictureBox(bool forceReload = false) { if (comboBox1.SelectedItem != null) { AbstractImage im = GetImageFromComboBoxItem(); Bitmap image = im.GetImageFromIso(iso, forceReload); Bitmap zoomedImage = zoom.GetZoomedBitmap(image); AssignNewPictureBoxImage(zoomedImage); imageSizeLabel.Text = string.Format("Image dimensions: {0}x{1}", im.Width, im.Height); } }
private void UpdateImage() { if (sprite != null) { Bitmap b = new Bitmap(sprite.Width, sprite.Height, PixelFormat.Format32bppArgb); BitmapData bmd = b.LockBits(new Rectangle(Point.Empty, b.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); sprite.DrawSprite(bmd, palette, portraitPalette); b.UnlockBits(bmd); if (tiles != null) { using (Pen p = new Pen(Color.Yellow)) using (Graphics g = Graphics.FromImage(b)) { foreach (Tile t in tiles) { g.DrawRectangle(p, t.Rectangle); } } } Bitmap zb = zoom.GetZoomedBitmap(b); SuspendLayout(); pictureBox1.SuspendLayout(); if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); pictureBox1.Image = null; } pictureBox1.Image = zb; //pictureBox1.Image = b; pictureBox1.ResumeLayout(); ResumeLayout(false); PerformLayout(); } else if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); pictureBox1.Image = null; } }