本文整理汇总了C++中png_get_progressive_ptr函数的典型用法代码示例。如果您正苦于以下问题:C++ png_get_progressive_ptr函数的具体用法?C++ png_get_progressive_ptr怎么用?C++ png_get_progressive_ptr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了png_get_progressive_ptr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
nsPNGDecoder::end_callback(png_structp png_ptr, png_infop info_ptr)
{
/* libpng comments:
*
* this function is called when the whole image has been read,
* including any chunks after the image (up to and including
* the IEND). You will usually have the same info chunk as you
* had in the header, although some data may have been added
* to the comments and time fields.
*
* Most people won't do much here, perhaps setting a flag that
* marks the image as finished.
*/
nsPNGDecoder* decoder =
static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
// We shouldn't get here if we've hit an error
MOZ_ASSERT(!decoder->HasError(), "Finishing up PNG but hit error!");
int32_t loop_count = 0;
#ifdef PNG_APNG_SUPPORTED
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_acTL)) {
int32_t num_plays = png_get_num_plays(png_ptr, info_ptr);
loop_count = num_plays - 1;
}
#endif
// Send final notifications
decoder->EndImageFrame();
decoder->PostDecodeDone(loop_count);
}
示例2: read_data_fn
static void read_data_fn(png_structp png_ptr, png_bytep data, png_size_t length)
{
struct png_t* png = (struct png_t*)png_get_progressive_ptr(png_ptr);
if(png->pos + length > png->size) png_error(png_ptr, "Read Error");
memcpy(data, &png->data[png->pos], length);
png->pos += length;
}
示例3: end_callback
void PngReader::end_callback(
png_structp png, png_infop info )
{
PngReader* reader =
( PngReader* )png_get_progressive_ptr( png );
reader->m_finished = true;
}
示例4: png_end_callback
/* Called after reading the entire image */
static void
png_end_callback (png_structp png_read_ptr,
png_infop png_info_ptr)
{
LoadContext* lc;
lc = png_get_progressive_ptr(png_read_ptr);
if (lc->fatal_error_occurred)
return;
}
示例5: pngDecEndCallback
void pngDecEndCallback(png_structp png_ptr, png_infop info)
{
PngStream* stream = (PngStream*)png_get_progressive_ptr(png_ptr);
if (!stream)
{
cellPngDec.error("Failed to obtain streamPtr in endCallback.");
return;
}
stream->endOfFile = true;
}
示例6: pngDecInfoCallback
void pngDecInfoCallback(png_structp png_ptr, png_infop info)
{
PngStream* stream = (PngStream*)png_get_progressive_ptr(png_ptr);
if (!stream)
{
cellPngDec.error("Failed to obtain streamPtr in rowCallback.");
return;
}
const size_t remaining = png_process_data_pause(png_ptr, false);
stream->buffer->cursor += (stream->buffer->length - remaining);
}
示例7: row_callback
static void row_callback(png_structp png_s, png_bytep new_row,
png_uint_32 row_num, int pass)
{
nspng_content *png_c = png_get_progressive_ptr(png_s);
unsigned long rowbytes = png_c->rowbytes;
unsigned char *buffer, *row;
/* Give up if there's no bitmap */
if (png_c->bitmap == NULL)
return;
/* Abort if we've not got any data */
if (new_row == NULL)
return;
/* Get bitmap buffer */
buffer = bitmap_get_buffer(png_c->bitmap);
if (buffer == NULL) {
/* No buffer, bail out */
longjmp(png_jmpbuf(png_s), 1);
}
/* Calculate address of row start */
row = buffer + (png_c->rowstride * row_num);
/* Handle interlaced sprites using the Adam7 algorithm */
if (png_c->interlace) {
unsigned long dst_off;
unsigned long src_off = 0;
unsigned int start, step;
start = interlace_start[pass];
step = interlace_step[pass];
row_num = interlace_row_start[pass] +
interlace_row_step[pass] * row_num;
/* Copy the data to our current row taking interlacing
* into consideration */
row = buffer + (png_c->rowstride * row_num);
for (dst_off = start; dst_off < rowbytes; dst_off += step) {
row[dst_off++] = new_row[src_off++];
row[dst_off++] = new_row[src_off++];
row[dst_off++] = new_row[src_off++];
row[dst_off++] = new_row[src_off++];
}
} else {
/* Do a fast memcpy of the row data */
memcpy(row, new_row, rowbytes);
}
}
示例8: row_callback
void PngReader::row_callback(
png_structp png, png_bytep row,
png_uint_32 rowpos, int pass )
{
if( !row )
{
return;
}
PngReader* reader =
( PngReader* )png_get_progressive_ptr( png );
png_progressive_combine_row(
png,
reader->m_data->m_data +
reader->m_stride * ( reader->m_height - rowpos - 1 ),
row );
}
示例9: _png_get_row_func
static void _png_get_row_func(png_structp png_ptr,
png_bytep new_row,
png_uint_32 row_num,
int pass) {
FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr);
if (!p)
return;
CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr;
uint8_t* src_buf = nullptr;
if (!pModule->AskScanlineBufCallback(p->child_ptr, row_num, src_buf)) {
png_error(png_ptr, "Ask Scanline buffer Callback Error");
}
if (src_buf) {
png_progressive_combine_row(png_ptr, src_buf, new_row);
}
pModule->FillScanlineBufCompletedCallback(p->child_ptr, pass, row_num);
}
示例10: decode
bool decode(const SharedBuffer& data, bool sizeOnly)
{
m_decodingSizeOnly = sizeOnly;
PNGImageDecoder* decoder = static_cast<PNGImageDecoder*>(png_get_progressive_ptr(m_png));
// We need to do the setjmp here. Otherwise bad things will happen.
if (setjmp(JMPBUF(m_png)))
return decoder->setFailed();
const char* segment;
while (unsigned segmentLength = data.getSomeData(segment, m_readOffset)) {
m_readOffset += segmentLength;
m_currentBufferSize = m_readOffset;
png_process_data(m_png, m_info, reinterpret_cast<png_bytep>(const_cast<char*>(segment)), segmentLength);
// We explicitly specify the superclass isSizeAvailable() because we
// merely want to check if we've managed to set the size, not
// (recursively) trigger additional decoding if we haven't.
if (sizeOnly ? decoder->ImageDecoder::isSizeAvailable() : decoder->isComplete())
return true;
}
return false;
}
示例11: png_row_callback
/* Called for each row; note that you will get duplicate row numbers
for interlaced PNGs */
static void
png_row_callback (png_structp png_read_ptr,
png_bytep new_row,
png_uint_32 row_num,
int pass_num)
{
LoadContext* lc;
guchar* old_row = NULL;
lc = png_get_progressive_ptr(png_read_ptr);
if (lc->fatal_error_occurred)
return;
if (row_num >= lc->pixbuf->height) {
lc->fatal_error_occurred = TRUE;
if (lc->error && *lc->error == NULL) {
g_set_error_literal (lc->error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Fatal error reading PNG image file"));
}
return;
}
if (lc->first_row_seen_in_chunk < 0) {
lc->first_row_seen_in_chunk = row_num;
lc->first_pass_seen_in_chunk = pass_num;
}
lc->max_row_seen_in_chunk = MAX(lc->max_row_seen_in_chunk, ((gint)row_num));
lc->last_row_seen_in_chunk = row_num;
lc->last_pass_seen_in_chunk = pass_num;
old_row = lc->pixbuf->pixels + (row_num * lc->pixbuf->rowstride);
png_progressive_combine_row(lc->png_read_ptr, old_row, new_row);
}
示例12: info_callback
void PngReader::info_callback(
png_structp png, png_infop info )
{
PngReader* reader =
( PngReader* )png_get_progressive_ptr( png );
int bitdepth;
int colortype;
png_get_IHDR( png, info,
( png_uint_32* )&reader->m_width,
( png_uint_32* )&reader->m_height,
&bitdepth, &colortype, 0, 0, 0 );
formattable[ reader->m_format ].setformat(
png, info, bitdepth, colortype );
png_set_interlace_handling( png );
png_read_update_info( png, info );
reader->m_stride =
reader->m_width *
formattable[ reader->m_format ].pixelstride;
size_t size = reader->m_stride * reader->m_height;
reader->m_data = DataBuffer::create(
size, size, 0 );
memset( reader->m_data->m_data, 0, size );
}
示例13: pngDecRowCallback
void pngDecRowCallback(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass)
{
PngStream* stream = (PngStream*)png_get_progressive_ptr(png_ptr);
if (!stream)
{
cellPngDec.error("Failed to obtain streamPtr in rowCallback.");
return;
}
// we have to check this everytime as this func can be called multiple times per row, and/or only once per row
if (stream->nextRow + stream->outputCounts == row_num)
stream->nextRow = row_num;
if (stream->ppuContext && (stream->nextRow == row_num || pass > 0))
{
if (pass > 0 )
{
stream->cbDispInfo->scanPassCount = pass;
stream->cbDispInfo->nextOutputStartY = row_num;
}
else {
stream->cbDispInfo->scanPassCount = 0;
stream->cbDispInfo->nextOutputStartY = 0;
}
stream->cbDispInfo->outputImage = stream->cbDispParam->nextOutputImage;
stream->cbCtrlDisp.cbCtrlDispFunc(*stream->ppuContext, stream->cbDispInfo, stream->cbDispParam, stream->cbCtrlDisp.cbCtrlDispArg);
stream->cbDispInfo->outputStartY = row_num;
}
u8* data;
if (pass > 0)
data = static_cast<u8*>(stream->cbDispParam->nextOutputImage.get_ptr());
else
data = static_cast<u8*>(stream->cbDispParam->nextOutputImage.get_ptr()) + ((row_num - stream->cbDispInfo->outputStartY) * stream->cbDispInfo->outputFrameWidthByte);
png_progressive_combine_row(png_ptr, data, new_row);
}
示例14: info_callback
/**
* info_callback -- PNG header has been completely received, prepare to process
* image data
*/
static void info_callback(png_structp png_s, png_infop info)
{
int interlace;
png_uint_32 width, height;
nspng_content *png_c = png_get_progressive_ptr(png_s);
width = png_get_image_width(png_s, info);
height = png_get_image_height(png_s, info);
interlace = png_get_interlace_type(png_s, info);
png_c->base.width = width;
png_c->base.height = height;
png_c->base.size += width * height * 4;
/* see if progressive-conversion should continue */
if (image_cache_speculate((struct content *)png_c) == false) {
longjmp(png_jmpbuf(png_s), CBERR_NOPRE);
}
/* Claim the required memory for the converted PNG */
png_c->bitmap = bitmap_create(width, height, BITMAP_NEW);
if (png_c->bitmap == NULL) {
/* Failed to create bitmap skip pre-conversion */
longjmp(png_jmpbuf(png_s), CBERR_NOPRE);
}
png_c->rowstride = bitmap_get_rowstride(png_c->bitmap);
png_c->bpp = bitmap_get_bpp(png_c->bitmap);
nspng_setup_transforms(png_s, info);
png_c->rowbytes = png_get_rowbytes(png_s, info);
png_c->interlace = (interlace == PNG_INTERLACE_ADAM7);
LOG(("size %li * %li, rowbytes %zu", (unsigned long)width,
(unsigned long)height, png_c->rowbytes));
}
示例15: readpng2_info_callback
static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
{
mainprog_info *mainprog_ptr;
int color_type, bit_depth;
png_uint_32 width, height;
#ifdef PNG_FLOATING_POINT_SUPPORTED
double gamma;
#else
png_fixed_point gamma;
#endif
/* setjmp() doesn't make sense here, because we'd either have to exit(),
* longjmp() ourselves, or return control to libpng, which doesn't want
* to see us again. By not doing anything here, libpng will instead jump
* to readpng2_decode_data(), which can return an error value to the main
* program. */
/* retrieve the pointer to our special-purpose struct, using the png_ptr
* that libpng passed back to us (i.e., not a global this time--there's
* no real difference for a single image, but for a multithreaded browser
* decoding several PNG images at the same time, one needs to avoid mixing
* up different images' structs) */
mainprog_ptr = png_get_progressive_ptr(png_ptr);
if (mainprog_ptr == NULL) { /* we be hosed */
fprintf(stderr,
"readpng2 error: main struct not recoverable in info_callback.\n");
fflush(stderr);
return;
/*
* Alternatively, we could call our error-handler just like libpng
* does, which would effectively terminate the program. Since this
* can only happen if png_ptr gets redirected somewhere odd or the
* main PNG struct gets wiped, we're probably toast anyway. (If
* png_ptr itself is NULL, we would not have been called.)
*/
}
/* this is just like in the non-progressive case */
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
NULL, NULL, NULL);
mainprog_ptr->width = (ulg)width;
mainprog_ptr->height = (ulg)height;
/* since we know we've read all of the PNG file's "header" (i.e., up
* to IDAT), we can check for a background color here */
if (mainprog_ptr->need_bgcolor &&
png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD))
{
png_color_16p pBackground;
/* it is not obvious from the libpng documentation, but this function
* takes a pointer to a pointer, and it always returns valid red,
* green and blue values, regardless of color_type: */
png_get_bKGD(png_ptr, info_ptr, &pBackground);
/* however, it always returns the raw bKGD data, regardless of any
* bit-depth transformations, so check depth and adjust if necessary */
if (bit_depth == 16) {
mainprog_ptr->bg_red = pBackground->red >> 8;
mainprog_ptr->bg_green = pBackground->green >> 8;
mainprog_ptr->bg_blue = pBackground->blue >> 8;
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {