Ejemplo n.º 1
0
		/// <summary>
		/// Validates that the photometric interpretation is not unknown.
		/// </summary>
		/// <param name="photometricInterpretation"></param>
		public static void ValidatePhotometricInterpretation(PhotometricInterpretation photometricInterpretation)
		{
			if (photometricInterpretation == PhotometricInterpretation.Unknown)
			{
				throw new DicomDataException(String.Format(SR.ExceptionInvalidPhotometricInterpretation, photometricInterpretation));
			}
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Validates that the input image property relationships are compatible.
		/// </summary>
		public static void ValidateImagePropertyRelationships(int bitsStored, int bitsAllocated, int highBit, PhotometricInterpretation photometricInterpretation, int planarConfiguration, int samplesPerPixel)
		{
			if (bitsStored > bitsAllocated)
				throw new DicomDataException(String.Format(SR.ExceptionInvalidBitsStoredBitsAllocated, bitsStored, bitsAllocated));

			if (highBit > bitsAllocated - 1)
				throw new DicomDataException(String.Format(SR.ExceptionInvalidHighBitBitsAllocated, highBit, bitsAllocated));

			if ((photometricInterpretation == PhotometricInterpretation.Monochrome1
			     || photometricInterpretation == PhotometricInterpretation.Monochrome2) &&
			    samplesPerPixel != 1)
			{
				throw new DicomDataException(String.Format(SR.ExceptionInvalidPhotometricInterpretationSamplesPerPixel, photometricInterpretation, samplesPerPixel));
			}

			if (samplesPerPixel != 1)
			{
				if (planarConfiguration != 0 && planarConfiguration != 1)
					throw new DicomDataException(String.Format(SR.ExceptionInvalidPlanarConfiguration));
			}

			if ((photometricInterpretation == PhotometricInterpretation.Rgb ||
			     photometricInterpretation == PhotometricInterpretation.YbrFull ||
			     photometricInterpretation == PhotometricInterpretation.YbrFull422 ||
			     photometricInterpretation == PhotometricInterpretation.YbrPartial422 ||
			     photometricInterpretation == PhotometricInterpretation.YbrIct ||
			     photometricInterpretation == PhotometricInterpretation.YbrRct) &&
			    samplesPerPixel != 3)
			{
				throw new DicomDataException(String.Format(SR.ExceptionInvalidPhotometricInterpretationSamplesPerPixel, photometricInterpretation, samplesPerPixel));
			}
		}
		private static void Add(PhotometricInterpretation photometricInterpretation)
		{
			_photometricInterpretations.Add(photometricInterpretation.Code, photometricInterpretation);
		}