/// <summary>
        /// Gets a formatted string identifying the overlay plane on which an error occurred.
        /// </summary>
        /// <param name="group">The overlay plane group on which the error occurred.</param>
        /// <param name="source">The source of the overlay plane on which the error occurred.</param>
        /// <returns>A formatted string identifying the overlay plane on which an error occurred.</returns>
        public static string FormatOverlayPlaneId(ushort group, OverlayPlaneSource source)
        {
            switch (source)
            {
            case OverlayPlaneSource.Image:
                return(string.Format("Image/0x{0:X4}", group));

            case OverlayPlaneSource.PresentationState:
                return(string.Format("PresentationState/0x{0:X4}", group));

            case OverlayPlaneSource.User:
            default:
                return("UserCreated");
            }
        }
        /// <summary>
        /// Constructs a new user-created <see cref="OverlayPlaneGraphic"/> with the specified dimensions.
        /// </summary>
        /// <param name="rows">The number of rows in the overlay.</param>
        /// <param name="columns">The number of columns in the overlay.</param>
        protected OverlayPlaneGraphic(int rows, int columns)
        {
            Platform.CheckPositive(rows, "rows");
            Platform.CheckPositive(columns, "columns");

            _index          = -1;
            _frameIndex     = 0;
            _label          = string.Empty;
            _description    = string.Empty;
            _type           = OverlayType.G;
            _subtype        = null;
            _source         = OverlayPlaneSource.User;
            _overlayGraphic = new GrayscaleImageGraphic(
                rows, columns,                                  // the reported overlay dimensions
                8,                                              // bits allocated is always 8
                8,                                              // overlays always have bit depth of 1, but we upconverted the data
                7,                                              // the high bit is now 7 after upconverting
                false, false,                                   // overlays aren't signed and don't get inverted
                1, 0,                                           // overlays have no rescale
                MemoryManager.Allocate <byte>(rows * columns)); // new empty pixel buffer

            this.Color = System.Drawing.Color.PeachPuff;
            base.Graphics.Add(_overlayGraphic);
        }
        /// <summary>
        /// Constructs an <see cref="OverlayPlaneGraphic"/> for a single or multi-frame overlay plane using a pre-processed overlay pixel data buffer.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The <paramref name="overlayPixelData"/> parameter allows for the specification of an alternate source of overlay pixel data, such
        /// as the unpacked contents of <see cref="DicomTags.OverlayData"/> or the extracted, inflated overlay pixels of <see cref="DicomTags.PixelData"/>.
        /// Although the format should be 8-bits per pixel, every pixel should either be 0 or 255. This will allow pixel interpolation algorithms
        /// sufficient range to produce a pleasant image. (If the data was either 0 or 1, regardless of the bit-depth, most interpolation algorithms
        /// will interpolate 0s for everything in between!)
        /// </para>
        /// </remarks>
        /// <param name="overlayPlaneIod">The IOD object containing properties of the overlay plane.</param>
        /// <param name="overlayPixelData">The overlay pixel data in 8-bits per pixel format, with each pixel being either 0 or 255.</param>
        /// <param name="frameIndex">The overlay frame index (0-based). Single-frame overlays should specify 0.</param>
        /// <param name="source">A value identifying the source of the overlay plane.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="overlayPixelData"/> is NULL or 0-length.</exception>
        public OverlayPlaneGraphic(OverlayPlane overlayPlaneIod, byte[] overlayPixelData, int frameIndex, OverlayPlaneSource source)
        {
            Platform.CheckNonNegative(frameIndex, "frameIndex");
            _frameIndex  = frameIndex;
            _index       = overlayPlaneIod.Index;
            _label       = overlayPlaneIod.OverlayLabel;
            _description = overlayPlaneIod.OverlayDescription;
            _type        = overlayPlaneIod.OverlayType;
            _subtype     = (OverlayPlaneSubtype)overlayPlaneIod.OverlaySubtype;
            _source      = source;

            GrayscaleImageGraphic overlayImageGraphic = CreateOverlayImageGraphic(overlayPlaneIod, overlayPixelData);

            if (overlayImageGraphic != null)
            {
                _overlayGraphic = overlayImageGraphic;
                this.Color      = System.Drawing.Color.PeachPuff;
                base.Graphics.Add(overlayImageGraphic);
            }

            if (string.IsNullOrEmpty(overlayPlaneIod.OverlayLabel))
            {
                if (overlayPlaneIod.IsMultiFrame)
                {
                    base.Name = string.Format(SR.FormatDefaultMultiFrameOverlayGraphicName, _source, _index, frameIndex);
                }
                else
                {
                    base.Name = string.Format(SR.FormatDefaultSingleFrameOverlayGraphicName, _source, _index, frameIndex);
                }
            }
            else
            {
                base.Name = overlayPlaneIod.OverlayLabel;
            }
        }
Esempio n. 4
0
		/// <summary>
		/// Constructs an <see cref="OverlayPlaneGraphic"/> for a single or multi-frame overlay plane using a pre-processed overlay pixel data buffer.
		/// </summary>
		/// <remarks>
		/// <para>
		/// The <paramref name="overlayPixelData"/> parameter allows for the specification of an alternate source of overlay pixel data, such
		/// as the unpacked contents of <see cref="DicomTags.OverlayData"/> or the extracted, inflated overlay pixels of <see cref="DicomTags.PixelData"/>.
		/// Although the format should be 8-bits per pixel, every pixel should either be 0 or 255. This will allow pixel interpolation algorithms
		/// sufficient range to produce a pleasant image. (If the data was either 0 or 1, regardless of the bit-depth, most interpolation algorithms
		/// will interpolate 0s for everything in between!)
		/// </para>
		/// </remarks>
		/// <param name="overlayPlaneIod">The IOD object containing properties of the overlay plane.</param>
		/// <param name="overlayPixelData">The overlay pixel data in 8-bits per pixel format, with each pixel being either 0 or 255.</param>
		/// <param name="frameIndex">The overlay frame index (0-based). Single-frame overlays should specify 0.</param>
		/// <param name="source">A value identifying the source of the overlay plane.</param>
		/// <exception cref="ArgumentNullException">Thrown if <paramref name="overlayPixelData"/> is NULL or 0-length.</exception>
		public OverlayPlaneGraphic(OverlayPlane overlayPlaneIod, byte[] overlayPixelData, int frameIndex, OverlayPlaneSource source)
		{
			Platform.CheckNonNegative(frameIndex, "frameIndex");
			_frameIndex = frameIndex;
			_index = overlayPlaneIod.Index;
			_label = overlayPlaneIod.OverlayLabel;
			_description = overlayPlaneIod.OverlayDescription;
			_type = overlayPlaneIod.OverlayType;
			_subtype = (OverlayPlaneSubtype) overlayPlaneIod.OverlaySubtype;
			_source = source;

			GrayscaleImageGraphic overlayImageGraphic = CreateOverlayImageGraphic(overlayPlaneIod, overlayPixelData);
			if (overlayImageGraphic != null)
			{
				_overlayGraphic = overlayImageGraphic;
				this.Color = System.Drawing.Color.PeachPuff;
				base.Graphics.Add(overlayImageGraphic);
			}

			if (string.IsNullOrEmpty(overlayPlaneIod.OverlayLabel))
			{
				if (overlayPlaneIod.IsMultiFrame)
					base.Name = string.Format(SR.FormatDefaultMultiFrameOverlayGraphicName, _source, _index, frameIndex);
				else
					base.Name = string.Format(SR.FormatDefaultSingleFrameOverlayGraphicName, _source, _index, frameIndex);
			}
			else
			{
				base.Name = overlayPlaneIod.OverlayLabel;
			}
		}
Esempio n. 5
0
		/// <summary>
		/// Constructs an <see cref="OverlayPlaneGraphic"/> for a single-frame overlay plane using a pre-processed overlay pixel data buffer.
		/// </summary>
		/// <remarks>
		/// <para>
		/// This overload should only be used for single-frame overlay planes. Multi-frame overlay planes should process the overlay data
		/// into separate buffers and then construct individual graphics using <see cref="OverlayPlaneGraphic(OverlayPlane, byte[], int, OverlayPlaneSource)"/>.
		/// </para>
		/// <para>
		/// The <paramref name="overlayPixelData"/> parameter allows for the specification of an alternate source of overlay pixel data, such
		/// as the unpacked contents of <see cref="DicomTags.OverlayData"/> or the extracted, inflated overlay pixels of <see cref="DicomTags.PixelData"/>.
		/// Although the format should be 8-bits per pixel, every pixel should either be 0 or 255. This will allow pixel interpolation algorithms
		/// sufficient range to produce a pleasant image. (If the data was either 0 or 1, regardless of the bit-depth, most interpolation algorithms
		/// will interpolate 0s for everything in between!)
		/// </para>
		/// </remarks>
		/// <param name="overlayPlaneIod">The IOD object containing properties of the overlay plane.</param>
		/// <param name="overlayPixelData">The overlay pixel data in 8-bits per pixel format, with each pixel being either 0 or 255.</param>
		/// <param name="source">A value identifying the source of the overlay plane.</param>
		/// <exception cref="ArgumentNullException">Thrown if <paramref name="overlayPixelData"/> is NULL or 0-length.</exception>
		public OverlayPlaneGraphic(OverlayPlane overlayPlaneIod, byte[] overlayPixelData, OverlayPlaneSource source) : this(overlayPlaneIod, overlayPixelData, 0, source) {}
Esempio n. 6
0
		/// <summary>
		/// Constructs a new user-created <see cref="OverlayPlaneGraphic"/> with the specified dimensions.
		/// </summary>
		/// <param name="rows">The number of rows in the overlay.</param>
		/// <param name="columns">The number of columns in the overlay.</param>
		protected OverlayPlaneGraphic(int rows, int columns)
		{
			Platform.CheckPositive(rows, "rows");
			Platform.CheckPositive(columns, "columns");

			_index = -1;
			_frameIndex = 0;
			_label = string.Empty;
			_description = string.Empty;
			_type = OverlayType.G;
			_subtype = null;
			_source = OverlayPlaneSource.User;
			_overlayGraphic = new GrayscaleImageGraphic(
				rows, columns, // the reported overlay dimensions
				8, // bits allocated is always 8
				8, // overlays always have bit depth of 1, but we upconverted the data
				7, // the high bit is now 7 after upconverting
				false, false, // overlays aren't signed and don't get inverted
				1, 0, // overlays have no rescale
				MemoryManager.Allocate<byte>(rows*columns)); // new empty pixel buffer

			this.Color = System.Drawing.Color.PeachPuff;
			base.Graphics.Add(_overlayGraphic);
		}
 /// <summary>
 /// Constructs an <see cref="OverlayPlaneGraphic"/> for a single-frame overlay plane using a pre-processed overlay pixel data buffer.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This overload should only be used for single-frame overlay planes. Multi-frame overlay planes should process the overlay data
 /// into separate buffers and then construct individual graphics using <see cref="OverlayPlaneGraphic(OverlayPlane, byte[], int, OverlayPlaneSource)"/>.
 /// </para>
 /// <para>
 /// The <paramref name="overlayPixelData"/> parameter allows for the specification of an alternate source of overlay pixel data, such
 /// as the unpacked contents of <see cref="DicomTags.OverlayData"/> or the extracted, inflated overlay pixels of <see cref="DicomTags.PixelData"/>.
 /// Although the format should be 8-bits per pixel, every pixel should either be 0 or 255. This will allow pixel interpolation algorithms
 /// sufficient range to produce a pleasant image. (If the data was either 0 or 1, regardless of the bit-depth, most interpolation algorithms
 /// will interpolate 0s for everything in between!)
 /// </para>
 /// </remarks>
 /// <param name="overlayPlaneIod">The IOD object containing properties of the overlay plane.</param>
 /// <param name="overlayPixelData">The overlay pixel data in 8-bits per pixel format, with each pixel being either 0 or 255.</param>
 /// <param name="source">A value identifying the source of the overlay plane.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="overlayPixelData"/> is NULL or 0-length.</exception>
 public OverlayPlaneGraphic(OverlayPlane overlayPlaneIod, byte[] overlayPixelData, OverlayPlaneSource source) : this(overlayPlaneIod, overlayPixelData, 0, source)
 {
 }
		/// <summary>
		/// Initializes a new instance of <see cref="DicomOverlayDeserializationException"/> with a default error message.
		/// </summary>
		/// <param name="overlayGroup">The overlay plane group on which the error occurred.</param>
		/// <param name="overlaySource">The source of the overlay plane on which the error occurred.</param>
		/// <param name="innerException">The exception that is the cause of the current exception, if available.</param>
		public DicomOverlayDeserializationException(ushort overlayGroup, OverlayPlaneSource overlaySource, Exception innerException)
			: base(string.Format(_defaultFormattedMessage, FormatOverlayPlaneId(overlayGroup, overlaySource)), innerException)
		{
			OverlayGroup = overlayGroup;
			OverlaySource = overlaySource;
		}
		/// <summary>
		/// Initializes a new instance of <see cref="DicomOverlayDeserializationException"/> with the specified error message.
		/// </summary>
		/// <param name="overlayGroup">The overlay plane group on which the error occurred.</param>
		/// <param name="overlaySource">The source of the overlay plane on which the error occurred.</param>
		/// <param name="message">The message that describes the error.</param>
		public DicomOverlayDeserializationException(ushort overlayGroup, OverlayPlaneSource overlaySource, string message)
			: base(message)
		{
			OverlayGroup = overlayGroup;
			OverlaySource = overlaySource;
		}
		/// <summary>
		/// Gets a formatted string identifying the overlay plane on which an error occurred.
		/// </summary>
		/// <param name="group">The overlay plane group on which the error occurred.</param>
		/// <param name="source">The source of the overlay plane on which the error occurred.</param>
		/// <returns>A formatted string identifying the overlay plane on which an error occurred.</returns>
		public static string FormatOverlayPlaneId(ushort group, OverlayPlaneSource source)
		{
			switch (source)
			{
				case OverlayPlaneSource.Image:
					return string.Format("Image/0x{0:X4}", group);
				case OverlayPlaneSource.PresentationState:
					return string.Format("PresentationState/0x{0:X4}", group);
				case OverlayPlaneSource.User:
				default:
					return "UserCreated";
			}
		}
 /// <summary>
 /// Initializes a new instance of <see cref="DicomOverlayDeserializationException"/> with a default error message.
 /// </summary>
 /// <param name="overlayGroup">The overlay plane group on which the error occurred.</param>
 /// <param name="overlaySource">The source of the overlay plane on which the error occurred.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, if available.</param>
 public DicomOverlayDeserializationException(ushort overlayGroup, OverlayPlaneSource overlaySource, Exception innerException)
     : base(string.Format(_defaultFormattedMessage, FormatOverlayPlaneId(overlayGroup, overlaySource)), innerException)
 {
     OverlayGroup  = overlayGroup;
     OverlaySource = overlaySource;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="DicomOverlayDeserializationException"/> with the specified error message.
 /// </summary>
 /// <param name="overlayGroup">The overlay plane group on which the error occurred.</param>
 /// <param name="overlaySource">The source of the overlay plane on which the error occurred.</param>
 /// <param name="message">The message that describes the error.</param>
 public DicomOverlayDeserializationException(ushort overlayGroup, OverlayPlaneSource overlaySource, string message)
     : base(message)
 {
     OverlayGroup  = overlayGroup;
     OverlaySource = overlaySource;
 }