Пример #1
0
        internal void SearchFramesByMagicPhase2(OnSearchProgressDelegate progressCallback)
        {
            m_Index = new AdvFramesIndex();

            int  percentCompleted;
            int  lastPercentCompleted = -1;
            int  framesRecovered      = 0;
            long startTimeTicks       = -1;

            m_CandidateFrameOffsets.Add(new RecoveredFrameHeader()
            {
                Position = m_FileReader.BaseStream.Length
            });

            ushort[,] prevFramePixels = null;

            for (int i = 0; i < m_CandidateFrameOffsets.Count - 1; i++)
            {
                RecoveredFrameHeader frameInfo1 = m_CandidateFrameOffsets[i];
                RecoveredFrameHeader frameInfo2 = m_CandidateFrameOffsets[i + 1];

                if (startTimeTicks == -1)
                {
                    startTimeTicks = frameInfo1.StartExposureUT.Ticks;
                }

                m_Index.Index.Add(new AdvFramesIndexEntry()
                {
                    ElapsedTime = new TimeSpan(frameInfo1.StartExposureUT.Ticks - startTimeTicks),
                    Offset      = frameInfo1.Position,
                    Length      = (uint)(frameInfo2.Position - frameInfo1.Position)
                });

                try
                {
                    object[]      data        = GetFrameSectionData(framesRecovered, prevFramePixels);
                    AdvImageData  imageData   = (AdvImageData)data[0];
                    AdvStatusData statusData  = (AdvStatusData)data[1];
                    int           frameWidth  = imageData.ImageData.GetLength(0);
                    int           frameHeight = imageData.ImageData.GetLength(1);
                    Trace.WriteLine(string.Format("Recovered frame #{0} with LayoutId {1} and {2} status tags. Dimentions: {3}x{4} pixels", framesRecovered, imageData.LayoutId, statusData.TagValues.Count, frameWidth, frameHeight));

                    // NOTE: Doesn't have to be right, just need something so we read the pixels
                    prevFramePixels = imageData.ImageData;

                    framesRecovered++;
                }
                catch (Exception)
                {
                    m_Index.Index.RemoveAt(m_Index.Index.Count - 1);
                }

                percentCompleted = (int)(100.0 * i / (m_CandidateFrameOffsets.Count - 1));
                if (lastPercentCompleted < percentCompleted)
                {
                    progressCallback(percentCompleted, framesRecovered);
                    lastPercentCompleted = percentCompleted;
                }
            }
        }
Пример #2
0
        internal void SearchFramesByMagicPhase2(OnSearchProgressDelegate progressCallback)
        {
            m_Index = new AdvFramesIndex();

            int percentCompleted;
            int lastPercentCompleted = -1;
            int framesRecovered = 0;
            long startTimeTicks = -1;

            m_CandidateFrameOffsets.Add(new RecoveredFrameHeader()
            {
                Position = m_FileReader.BaseStream.Length
            });

            ushort[,] prevFramePixels = null;

            for(int i = 0; i < m_CandidateFrameOffsets.Count - 1; i ++)
            {
                RecoveredFrameHeader frameInfo1 = m_CandidateFrameOffsets[i];
                RecoveredFrameHeader frameInfo2 = m_CandidateFrameOffsets[i + 1];

                if (startTimeTicks == -1)
                    startTimeTicks = frameInfo1.StartExposureUT.Ticks;

                m_Index.Index.Add(new AdvFramesIndexEntry()
                {
                    ElapsedTime = new TimeSpan(frameInfo1.StartExposureUT.Ticks - startTimeTicks),
                    Offset = frameInfo1.Position,
                    Length = (uint)(frameInfo2.Position - frameInfo1.Position)
                });

                try
                {
                    object[] data = GetFrameSectionData(framesRecovered, prevFramePixels);
                    AdvImageData imageData = (AdvImageData)data[0];
                    AdvStatusData statusData = (AdvStatusData)data[1];
                    int frameWidth = imageData.ImageData.GetLength(0);
                    int frameHeight = imageData.ImageData.GetLength(1);
                    Trace.WriteLine(string.Format("Recovered frame #{0} with LayoutId {1} and {2} status tags. Dimentions: {3}x{4} pixels", framesRecovered, imageData.LayoutId, statusData.TagValues.Count, frameWidth, frameHeight));

                    // NOTE: Doesn't have to be right, just need something so we read the pixels
                    prevFramePixels = imageData.ImageData;

                    framesRecovered++;
                }
                catch(Exception)
                {
                    m_Index.Index.RemoveAt(m_Index.Index.Count - 1);
                }

                percentCompleted = (int)(100.0 * i / (m_CandidateFrameOffsets.Count - 1));
                if (lastPercentCompleted < percentCompleted)
                {
                    progressCallback(percentCompleted, framesRecovered);
                    lastPercentCompleted = percentCompleted;
                }
            }
        }