示例#1
0
        private GrayscalePixelDataU16(int width, int height, ushort[] data)
        {
            _width  = width;
            _height = height;

            _buffer = new MappedFileBuffer(Dicom.IO.ByteConverter.ToByteBuffer <ushort>(data).Data);
        }
示例#2
0
        public GrayscalePixelDataS16(int width, int height, BitDepth bitDepth, IByteBuffer data)
        {
            _bits   = bitDepth;
            _width  = width;
            _height = height;

            var shortData = Dicom.IO.ByteConverter.ToArray <short>(data);

            if (bitDepth.BitsStored != 16)
            {
                int sign = 1 << bitDepth.HighBit;
                int mask = (UInt16.MaxValue >> (bitDepth.BitsAllocated - bitDepth.BitsStored));

                Parallel.For(0, shortData.Length, (int i) => {
                    short d = shortData[i];
                    if ((d & sign) != 0)
                    {
                        shortData[i] = (short)-(((-d) & mask) + 1);
                    }
                    else
                    {
                        shortData[i] = (short)(d & mask);
                    }
                });
            }

            _buffer = new MappedFileBuffer(Dicom.IO.ByteConverter.ToByteBuffer <short>(shortData).Data);
        }
示例#3
0
        public GrayscalePixelDataU8(int width, int height, IByteBuffer data)
        {
            _width  = width;
            _height = height;

            _buffer = new MappedFileBuffer(data.Data);
        }
示例#4
0
        private GrayscalePixelDataU8(int width, int height, byte[] data)
        {
            _width  = width;
            _height = height;

            _buffer = new MappedFileBuffer(data);
            //_data = data;
        }
示例#5
0
        public GrayscalePixelDataU16(int width, int height, BitDepth bitDepth, IByteBuffer data)
        {
            _bits   = bitDepth;
            _width  = width;
            _height = height;

            var ushortData = Dicom.IO.ByteConverter.ToArray <ushort>(data);

            if (bitDepth.BitsStored != 16)
            {
                int mask = (1 << (bitDepth.HighBit + 1)) - 1;

                Parallel.For(0, ushortData.Length, (int i) => {
                    ushortData[i] = (ushort)(ushortData[i] & mask);
                });
            }

            _buffer = new MappedFileBuffer(Dicom.IO.ByteConverter.ToByteBuffer <ushort>(ushortData).Data);
        }
示例#6
0
        public GrayscalePixelDataS32(int width, int height, BitDepth bitDepth, IByteBuffer data)
        {
            _width  = width;
            _height = height;

            var intData = Dicom.IO.ByteConverter.ToArray <int>(data);

            int  sign = 1 << bitDepth.HighBit;
            uint mask = (UInt32.MaxValue >> (bitDepth.BitsAllocated - bitDepth.BitsStored));

            Parallel.For(0, intData.Length, (int i) => {
                int d = intData[i];
                if ((d & sign) != 0)
                {
                    intData[i] = (int)-(((-d) & mask) + 1);
                }
                else
                {
                    intData[i] = (int)(d & mask);
                }
            });

            _buffer = new MappedFileBuffer(Dicom.IO.ByteConverter.ToByteBuffer <int>(intData).Data);
        }
示例#7
0
 public ColorPixelData24(int width, int height, IByteBuffer data)
 {
     _width  = width;
     _height = height;
     _buffer = new MappedFileBuffer(data.Data);
 }
示例#8
0
 private ColorPixelData24(int width, int height, byte[] data)
 {
     _width  = width;
     _height = height;
     _buffer = new MappedFileBuffer(data);
 }