当前位置: 首页>>代码示例>>C++>>正文


C++ png_get_io_ptr函数代码示例

本文整理汇总了C++中png_get_io_ptr函数的典型用法代码示例。如果您正苦于以下问题:C++ png_get_io_ptr函数的具体用法?C++ png_get_io_ptr怎么用?C++ png_get_io_ptr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了png_get_io_ptr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _png_read

static void _png_read(png_structp png_ptr, png_bytep data, png_size_t length)
{
	struct _bb* p = static_cast<struct _bb*>(png_get_io_ptr(png_ptr));
	const UT_Byte* pBytes = p->pBB->getPointer(0);

	// make sure that we don't read outside of pBytes
	if (p->iCurPos >= p->pBB->getLength() - length) {
		UT_WARNINGMSG(("PNG: Reading past buffer bounds. cur = %u, buflen = %u, length = %lu\n",
					   p->iCurPos, p->pBB->getLength(), length));
		length = p->pBB->getLength() - p->iCurPos;
		if (length == 0) {
			UT_WARNINGMSG(("PNG: Truncating to ZERO length.\n"));
			png_error(png_ptr, "Premature end of buffer");
			return;
		} else {
			UT_WARNINGMSG(("PNG: Truncating to %lu.\n", length));
		}
	}
	memcpy(data, pBytes + p->iCurPos, length);
	p->iCurPos += length;
}
开发者ID:hfiguiere,项目名称:abiword,代码行数:21,代码来源:ut_png.cpp

示例2: caerLibPNGWriteBuffer

static void caerLibPNGWriteBuffer(png_structp png_ptr, png_bytep data, png_size_t length) {
	struct mem_encode *p = (struct mem_encode *) png_get_io_ptr(png_ptr);
	size_t nsize = p->size + length;

	// Allocate or grow buffer as needed.
	if (p->buffer) {
		p->buffer = realloc(p->buffer, nsize);
	}
	else {
		p->buffer = malloc(nsize);
	}

	if (p->buffer == NULL) {
		png_error(png_ptr, "Write Buffer Error");
		return;
	}

	// Copy the new bytes to the end of the buffer.
	memcpy(p->buffer + p->size, data, length);
	p->size += length;
}
开发者ID:baspijhor,项目名称:caer,代码行数:21,代码来源:output_common.c

示例3: memcpy

  void PngReader::PngRabi::MemoryCallback(png_structp png_ptr, 
                                          png_bytep outBytes, 
                                          png_size_t byteCountToRead)
  {
    MemoryBuffer* from = reinterpret_cast<MemoryBuffer*>(png_get_io_ptr(png_ptr));

    if (!from->ok_)
    {
      return;
    }

    if (from->pos_ + byteCountToRead > from->size_)
    {
      from->ok_ = false;
      return;
    }

    memcpy(outBytes, from->buffer_ + from->pos_, byteCountToRead);

    from->pos_ += byteCountToRead;
  }
开发者ID:PACSinTERRA,项目名称:orthanc,代码行数:21,代码来源:PngReader.cpp

示例4: user_end_callback

static void
user_end_callback (png_structp png_ptr, png_infop info)
{
  GstPngDec *pngdec = NULL;

  pngdec = GST_PNGDEC (png_get_io_ptr (png_ptr));

  GST_LOG_OBJECT (pngdec, "and we are done reading this image");

  if (!pngdec->current_frame->output_buffer)
    return;

  gst_buffer_unmap (pngdec->current_frame->input_buffer,
      &pngdec->current_frame_map);

  pngdec->ret =
      gst_video_decoder_finish_frame (GST_VIDEO_DECODER (pngdec),
      pngdec->current_frame);

  pngdec->image_ready = TRUE;
}
开发者ID:DylanZA,项目名称:gst-plugins-good,代码行数:21,代码来源:gstpngdec.c

示例5: read_data

static void read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
  png_size_t check;
  FILE *fp;

  if (png_ptr == NULL )
    return;

  fp = (FILE *) png_get_io_ptr(png_ptr);

  if ( fp == NULL )
    return;

  /* fread() returns 0 on error, so it is OK to store this in a png_size_t
   * instead of an int, which is what fread() actually returns.
   */
  check = fread(data, 1, length, fp);

  if (check != length)
    G_fatal_error(_("Unable to read PNG"));
}
开发者ID:rkrug,项目名称:grass-ci,代码行数:21,代码来源:read_png.c

示例6: user_info_callback

static void
user_info_callback (png_structp png_ptr, png_infop info)
{
  GstPngDec *pngdec = NULL;
  GstFlowReturn ret = GST_FLOW_OK;
  size_t buffer_size;
  GstBuffer *buffer = NULL;

  pngdec = GST_PNGDEC (png_get_io_ptr (png_ptr));

  GST_LOG ("info ready");

  /* Generate the caps and configure */
  ret = gst_pngdec_caps_create_and_set (pngdec);
  if (ret != GST_FLOW_OK) {
    goto beach;
  }

  /* Allocate output buffer */
  pngdec->rowbytes = png_get_rowbytes (pngdec->png, pngdec->info);
  if (pngdec->rowbytes > (G_MAXUINT32 - 3)
      || pngdec->height > G_MAXUINT32 / pngdec->rowbytes) {
    ret = GST_FLOW_ERROR;
    goto beach;
  }
  pngdec->rowbytes = GST_ROUND_UP_4 (pngdec->rowbytes);
  buffer_size = pngdec->height * pngdec->rowbytes;

  ret =
      gst_pad_alloc_buffer_and_set_caps (pngdec->srcpad, GST_BUFFER_OFFSET_NONE,
      buffer_size, GST_PAD_CAPS (pngdec->srcpad), &buffer);
  if (ret != GST_FLOW_OK) {
    goto beach;
  }

  pngdec->buffer_out = buffer;

beach:
  pngdec->ret = ret;
}
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:40,代码来源:gstpngdec.c

示例7: opng_handle_chunk

/*
 * Chunk handler
 */
static void opng_handle_chunk(png_structp png_ptr, png_bytep chunk_type)
{
    if (opng_is_image_chunk(chunk_type))
        return;
    struct opng_codec_context * context = (struct opng_codec_context *)png_get_io_ptr(png_ptr);
    struct opng_encoding_stats * stats = context->stats;

    /* Bypass the chunks that are intended to be stripped. */
    if (opng_transform_query_strip_chunk(context->transformer, chunk_type))
    {
        char debug_chunk_name[5];
        memcpy(debug_chunk_name, chunk_type, 4);
        debug_chunk_name[4] = (char)0;
        if (opng_is_apng_chunk(chunk_type))
        {
            /*printf("Snipping: %s\n", debug_chunk_name);*/
            stats->flags |= OPNG_HAS_SNIPPED_IMAGES;
        }
        else
        {
            /*printf("Stripping: %s\n", debug_chunk_name);*/
            stats->flags |= OPNG_HAS_STRIPPED_METADATA;
        }
        opng_set_keep_unknown_chunk(png_ptr, PNG_HANDLE_CHUNK_NEVER, chunk_type);
        return;
    }

    /* Let libpng handle bKGD, hIST and sBIT. */
    if (memcmp(chunk_type, opng_sig_bKGD, 4) == 0 ||
            memcmp(chunk_type, opng_sig_hIST, 4) == 0 ||
            memcmp(chunk_type, opng_sig_sBIT, 4) == 0)
        return;

    /* Everything else is handled as unknown by libpng. */
    if (memcmp(chunk_type, opng_sig_dSIG, 4) == 0)
        stats->flags |= OPNG_HAS_DIGITAL_SIGNATURE;
    else if (memcmp(chunk_type, opng_sig_fdAT, 4) == 0)
        stats->flags |= OPNG_HAS_MULTIPLE_IMAGES;
    opng_set_keep_unknown_chunk(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, chunk_type);
}
开发者ID:RamiroCruzo,项目名称:Efficient-Compression-Tool,代码行数:43,代码来源:codec.c

示例8: png_data_write_func

void
png_data_write_func(png_structp png_ptr, png_bytep buf, png_size_t size) {
    my_png_buffer *png_buff = (my_png_buffer *)png_get_io_ptr(png_ptr);
    unsigned long new_data_len;
    unsigned char *tmp;
    if (png_buff->data_offset + size > png_buff->data_len) {
        new_data_len = 2 * png_buff->data_len;
        if (png_buff->data_offset + size > new_data_len) {
            new_data_len = png_buff->data_offset + size;
        }
        tmp = realloc(png_buff->data, new_data_len);
        if (tmp == NULL) {
            fprintf(stderr, "png_data_write_func: can't realloc: new_data_len(%lu), data_len(%lu)\n",
                    new_data_len, png_buff->data_len);
            png_error(png_ptr,"png_data_write_func failed");
        }
        png_buff->data = tmp;
        png_buff->data_len = new_data_len;
    }
    memcpy(png_buff->data + png_buff->data_offset, buf, size);
    png_buff->data_offset += size;
}
开发者ID:gitpan,项目名称:SWFEditor,代码行数:22,代码来源:swf_png.c

示例9: loadPNGEx_user_read_data

void loadPNGEx_user_read_data(png_structp png_ptr,
							  png_bytep data, png_size_t length) {
	loadPNGExData *lPEd = (loadPNGExData *)png_get_io_ptr(png_ptr);

	// check requested length
	if ((int)length > lPEd->bufLength - lPEd->bufPos) {
		cprintf("loadPNGEx_user_read_data(): too much data requested by libpng, padding with 0\n");

		memset(data + lPEd->bufLength - lPEd->bufPos, 0, length - (lPEd->bufLength - lPEd->bufPos));
		length = lPEd->bufLength - lPEd->bufPos;
	}

	// copy data
	memcpy(data, lPEd->buf + lPEd->bufPos, length);

	// update structure
	lPEd->bufPos += (int)length;

	//return length;

	return;
}
开发者ID:maarten990,项目名称:bsc-pga,代码行数:22,代码来源:pngwrapper.cpp

示例10: tarpng_read_data

void tarpng_read_data(png_structp read_ptr, png_bytep data, png_size_t length)
{
	/* Get the animation archive. */
	struct archive *animarc;
	animarc = (struct archive *)png_get_io_ptr(read_ptr);
	/* printf("%d bytes requested\n", length); */
	int res;
	res = archive_read_data(animarc, data, length);
	/* If the result is zero then no more data. If the result is FATAL, WARN,
	 * or RETRY there was a problem. If the value is > 1 then it wrote that
	 * many bytes.
	 */
	if (res == 0) {
		printf("EOF\n");	
	} else if (res == ARCHIVE_FATAL || res == ARCHIVE_WARN || res == ARCHIVE_RETRY) {
		png_error(read_ptr, "Read Error!\n");
		printf("Read error!\n");
		/* set error and end */
	} else if ( res > 1) {
		/* printf("Read %d bytes.\n",res); */
	}
}
开发者ID:fallrisk,项目名称:led_drapes,代码行数:22,代码来源:png-helper.c

示例11: sizeof

void
PngEncoder::png_chunk_producer(png_structp png_ptr, png_bytep data, png_size_t length)
{
    PngEncoder *p = (PngEncoder *)png_get_io_ptr(png_ptr);

    if (!p->png) {
        p->png = (char *)malloc(sizeof(p->png)*41); // from tests pngs are at least 41 bytes
        if (!p->png)
            throw "malloc failed in node-png (PngEncoder::png_chunk_producer)";
        p->mem_len = 41;
    }

    if (p->png_len + length > p->mem_len) {
        char *new_png = (char *)realloc(p->png, sizeof(char)*p->png_len + length);
        if (!new_png)
            throw "realloc failed in node-png (PngEncoder::png_chunk_producer).";
        p->png = new_png;
        p->mem_len += length;
    }
    memcpy(p->png + p->png_len, data, length);
    p->png_len += length;
}
开发者ID:dahalecp,项目名称:node-png,代码行数:22,代码来源:png_encoder.cpp

示例12: write_png2

static VALUE
write_png2(VALUE *args)
{
    struct io_write *data;
    png_structp png_ptr = (png_structp)args[0];
    png_infop info_ptr = (png_infop)args[1];
    VALUE scanline, image_in = args[2];
    size_t i;

    write_configure(image_in, png_ptr, info_ptr);
    png_write_info(png_ptr, info_ptr);

    for (i = 0; i < png_get_image_height(png_ptr, info_ptr); i++) {
	scanline = rb_funcall(image_in, id_gets, 0);
	write_scanline(scanline, png_ptr, info_ptr);
    }
    png_write_end(png_ptr, info_ptr);

    data = (struct io_write *)png_get_io_ptr(png_ptr);

    return INT2FIX(data->total);
}
开发者ID:ender672,项目名称:axon,代码行数:22,代码来源:png.c

示例13: user_endrow_callback

static void
user_endrow_callback (png_structp png_ptr, png_bytep new_row,
    png_uint_32 row_num, int pass)
{
  GstPngDec *pngdec = NULL;

  pngdec = GST_PNGDEC (png_get_io_ptr (png_ptr));

  /* FIXME: implement interlaced pictures */

  /* If buffer_out doesn't exist, it means buffer_alloc failed, which 
   * will already have set the return code */
  if (GST_IS_BUFFER (pngdec->buffer_out)) {
    size_t offset = row_num * pngdec->rowbytes;

    GST_LOG ("got row %u, copying in buffer %p at offset %" G_GSIZE_FORMAT,
        (guint) row_num, pngdec->buffer_out, offset);
    memcpy (GST_BUFFER_DATA (pngdec->buffer_out) + offset, new_row,
        pngdec->rowbytes);
    pngdec->ret = GST_FLOW_OK;
  }
}
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:22,代码来源:gstpngdec.c

示例14: iod_read_fn

static
void CALLBACK_CALL_TYPE iod_read_fn(png_structp png_ptr, png_bytep data, png_size_t length)
{
    QPngHandlerPrivate *d = (QPngHandlerPrivate *)png_get_io_ptr(png_ptr);
    QIODevice *in = d->q->device();

    if (d->state == QPngHandlerPrivate::ReadingEnd && !in->isSequential() && (in->size() - in->pos()) < 4 && length == 4) {
        // Workaround for certain malformed PNGs that lack the final crc bytes
        uchar endcrc[4] = { 0xae, 0x42, 0x60, 0x82 };
        qMemCopy(data, endcrc, 4);
        in->seek(in->size());
        return;
    }

    while (length) {
        int nr = in->read((char*)data, length);
        if (nr <= 0) {
            png_error(png_ptr, "Read Error");
            return;
        }
        length -= nr;
    }
}
开发者ID:AlekSi,项目名称:phantomjs,代码行数:23,代码来源:qpnghandler.cpp

示例15: read_cb

/* libpng calls this (at read_png_data's request)
* to copy data from the in-RAM PNG into our bitmap */
void read_cb (png_structp png_ptr, png_bytep outBytes, png_size_t byteCountToRead) {
	struct bufdata * bd = png_get_io_ptr(png_ptr);

	//pthread_mutex_lock(&lock_read_cb);
	if (bd == NULL)
		abort_("[read_png_file/read_cb] invalid memory passed to png reader");
	if (bd->pos + byteCountToRead >= bd->len)
	{
#ifdef _DEBUG_1_
	printf("\nError (read_cb): bd->pos: %d, byteCountToRead: %d, bd->len: %d\n", bd->pos, byteCountToRead, bd->len);
	fflush(stdout);
#endif
		abort_("[read_png_file/read_cb] attempting to read beyond end of buffer");
	}
#ifdef _DEBUG_1_
	//printf("\read_cb: bd->pos: %d, byteCountToRead: %d, bd->len: %d\n", bd->pos, byteCountToRead, bd->len);
	//fflush(stdout);
#endif

	memcpy(outBytes, bd->buf+bd->pos, byteCountToRead);
	bd->pos += byteCountToRead;
	//pthread_mutex_unlock(&lock_read_cb);
}
开发者ID:lzljzys,项目名称:OpenGL_OpenMP_Pthread,代码行数:25,代码来源:paster_nbio_gary4.c


注:本文中的png_get_io_ptr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。