示例#1
0
        /// <summary>
        /// method to write data
        /// </summary>
        /// <param name="o"></param>
        public override void Write(ArrayDataIO o)
        {
            // Don't need to write null data (noted by Jens Knudstrup)
            if (byteSize == 0)
            {
                return;
            }

            // changes suggested in .97 version:
            if (dataArray == null)
            {
                if (tiler != null)
                {
                    // Need to read in the whole image first.
                    try
                    {
                        dataArray = tiler.CompleteImage;
                    }
                    catch (IOException)
                    {
                        throw new FitsException("Error attempting to fill image");
                    }
                }
                else if (dataArray == null && dataDescription != null)
                {
                    // Need to create an array to match a specified header.
                    dataArray = ArrayFuncs.NewInstance(dataDescription.type, dataDescription.dims);
                }
                else
                {
                    // This image isn't ready to be written!
                    throw new FitsException("Null image data");
                }
            }

            try
            {
                o.WriteArray(dataArray);
            }
            catch (IOException e)
            {
                throw new FitsException("IO Error on image write: " + e);
            }

            byte[] padding = new byte[FitsUtil.Padding(TrueSize)];
            try
            {
                o.Write(padding);
                o.Flush();
            }
            catch (IOException e)
            {
                throw new FitsException("Error writing padding: " + e);
            }
        }
示例#2
0
 /// <summary>Write the RandomGroupsData.</summary>
 public override void Write(ArrayDataIO str)
 {
     try
     {
         str.WriteArray(dataArray);
         byte[] padding = new byte[FitsUtil.Padding(TrueSize)];
         str.Write(padding);
         str.Flush();
     }
     catch (IOException e)
     {
         throw new FitsException("IO error writing random groups data " + e);
     }
 }