public PaddedBrushModel(TilesetModel tileset, int tileOffsetX, int tileOffsetY) : base(tileset.Columns.Value, tileset.Rows.Value, tileset.TileWidth.Value, tileset.TileHeight.Value) { this.Tiles = new ObservableCollection <Tile>(); this.TileOffsetX.Value = tileOffsetX; this.TileOffsetY.Value = tileOffsetY; }
public void TileImage(Mat tilesImage, Point pixelPoint, TilesetModel tilesetModel) { this.Tiles.Clear(); int colCount = tilesImage.Cols / this.TileWidth.Value; int rowCount = tilesImage.Rows / this.TileHeight.Value; for (int rowIndex = 0; rowIndex < rowCount; ++rowIndex) { for (int colIndex = 0; colIndex < colCount; ++colIndex) { Size tileSize = this.GetTileSize(); Point topLeftPoint = new Point(colIndex * this.TileWidth.Value, rowIndex * this.TileHeight.Value); Mat tileImage = BrushUtils.CropImage(tilesImage, topLeftPoint, tileSize); Rect drawingRect = new Rect(topLeftPoint, tileSize); ImageDrawing drawing = ImageUtils.MatToImageDrawing(tileImage, drawingRect); Point offsetPoint = Point.Add(pixelPoint, (Vector)topLeftPoint); int tileID = tilesetModel.GetID(offsetPoint); int tilesetID = tilesetModel.ID; Tile tile = new Tile(drawing, tilesetID, tileID); this.Tiles.Add(tile); } } }
public PaddedBrushModel(TilesetModel tileset) : base(tileset.Columns.Value, tileset.Rows.Value, tileset.TileWidth.Value, tileset.TileHeight.Value) { this.Tiles = new ObservableCollection <Tile>(); }