Пример #1
0
        /// <summary>
        /// Method to read the ArrayDataIO
        /// </summary>
        /// <param name="i"></param>
        public override void Read(ArrayDataIO i)
        {
            SetFileOffset(i);

            if (i is RandomAccess)
            {
                try
                {
                    //BinaryReader temp_BinaryReader;
                    System.Int64 temp_Int64;
                    //temp_BinaryReader = i;
                    temp_Int64 = i.Position;                         //temp_BinaryReader.BaseStream.Position;
                    temp_Int64 = i.Seek((int)byteSize) - temp_Int64; //temp_BinaryReader.BaseStream.Seek((int) byteSize, SeekOrigin.Current) - temp_Int64;
                    int generatedAux = (int)temp_Int64;
                }
                catch (IOException e)
                {
                    throw new FitsException("Unable to skip over data:" + e);
                }
            }
            else
            {
                try
                {
                    i.Read(data);
                }
                catch (IOException e)
                {
                    throw new FitsException("Unable to read unknown data:" + e);
                }
            }

            int pad = FitsUtil.Padding(TrueSize);

            try
            {
                //BinaryReader temp_BinaryReader2;
                System.Int64 temp_Int65;
                //temp_BinaryReader2 = i;
                temp_Int65 = i.Position;                  //temp_BinaryReader2.BaseStream.Position;
                temp_Int65 = i.Seek(pad) - temp_Int65;    //temp_BinaryReader2.BaseStream.Seek(pad, SeekOrigin.Current) - temp_Int65;
                //	if (temp_Int65 != pad)
                if (i.Seek(pad) != pad)
                {
                    throw new FitsException("Error skipping padding");
                }
            }
            catch (IOException e)
            {
                throw new FitsException("Error reading unknown padding:" + e);
            }
        }
Пример #2
0
        /// <summary>Read some data into the buffer.</summary>
        private void GetBuffer(int size, long offset)
        {
            if (currInput == null)
            {
                throw new IOException("No stream open to read");
            }

            buffer = new byte[size];
            if (offset != 0)
            {
                //FitsUtil.Reposition(currInput, offset);
                currInput.Seek(offset, SeekOrigin.Begin);
            }
            currInput.Read(buffer);            //SupportClass.ReadInput(currInput.BaseStream, ref buffer, 0, buffer.Length);
            bp = new ByteParser(buffer);
        }
Пример #3
0
        /// <summary>Read the heap</summary>
        public virtual void Read(ArrayDataIO str)
        {
            if (str is RandomAccess)
            {
                fileOffset = FitsUtil.FindOffset(str);
                input      = str;
            }

            if (heap != null)
            {
                try
                {
                    str.Read(heap, 0, heapSize);
                }
                catch (IOException e)
                {
                    throw new FitsException("Error reading heap:" + e);
                }
            }
        }
Пример #4
0
        /// <summary>File a tile segment from a file.</summary>
        /// <param name="output">The output tile.</param>
        /// <param name="delta">The offset from the beginning of the image in bytes.</param>
        /// <param name="outputOffset">The index into the output array.</param>
        /// <param name="segment">The number of elements to be read for this segment.</param>
        protected internal virtual void FillFileData(Array output, int delta, int outputOffset, int segment)
        {
            f.Seek(fileOffset + delta, SeekOrigin.Begin);

            if (base_Renamed == typeof(float))
            {
                f.Read((float[])output, outputOffset, segment);
            }
            else if (base_Renamed == typeof(int))
            {
                f.Read((int[])output, outputOffset, segment);
            }
            else if (base_Renamed == typeof(short))
            {
                f.Read((short[])output, outputOffset, segment);
            }
            else if (base_Renamed == typeof(double))
            {
                f.Read((double[])output, outputOffset, segment);
            }
            else if (base_Renamed == typeof(byte))
            {
                f.Read((byte[])output, outputOffset, segment);
            }
            else if (base_Renamed == typeof(char))
            {
                f.Read((char[])output, outputOffset, segment);
            }
            else if (base_Renamed == typeof(long))
            {
                f.Read((long[])output, outputOffset, segment);
            }
            else
            {
                throw new IOException("Invalid type for tile array");
            }
        }