Example #1
0
 private void _32bitRadioButton_Checked(object sender, RoutedEventArgs e)
 {
     if (this.IsLoaded)
     {
         channelDepth = ImageBitDepth.float32bit;
         ResetServer();
     }
 }
Example #2
0
        public void ShouldCorrectlyMaintainParametersProvidedWhenCreated()
        {
            // Given
            const int           width         = 256;
            const int           height        = 512;
            const ImageBitDepth imageBitDepth = ImageBitDepth.Bpp12;

            // When
            var imageModel = new ImageModel(width, height, imageBitDepth);

            // Then
            Assert.AreEqual(width, imageModel.Width);
            Assert.AreEqual(height, imageModel.Height);
            Assert.AreEqual(imageBitDepth, imageModel.ImageBitDepth);
        }
Example #3
0
        private void InitializeMinMaxValues(ImageBitDepth imageBitDepth)
        {
            _minValue = 0;

            switch (imageBitDepth)
            {
            case ImageBitDepth.Bpp8:
                _maxValue = 255;
                break;

            case ImageBitDepth.Bpp12:
                _maxValue = 4095;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(imageBitDepth), imageBitDepth, null);
            }
        }
Example #4
0
        public Pixel ConvertToBitDepth(ImageBitDepth bitDepthFrom, ImageBitDepth bitDepthTo)
        {
            if (bitDepthFrom == bitDepthTo)
            {
                return(_value);
            }

            if (bitDepthFrom == ImageBitDepth.Bpp8 && bitDepthTo == ImageBitDepth.Bpp12)
            {
                return(_value << 4);
            }

            if (bitDepthFrom == ImageBitDepth.Bpp12 && bitDepthTo == ImageBitDepth.Bpp8)
            {
                return(_value >> 4);
            }

            throw new InvalidOperationException();
        }
Example #5
0
        public void ShouldCorrectlyGenerateHashCode()
        {
            // Given
            const int           width         = 256;
            const int           height        = 512;
            const ImageBitDepth imageBitDepth = ImageBitDepth.Bpp12;
            var imageModel = new ImageModel(width, height, imageBitDepth);

            int expected;

            unchecked
            {
                expected = width;
                expected = (expected * 397) ^ height;
                expected = (expected * 397) ^ (int)imageBitDepth;
            }

            // When
            var actual = imageModel.GetHashCode();

            // Then
            Assert.AreEqual(expected, actual);
        }
Example #6
0
 public ImageModel(ushort width, ushort height, ImageBitDepth imageBitDepth)
 {
     Width         = width;
     Height        = height;
     ImageBitDepth = imageBitDepth;
 }
Example #7
0
 private void _8bitRadioButton_Checked(object sender, RoutedEventArgs e)
 {
     if (this.IsLoaded)
     {
         channelDepth = ImageBitDepth.unsigned8bit;
         ResetServer();
     }
 }