/// <summary> /// Called by PckViewForm.OnImportSpritesheetClick() /// </summary> /// <param name="bitmap">bitmap containing sprites</param> /// <param name="pal"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="pad"></param> /// <returns></returns> public static SpriteCollectionBase CreateSpriteset( Bitmap bitmap, Palette pal, int width, int height, int pad) { var spriteset = new SpriteCollectionBase(); int cols = (bitmap.Width + pad) / (width + pad); int rows = (bitmap.Height + pad) / (height + pad); int terrainId = 0; for (int i = 0; i != cols * rows; ++i) { int x = (i % cols) * (width + pad); int y = (i / cols) * (height + pad); spriteset.Add(CreateSprite( bitmap, terrainId++, pal, x, y, width, height)); // UpdateProgressBar(aniSprite, rows * cols); } spriteset.Pal = pal; return(spriteset); }
/// <summary> /// Called by PckViewForm.OnImportSpritesheetClick() /// </summary> /// <param name="b">an indexed Bitmap of a spritesheet</param> /// <param name="pal"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="pad"></param> /// <returns></returns> public static SpriteCollectionBase CreateSheetSprites( Bitmap b, Palette pal, int width, int height, int pad = 0) { var spriteset = new SpriteCollectionBase(); int cols = (b.Width + pad) / (width + pad); int rows = (b.Height + pad) / (height + pad); int id = -1; for (int i = 0; i != cols * rows; ++i) { int x = (i % cols) * (width + pad); int y = (i / cols) * (height + pad); spriteset.Add(CreateSprite( b, ++id, pal, width, height, x, y)); } spriteset.Pal = pal; return(spriteset); }