public static void ImportNewSprites(SpriteFolder folder, Bitmap bmp, bool alpha, bool remapColours, bool useRoomBackground, SpriteImportTransparency transparency, string filename, int frame, SpriteSheet spritesheet) { bool tiled = spritesheet != null; if (tiled) { foreach (Rectangle selection in spritesheet.GetSpriteSelections(new Size(bmp.Width, bmp.Height))) { Bitmap import = bmp.Clone(selection, bmp.PixelFormat); ImportNewSprite(folder, import, alpha, remapColours, useRoomBackground, transparency, filename, frame, selection, tiled); import.Dispose(); } } else { Rectangle selection = new Rectangle(0, 0, bmp.Width, bmp.Height); ImportNewSprite(folder, bmp, alpha, remapColours, useRoomBackground, transparency, filename, frame, selection, tiled); } }
public static void ReplaceSprite(Sprite sprite, Bitmap bmp, bool alpha, bool remapColours, bool useRoomBackground, SpriteImportTransparency transparency, string filename, int frame, SpriteSheet spritesheet) { bool tiled = spritesheet != null; if (tiled) { Rectangle selection = spritesheet.GetFirstSpriteSelection(new Size(bmp.Width, bmp.Height)); if (!selection.IsEmpty) { Bitmap replacement = bmp.Clone(selection, bmp.PixelFormat); ReplaceSprite(sprite, replacement, alpha, remapColours, useRoomBackground, transparency, filename, frame, selection, tiled); replacement.Dispose(); } else { string message = String.Format("Tiled selection for sprite {0} was out-of-bounds for image '{1}'", sprite.Number, sprite.SourceFile); throw new InvalidOperationException(message); } } else { Rectangle selection = new Rectangle(0, 0, bmp.Width, bmp.Height); ReplaceSprite(sprite, bmp, alpha, remapColours, useRoomBackground, transparency, filename, frame, selection, tiled); } }