private void DrawTile(Graphics graphics, int colsCounter, int rowsCounter) { using (var tile = Image.FromFile(this.filesEnumerator.GetNextFileName())) { var tileTransformerSettings = new TileTransformerSettings { GraphicsDpiX = graphics.DpiX, GraphicsDpiY = graphics.DpiY, RotateAndFlipRandomly = settings.Additional.RotateAndFlipRandomly, ScalePercent = settings.Dimensions.TileScalePercent }; using (var tileTransformed = this.tileTransformer.Transform(tile, tileTransformerSettings)) { graphics.DrawImage( tileTransformed, colsCounter * this.settings.Dimensions.TileWidth, rowsCounter * this.settings.Dimensions.TileHeight, new Rectangle(this.GetTilePosition(tile.Size), new Size(this.settings.Dimensions.TileWidth, this.settings.Dimensions.TileHeight)), GraphicsUnit.Pixel); } } }
public Image Transform(Image tile, TileTransformerSettings settings) { if (settings == null) { ThrowExceptions.IsNull(Exc.GetStackTrace(), type, Exc.CallingMethod(), "settings"); } if (tile == null) { ThrowExceptions.IsNull(Exc.GetStackTrace(), type, Exc.CallingMethod(), "tile"); } var tileScaled = tile.Scale(settings.ScalePercent); if (settings.RotateAndFlipRandomly) { tileScaled.RotateFlipRandom(this.randomGenerator); } if (Math.Abs(tileScaled.HorizontalResolution - settings.GraphicsDpiX) > 0.01 || Math.Abs(tileScaled.VerticalResolution - settings.GraphicsDpiY) > 0.01) { tileScaled.SetResolution(settings.GraphicsDpiX, settings.GraphicsDpiY); } return(tileScaled); }