コード例 #1
0
ファイル: OW.cs プロジェクト: mlavik1/UnityVolumeRendering
        protected override Array DecodeProper(byte[] bytes)
        {
            ValueMultiplicity vm = Tag.GetDictionaryEntry().VM;

            if (vm.Equals(1) || vm.IsUndefined)
            {
                if (bytes.Length % 2 != 0)
                {
                    throw new EncodingException(
                              "A value of multiple 2 bytes is only allowed.", Tag,
                              Name + "/value.Length", bytes.Length.ToString());
                }
                // TODO: Get allowed length from transfer syntax.
                ushort[] wordValue = new ushort[bytes.Length / 2];
                byte[]   buffer    = new byte[2];
                for (int i = 0; i < wordValue.Length; i++)
                {
                    Array.Copy(bytes, i * 2, buffer, 0, 2);
                    wordValue[i] = BitConverter.ToUInt16(
                        TransferSyntax.CorrectByteOrdering(buffer), 0);
                }
                return(new ushort[1][] { wordValue });
            }
            else
            {
                throw new EncodingException(
                          "Multiple values are not allowed within this field.", Tag,
                          Name + "/VM", vm.ToString());
            }
        }
コード例 #2
0
ファイル: SS.cs プロジェクト: mlavik1/UnityVolumeRendering
 protected override Array DecodeImproper(byte[] bytes)
 {
     byte[][] multiValue = ToImproperMultiValue(bytes, 2);
     short[]  number     = new short[multiValue.Length];
     for (int i = 0; i < number.Length; i++)
     {
         number[i] = BitConverter.ToInt16(
             TransferSyntax.CorrectByteOrdering(multiValue[i]), 0);
     }
     return(number);
 }
コード例 #3
0
 protected override Array DecodeImproper(byte[] bytes)
 {
     float[] floatValue = new float[(int)Math.Floor((double)bytes.Length / 4)];
     byte[]  buffer     = new byte[4];
     for (int i = 0; i < floatValue.Length; i++)
     {
         Array.Copy(bytes, i * 4, buffer, 0, 4);
         floatValue[i] = BitConverter.ToSingle(
             TransferSyntax.CorrectByteOrdering(buffer), 0);
     }
     return(new float[1][] { floatValue });
 }
コード例 #4
0
ファイル: OW.cs プロジェクト: mlavik1/UnityVolumeRendering
 protected override Array DecodeImproper(byte[] bytes)
 {
     ushort[] wordValue = new ushort[(int)Math.Floor((double)bytes.Length / 2)];
     byte[]   buffer    = new byte[2];
     for (int i = 0; i < wordValue.Length; i++)
     {
         Array.Copy(bytes, i * 2, buffer, 0, 2);
         wordValue[i] = BitConverter.ToUInt16(
             TransferSyntax.CorrectByteOrdering(buffer), 0);
     }
     return(new ushort[1][] { wordValue });
 }
コード例 #5
0
ファイル: AT.cs プロジェクト: mlavik1/UnityVolumeRendering
 protected override Array DecodeImproper(byte[] bytes)
 {
     byte[][] multiValue = ToImproperMultiValue(bytes, 4);
     Tag[]    tagValue   = new Tag[multiValue.Length];
     for (int i = 0; i < tagValue.Length; i++)
     {
         int group = TransferSyntax.CorrectByteOrdering(
             BitConverter.ToUInt16(multiValue[i], 0));
         int element = TransferSyntax.CorrectByteOrdering(
             BitConverter.ToUInt16(multiValue[i], 2));
         tagValue[i] = new Tag(group, element);
     }
     return(tagValue);
 }
コード例 #6
0
ファイル: SS.cs プロジェクト: mlavik1/UnityVolumeRendering
 protected override Array DecodeProper(byte[] bytes)
 {
     byte[][] multiValue = ToProperMultiValue(bytes, 2);
     if (bytes.Length == 2 * multiValue.Length)
     {
         short[] number = new short[multiValue.Length];
         for (int i = 0; i < number.Length; i++)
         {
             number[i] = BitConverter.ToInt16(
                 TransferSyntax.CorrectByteOrdering(multiValue[i]), 0);
         }
         return(number);
     }
     else
     {
         throw new EncodingException(
                   "A value of multiple 2 bytes is only allowed.",
                   Tag, Name + "/value.Length", bytes.Length.ToString());
     }
 }
コード例 #7
0
        protected override Array DecodeProper(byte[] bytes)
        {
            ValueMultiplicity vm = Tag.GetDictionaryEntry().VM;

            if (vm.Equals(1) || vm.IsUndefined)
            {
                if (bytes.Length % 4 != 0)
                {
                    throw new EncodingException(
                              "A value of multiple 4 bytes is only allowed.", Tag,
                              Name + "/value.Length", bytes.Length.ToString());
                }
                if (bytes.Length <= 0xFFFFFFB)
                {
                    float[] floatValue = new float[bytes.Length / 4];
                    byte[]  buffer     = new byte[4];
                    for (int i = 0; i < floatValue.Length; i++)
                    {
                        Array.Copy(bytes, i * 4, buffer, 0, 4);
                        floatValue[i] = BitConverter.ToSingle(
                            TransferSyntax.CorrectByteOrdering(buffer), 0);
                    }
                    return(new float[1][] { floatValue });
                }
                else
                {
                    throw new EncodingException(
                              "A value of max. 2^32 - 4 bytes is only allowed.",
                              Tag, Name + "/value.Length", bytes.Length.ToString());
                }
            }
            else
            {
                throw new EncodingException(
                          "Multiple values are not allowed within this field.",
                          Tag, Name + "/VM", vm.ToString());
            }
        }
コード例 #8
0
ファイル: AT.cs プロジェクト: mlavik1/UnityVolumeRendering
 protected override Array DecodeProper(byte[] bytes)
 {
     byte[][] multiValue = ToProperMultiValue(bytes, 4);
     if (bytes.Length == 4 * multiValue.Length)
     {
         Tag[] tagValue = new Tag[multiValue.Length];
         for (int i = 0; i < tagValue.Length; i++)
         {
             int group = TransferSyntax.CorrectByteOrdering(
                 BitConverter.ToUInt16(multiValue[i], 0));
             int element = TransferSyntax.CorrectByteOrdering(
                 BitConverter.ToUInt16(multiValue[i], 2));
             tagValue[i] = new Tag(group, element);
         }
         return(tagValue);
     }
     else
     {
         throw new EncodingException(
                   "A value of multiple 4 bytes is only allowed.", Tag,
                   Name + "/value.Length", bytes.Length.ToString());
     }
 }