/// <summary> /// Defloats either a dragged selection or a newly pasted selection. /// </summary> /// <param name="buffer">The dragged selection or the newly pasted selection.</param> private void Defloat(CopyBuffer buffer) { if (buffer == null) { return; } if (overlay.Select.Empty) { return; } Point location = new Point(); location.X = overlay.Select.X / 16; location.Y = overlay.Select.Y / 16; commandStack.Push(new MoldEdit( mold.Tiles, width / 16, height / 16, buffer.CopyBytes(), location.X, location.Y, buffer.Width / 16, buffer.Height / 16)); commandStack.Push(commandCount + 1); commandCount = 0; SetTilemapImage(); if (sequencesForm != null) { sequencesForm.SetFrameImages(); sequencesForm.RealignFrames(); } defloating = true; animation.WriteToBuffer(); }
private void Draw(Graphics g, int x, int y) { x /= 16; y /= 16; // cancel if no selection in the tileset is made if (overlay.SelectTS.Empty) { return; } // check to see if overwriting same tile(s) bool noChange = true; for (int y_ = 0; y_ < overlay.SelectTS.Height / 16; y_++) { for (int x_ = 0; x_ < overlay.SelectTS.Width / 16; x_++) { int index = ((overlay.SelectTS.Y / 16) + y_) * 8 + (overlay.SelectTS.X / 16) + x_; int indexInMold = (y + y_) * (width / 16) + x + x_; // cancel if overwriting same tile(s) if (indexInMold < mold.Tiles.Length && mold.Tiles[indexInMold] != index) { noChange = false; } } } if (noChange) { return; } commandStack.Push(new MoldEdit( mold.Tiles, width / 16, height / 16, selectedTiles.CopyBytes(), x, y, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16)); commandCount++; // draw the tile Point p = new Point(x * 16, y * 16); int[] pixels = Do.ImageToPixels(overlay.SelectTS.GetSelectionImage(tilesetImage)); Bitmap image = Do.PixelsToImage(pixels, overlay.SelectTS.Width, overlay.SelectTS.Height); p.X *= zoom; p.Y *= zoom; Rectangle rsrc = new Rectangle(0, 0, image.Width, image.Height); Rectangle rdst = new Rectangle(p.X, p.Y, (int)(image.Width * zoom), (int)(image.Height * zoom)); g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.DrawImage(image, rdst, rsrc, GraphicsUnit.Pixel); }