예제 #1
0
        /// <summary>
        ///     Returns the entire DICOM pixel data as array of byte arrays.
        /// </summary>
        /// <remarks>
        ///     All non-byte arrays are transcoded into byte arrays. If a DICOM
        ///     pixel data element is not a DICOM sequence of items, an array
        ///     with a single byte array entry will be returned.
        /// </remarks>
        public byte[][] ToBytesArray()
        {
            byte[][] bytesArray;
            if (Data.Value.IsSequence)
            {
                Sequence sq = (Sequence)Data.Value[0];

                bytesArray = new byte[sq.Count][];
                for (int i = 0; i < sq.Count; i++)
                {
                    if (sq[i].Value[0] is ushort[])
                    {
                        bytesArray[i] = ByteConvert.ToBytes(
                            (ushort[])sq[i].Value[0]);
                    }
                    else
                    {
                        bytesArray[i] = (byte[])sq[i].Value[0];
                    }
                }
            }
            else
            {
                bytesArray = new byte[1][];
                if (Data.Value[0] is ushort[])
                {
                    bytesArray[0] = ByteConvert.ToBytes(
                        (ushort[])Data.Value[0]);
                }
                else
                {
                    bytesArray[0] = (byte[])Data.Value[0];
                }
            }
            return(bytesArray);
        }
예제 #2
0
 private void AddValueToXml(XmlTextWriter xml, object value,
                            bool isDate)
 {
     if (value is ushort[])
     {
         byte[] bytes = ByteConvert.ToBytes((ushort[])value);
         xml.WriteAttributeString("encoding", "Base64");
         AddBase64ValueToXml(xml, bytes);
     }
     else if (value is byte[])
     {
         xml.WriteAttributeString("encoding", "Base64");
         AddBase64ValueToXml(xml, (byte[])value);
     }
     else if (isDate)
     {
         // hide zero valued time
         xml.WriteString(((DateTime)value).ToShortDateString());
     }
     else
     {
         xml.WriteString(value.ToString());
     }
 }