/// <summary> /// Opens a tile-part with the specified indices. /// Reads and parses all associated headers and /// fills information about the child packets of this /// tile-part. /// </summary> /// <param name="tileIdx">Tile index in raster order</param> /// <param name="tilepartIdx">The in tile index of the tile-part</param> /// <returns></returns> public JP2TilePart OpenTilePart(int tileIdx, int tilepartIdx) { if (tileIdx > Tiles.Count()) { throw new IndexOutOfRangeException("tile index: " + tileIdx); } return(Tiles[tileIdx].OpenTilePart(tilepartIdx)); }
public void BreakBlock(Rectangle rect, Inventory inv) { for (int i = 0; i < Tiles.Count(); i++) { if (rect == Tiles[i].rect) { inv.items.Add(new Item(Tiles[i])); Tiles.RemoveAt(i); break; } } }
private void ConstructTilesFromCodestream() { if (_sotOffset == 0) { throw new InvalidOperationException( "SOT offset uninitialized, cannot traverse tile-parts " + "before main header was parsed and first tile part" + " was encountered"); } int tileCount = Tiles.Count(); UnderlyingIO.Seek(Position + _sotOffset, SeekOrigin.Begin); long offset = _sotOffset; MarkerType type; while ((type = MarkerSegment.Peek(UnderlyingIO)) != MarkerType.EOC) { if (type != MarkerType.SOT) { throw new InvalidOperationException( "Expected only SOT markers in codestream traversal"); } // get the length of the tile part from the SOT and continue as // if we have read a TLM entry. SotMarker sot = MarkerSegment.Open(UnderlyingIO) as SotMarker; if (sot.TileIndex >= tileCount) { throw new ArgumentOutOfRangeException( "SOT TileIndex is too large for number of tiles" + " calculated from SIZ tile and image size"); } AddTilePart(offset, sot.TileIndex, sot.TilePartLength); offset += sot.TilePartLength; // skip to the next marker segment, // account for the already read SOT_MARKER long skip = sot.TilePartLength; skip -= SotMarker.SOT_MARKER_LENGTH; skip -= MarkerSegment.MarkerLength; UnderlyingIO.Seek(skip, SeekOrigin.Current); } return; }
public int Simulate(int occupied) { while (Tiles.Any(seat => seat.Changed)) { foreach (var seat in Tiles) { seat.Changed = false; } foreach (var seat in Tiles) { var next = seat.GetNext(occupied); seat.Changed = next != seat.Occupied; seat.Next = next; } foreach (var seat in Tiles) { seat.Occupied = seat.Next; } } return(Tiles.Count(seat => seat.Occupied)); }
private void MarkTile(Tile tile) { tile.Mark(); MinesLeft = Mines - Tiles.Count(x => x.Status == "F"); }