} /* OldestFrame */ private SipperFrame GetFrameWithScanLine(long scanLine) { int frameNum = (int)(scanLine / Sipper3File.ScanLinesPerFrame); int x = 0; bool frameFound = true; SipperFrame f = null; for (x = 0; x < frames.Length; x++) { f = frames[x]; if (f.FrameNum == frameNum) { return(f); } } f = OldestFrame(); sipperFile.FrameRead(frameNum, f, ref frameFound); if (!frameFound) { f = null; } return(f); } /* GetFrameWithScanLine */
} /* OpenAppropriateFormat */ private SipperFrame OldestFrame() { int x = 0; SipperFrame oldest = frames[0]; long oldestTime = oldest.Time; if (oldest.FrameNum == -1) { return(oldest); } for (x = 1; x < frames.Length; x++) { if (frames[x].Time < oldestTime) { oldest = frames[x]; oldestTime = oldest.Time; } } oldest.Time = 0; oldest.FrameNum = -1; oldest.ScanLineFirst = -1; oldest.ScanLineLast = -1; return(oldest); } /* OldestFrame */
} /* GetFrameWithScanLine */ public byte[][] GetScanLines(long scanLineStart, long scanLineEnd ) { long numScanLines = scanLineEnd - scanLineStart + 1; byte[][] scanLines = new byte[numScanLines][]; int scanLinesNextRow = 0; long nextScanLine = scanLineStart; while (nextScanLine <= scanLineEnd) { SipperFrame f = GetFrameWithScanLine(nextScanLine); if (f == null) { break; } if (sipperFile.EofReached() && (sipperFile.LargestKnownScanLine() < nextScanLine)) { break; } byte[][] thisFrame = f.ScanLines; int thisFrameNextRow = 0; long thisFrameFirstRow = nextScanLine - f.ScanLineFirst; long thisFrameLastRow = Math.Min(scanLineEnd - f.ScanLineFirst, (thisFrame.Length - 1)); thisFrameNextRow = (int)thisFrameFirstRow; while (thisFrameNextRow <= thisFrameLastRow) { scanLines[scanLinesNextRow] = thisFrame[thisFrameNextRow]; nextScanLine++; scanLinesNextRow++; thisFrameNextRow++; } } if (scanLinesNextRow == 0) { scanLines = null; } return(scanLines); } /* GetScanLines */
public void FrameRead(int frameNum, SipperFrame frame, ref bool found ) { BlockStart(); if (frameNum > largestKnowmFrameNum) { UpdateFrameByteOffsetsForFrameNum(frameNum); if (frameNum > largestKnowmFrameNum) { // this can happen when there are less than 'framNum' frames // in the Sipper file. found = false; BlockEnd(); return; } } found = true; long tempFilePos = f.BaseStream.Seek(frameByteOffsets[frameNum], SeekOrigin.Begin); byteOffsetNextRead = frameByteOffsets[frameNum]; eof = false; frameNumLastRead = frameNum - 1; frameNumNextRead = frameNum; lastScanLineNum = frameNum * ScanLinesPerFrame - 1; frame.FrameNum = frameNum; frame.ScanLineFirst = lastScanLineNum + 1; frame.ScanLineLast = lastScanLineNum + ScanLinesPerFrame; ReadNextFrame(frame.ScanLines); BlockEnd(); } /* FrameRead */
} /* Dispose */ private void Initialization() { clock = new SipperClock(); int x = 0; frames = new SipperFrame[3]; bool found = true; for (x = 0; x < frames.Length; x++) { frames[x] = new SipperFrame(clock); sipperFile.FrameRead(x, frames[x], ref found); if (!found) { frames[x].FrameNum = -1; frames[x].ScanLineFirst = -1; frames[x].ScanLineLast = -1; } } SetPixelsPerDisplayLine(scanLineSize, 0, scanLineSize - 1); } /* Initialization */