|
AlbumShaper
1.0a3
|

Go to the source code of this file.
Functions | |
| bool | getJPEGSize (const char *filename, int &width, int &height) |
| bool getJPEGSize | ( | const char * | filename, |
| int & | width, | ||
| int & | height | ||
| ) |
Definition at line 65 of file jpegSize.cpp.
References first_marker(), infile, M_EOI, M_SOF0, M_SOF1, M_SOF10, M_SOF11, M_SOF13, M_SOF14, M_SOF15, M_SOF2, M_SOF3, M_SOF5, M_SOF6, M_SOF7, M_SOF9, M_SOS, next_marker(), process_SOFn(), READ_BINARY, and skip_variable().
Referenced by getImageSize(), and isJpeg().
{
//open file
if ((infile = fopen(filename, READ_BINARY)) == NULL)
return false;
//this is scan_JPEG_header (int verbose)
//Parse the marker stream until SOFn is seen;
int marker;
//Expect SOI at start of file
if (!first_marker(&marker))
{
fclose(infile);
return false;
}
/* Scan miscellaneous markers until we reach SOFn. */
for (;;)
{
if(!next_marker(&marker))
{
fclose(infile);
return false;
}
switch (marker)
{
/* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be,
* treated as SOFn. C4 in particular is actually DHT.
*/
case M_SOF0: /* Baseline */
case M_SOF1: /* Extended sequential, Huffman */
case M_SOF2: /* Progressive, Huffman */
case M_SOF3: /* Lossless, Huffman */
case M_SOF5: /* Differential sequential, Huffman */
case M_SOF6: /* Differential progressive, Huffman */
case M_SOF7: /* Differential lossless, Huffman */
case M_SOF9: /* Extended sequential, arithmetic */
case M_SOF10: /* Progressive, arithmetic */
case M_SOF11: /* Lossless, arithmetic */
case M_SOF13: /* Differential sequential, arithmetic */
case M_SOF14: /* Differential progressive, arithmetic */
case M_SOF15: /* Differential lossless, arithmetic */
if(!process_SOFn(width, height))
{
fclose(infile);
return false;
}
else
{
fclose(infile);
return true;
}
case M_SOS: /* stop before hitting compressed data */
{
fclose(infile);
return false;
}
case M_EOI: /* in case it's a tables-only JPEG stream */
{
fclose(infile);
return false;
}
default: /* Anything else just gets skipped */
skip_variable(); /* we assume it has a parameter count... */
break;
}
} /* end loop */
//cout << "ERROR!\n";
return false;
}
1.7.5.1