示例#1
0
        /// <summary>Read the RandomGroupsData.</summary>
        public override void Read(ArrayDataIO str)
        {
            SetFileOffset(str);

            try
            {
                str.ReadArray(dataArray);
            }
            catch (IOException e)
            {
                throw new FitsException("IO error reading Random Groups data " + e);
            }
            int pad = FitsUtil.Padding(TrueSize);

            try
            {
                //System.IO.BinaryReader temp_BinaryReader;
                System.Int64 temp_Int64;
                //temp_BinaryReader = str;
                temp_Int64 = str.Position;                  //temp_BinaryReader.BaseStream.Position;
                temp_Int64 = str.Seek(pad) - temp_Int64;    //temp_BinaryReader.BaseStream.Seek(pad, System.IO.SeekOrigin.Current) - temp_Int64;
                int generatedAux = (int)temp_Int64;
            }
            catch (IOException)
            {
                throw new FitsException("IO error reading padding.");
            }
        }
示例#2
0
        /// <summary>
        /// Method to read data
        /// </summary>
        /// <param name="i"></param>
        public override void Read(ArrayDataIO i)
        {
            // Don't need to read null data (noted by Jens Knudstrup)
            if (byteSize == 0)
            {
                return;
            }
            SetFileOffset(i);

            //if(i is RandomAccess)
            if (i.CanSeek)
            {
                //tiler = new ImageDataTiler(this, (RandomAccess) i, ((RandomAccess) i).FilePointer, dataDescription);
                tiler = new ImageDataTiler(this, (RandomAccess)i, ((Stream)i).Position, dataDescription);
                try
                {
                    double pos = i.Position;
                    //pos = i.Seek((int)byteSize) - pos;
                    i.Seek(byteSize);
                }
                catch (IOException e)
                {
                    throw new FitsException("Unable to skip over data:" + e);
                }
            }
            else
            {
                dataArray = ArrayFuncs.NewInstance(dataDescription.type, dataDescription.dims);
                try
                {
                    i.ReadArray(dataArray);
                }
                catch (IOException e)
                {
                    throw new FitsException("Unable to read image data:" + e);
                }

                tiler = new ImageDataTiler(this, null, 0, dataDescription);
            }

            int pad = FitsUtil.Padding(TrueSize);

            try
            {
                long pos = i.Seek(pad);
                if (pos != pad)
                {
                    throw new FitsException("Error skipping padding");
                }
            }
            catch (IOException e)
            {
                throw new FitsException("Error reading image padding:" + e);
            }
        }