using System.Drawing; using ClearCanvas.Common; using ClearCanvas.ImageViewer.PresentationStates.Dicom; namespace Nullstack.ClearCanvas.ImageViewerTools.Overlays { [ExtensionOf(typeof (OverlayTestPatternExtensionPoint))] public sealed class CheckerboardTestPattern : IOverlayTestPattern { private bool _firstSquareFilled = false; public string Name { get { return "Checkerboard"; } } public string Description { get { return "Checkerboard test pattern"; } } public bool FirstSquareFilled { get { return _firstSquareFilled; } set { _firstSquareFilled = value; } } public OverlayPlaneGraphic CreatePattern(Size patternSize) { int rows = patternSize.Height; int columns = patternSize.Width; UserOverlayPlaneGraphic pattern = new UserOverlayPlaneGraphic(rows, columns); pattern.Label = this.Name.ToUpperInvariant(); pattern.Description = this.Description; for (int x = 0; x < columns; x++) { for (int y = 0; y < rows; y++) { int file = (int) (8f*x/columns); int rank = (int) (8f*y/rows); pattern[x, y] = (file%2 == 0) ^ (rank%2 == 0) ^ _firstSquareFilled; } } return pattern; } } }