/* Table of CRCs of all 8-bit messages. */
sal_uInt32 PngHelper::crc_table[256];
/* Flag: has the table been computed? Initially false. */ bool PngHelper::bCRCTableInit = true;
/* Make the table for a fast CRC. */ void PngHelper::initCRCTable()
{ for (sal_uInt32 n = 0; n < 256; n++)
{
sal_uInt32 c = n; for (int k = 0; k < 8; k++)
{ if (c & 1)
c = 0xedb88320L ^ (c >> 1); else
c = c >> 1;
}
crc_table[n] = c;
}
bCRCTableInit = false;
}
/* Update a running CRC with the bytes buf[0..len-1]--the CRC shouldbeinitializedtoall1's,andthetransmittedvalue isthe1'scomplementofthefinalrunningCRC(seethe
crc() routine below)). */
// create scan line data buffer
OutputBuffer aScanlines; int nLineSize = (width + 7)/8;
aScanlines.reserve( nLineSize * height + height );
#if POPPLER_CHECK_VERSION(25, 2, 0) if (!str->reset()) return; #else
str->reset(); #endif for( int y = 0; y < height; y++ )
{ // determine filter type (none) for this scanline
aScanlines.push_back( 0 ); for( int x = 0; x < nLineSize; x++ )
aScanlines.push_back( str->getChar() );
}
// begin IDAT chunk for scanline data
nIdx = startChunk( "IDAT", o_rOutputBuf ); // compress scanlines
deflateBuffer( aScanlines.data(), aScanlines.size(), o_rOutputBuf ); // end IDAT chunk
endChunk( nIdx, o_rOutputBuf );
// output IEND
appendIEND( o_rOutputBuf );
}
void PngHelper::createPng( OutputBuffer& o_rOutputBuf,
Stream* str, int width, int height, GfxImageColorMap* colorMap,
Stream* maskStr, int maskWidth, int maskHeight, GfxImageColorMap* maskColorMap )
{
appendFileHeader( o_rOutputBuf );
appendIHDR( o_rOutputBuf, width, height, 8, 6 ); // RGBA image
// create scan line data buffer
OutputBuffer aScanlines;
aScanlines.reserve( width*height*4 + height );
for( int y=0; y<height; ++y)
{
aScanlines.push_back( 0 );
p = imgStr->getLine(); for( int x=0; x<width; ++x)
{
colorMap->getRGB(p, &rgb);
aScanlines.push_back(colToByte(rgb.r));
aScanlines.push_back(colToByte(rgb.g));
aScanlines.push_back(colToByte(rgb.b));
aScanlines.push_back( 0xff );
p +=colorMap->getNumPixelComps();
}
}
// now fill in the mask data
// CAUTION: originally this was done in one single loop // it caused merry chaos; the reason is that maskStr and str are // not independent streams, it happens that reading one advances // the other, too. Hence the two passes are imperative !
// create scan line data buffer
OutputBuffer aScanlines;
aScanlines.reserve( width*height*4 + height );
for( int y=0; y<height; ++y)
{
aScanlines.push_back( 0 );
p = imgStr->getLine(); for( int x=0; x<width; ++x)
{
colorMap->getRGB(p, &rgb);
aScanlines.push_back(colToByte(rgb.r));
aScanlines.push_back(colToByte(rgb.g));
aScanlines.push_back(colToByte(rgb.b));
aScanlines.push_back( 0xff );
p +=colorMap->getNumPixelComps();
}
}
// now fill in the mask data
// CAUTION: originally this was done in one single loop // it caused merry chaos; the reason is that maskStr and str are // not independent streams, it happens that reading one advances // the other, too. Hence the two passes are imperative !
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.