The Annoyance Filter.pdf - Fourmilab
The Annoyance Filter.pdf - Fourmilab
The Annoyance Filter.pdf - Fourmilab
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
§100 ANNOYANCE-FILTER FLASH STREAM DECODER 83<br />
}<br />
}<br />
get8 ( );<br />
void getString (string &s, int n = −1); /∗ Bit field decoding methods ∗/<br />
void initBits (void);<br />
unsigned int getBits (int n);<br />
int getSignedBits (const int n);<br />
void getRect (rect ∗ r); /∗ Read a Rectangle specification ∗/<br />
void getMatrix (matrix ∗ mat ); /∗ Read a Matrix definition ∗/<br />
};<br />
101. Read the header of the Flash file into memory, validating its signature.<br />
〈 Class implementations 11 〉 +≡<br />
void flashStream ::readHeader (void){ sig [0] = get8 ( );<br />
sig [1] = get8 ( );<br />
sig [2] = get8 ( ); if (isEOF ( ) ∨ (memcmp(sig , "FWS", 3) ≠ 0)) { error = true ;<br />
if (verbose ) {<br />
cerr ≪ "Invalid␣signature␣in␣Flash␣animation␣file." ≪ endl ;<br />
}<br />
return; } version = get8 ( );<br />
fileLength = get32 ( );<br />
getRect (&frameSize );<br />
frameRate = get16 ( );<br />
frameCount = get16 ( ); }<br />
102. Write a primate-readable description of the Flash header on the output stream argument os ,<br />
which defaults to cout .<br />
〈 Class implementations 11 〉 +≡<br />
void flashStream ::describe (ostream &os )<br />
{<br />
os ≪ "Flash␣animation␣version␣" ≪ static cast〈unsigned int〉(version ) ≪ endl ;<br />
os ≪ "␣␣File␣length:␣" ≪ fileLength ≪ "␣bytes." ≪ endl ;<br />
os ≪ "␣␣Frame␣size:␣␣X:␣" ≪ frameSize .xMin ≪ "␣−␣" ≪ frameSize .xMax ≪ "␣Y:␣" ≪<br />
frameSize .yMin ≪ "␣−␣" ≪ frameSize .yMax ≪ endl ;<br />
os ≪ "␣␣Frame␣rate:␣" ≪ setprecision (5) ≪ (frameRate /256.0) ≪ "␣fps." ≪ endl ;<br />
os ≪ "␣␣Frame␣count:␣" ≪ frameCount ≪ endl ;<br />
}