public static Dictionary <Sprite, Bitmap> Crop(SpriteSet spriteSet) { var bitmaps = new List <Bitmap>(spriteSet.TextureSet.Textures.Count); foreach (var texture in spriteSet.TextureSet.Textures) { var bitmap = TextureDecoder.Decode(texture); bitmap.RotateFlip(RotateFlipType.Rotate180FlipX); bitmaps.Add(bitmap); } var sprites = new Dictionary <Sprite, Bitmap>(spriteSet.Sprites.Count); foreach (var sprite in spriteSet.Sprites) { var sourceBitmap = bitmaps[sprite.TextureIndex]; var bitmap = sourceBitmap.Clone( new RectangleF(sprite.X, sprite.Y, sprite.Width, sprite.Height), sourceBitmap.PixelFormat); sprites.Add(sprite, bitmap); } foreach (var bitmap in bitmaps) { bitmap.Dispose(); } return(sprites); }
public static Bitmap Crop(Sprite sprite, SpriteSet parentSet) { var bitmap = TextureDecoder.Decode( parentSet.TextureSet.Textures[sprite.TextureIndex]); bitmap.RotateFlip(RotateFlipType.Rotate180FlipX); var croppedBitmap = bitmap.Clone( new RectangleF(sprite.X, sprite.Y, sprite.Width, sprite.Height), bitmap.PixelFormat); bitmap.Dispose(); return(croppedBitmap); }