/*
* tSkipToData - skip until a IDAT chunk is found
*
* returns the length of the pixeldata or -1 in case of error
*/
static size_t
tSkipToData(FILE *pFile, size_t tMaxBytes, size_t *ptSkipped)
{
ULONG ulName, ulTmp;
size_t tDataLength, tToSkip;
int iCounter;
/*
* iFindFirstPixelData - find the first pixeldata if a PNG image
*
* returns the length of the pixeldata or -1 in case of error
*/
static size_t
tFindFirstPixelData(FILE *pFile, size_t tMaxBytes, size_t *ptSkipped)
{
fail(pFile == NULL);
fail(tMaxBytes == 0);
fail(ptSkipped == NULL);
if (tMaxBytes < 8) {
DBG_DEC(tMaxBytes);
return (size_t)-1;
}
/* Skip over the PNG signature */
(void)tSkipBytes(pFile, 8);
*ptSkipped = 8;
return tSkipToData(pFile, tMaxBytes, ptSkipped);
} /* end of iFindFirstPixelData */
/*
* tFindNextPixelData - find the next pixeldata if a PNG image
*
* returns the length of the pixeldata or -1 in case of error
*/
static size_t
tFindNextPixelData(FILE *pFile, size_t tMaxBytes, size_t *ptSkipped)
{
fail(pFile == NULL);
fail(tMaxBytes == 0);
fail(ptSkipped == NULL);
if (tMaxBytes < 4) {
DBG_DEC(tMaxBytes);
return (size_t)-1;
}
/* Skip over the crc */
(void)tSkipBytes(pFile, 4);
*ptSkipped = 4;
return tSkipToData(pFile, tMaxBytes, ptSkipped);
} /* end of tFindNextPixelData */