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


C++ png_read_row函数代码示例

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


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

示例1: read_image

int read_image (dt_imageio_png_t *png, void *out)
{
  if (setjmp(png_jmpbuf(png->png_ptr)))
  {
    fclose(png->f);
    png_destroy_read_struct(&png->png_ptr, NULL, NULL);
    return 1;
  }
  // reflect changes
  png_read_update_info(png->png_ptr, png->info_ptr);

  png_bytep row_pointer = (png_bytep) out;
  unsigned long rowbytes = png_get_rowbytes(png->png_ptr, png->info_ptr);

  for (int y = 0; y < png->height; y++)
  {
    png_read_row(png->png_ptr, row_pointer, NULL);
    row_pointer += rowbytes;
  }

  png_read_end(png->png_ptr, png->info_ptr);
  png_destroy_read_struct(&png->png_ptr, &png->info_ptr, NULL);

  fclose(png->f);
  return 0;
}
开发者ID:EvilBit,项目名称:darktable,代码行数:26,代码来源:imageio_png.c

示例2: read_scanline

 void read_scanline( byte_t* dst )
 {
     png_read_row( this->get()->_struct
                 , dst
                 , NULL
                 );
 }
开发者ID:BackupTheBerlios,项目名称:airdc-svn,代码行数:7,代码来源:scanline_read.hpp

示例3: res_create_theme_display_surface

int res_create_theme_display_surface(const char* name, const char* themename, gr_surface* pSurface) {
    gr_surface surface = NULL;
    int result = 0;
    png_structp png_ptr = NULL;
    png_infop info_ptr = NULL;
    png_uint_32 width, height;
    png_byte channels;

    *pSurface = NULL;

    result = open_theme_png(name, themename, &png_ptr, &info_ptr, &width, &height, &channels);
    if (result < 0) return result;

    surface = init_display_surface(width, height);
    if (surface == NULL) {
        result = -8;
        goto exit;
    }

    unsigned char* p_row = malloc(width * 4);
    unsigned int y;
    for (y = 0; y < height; ++y) {
        png_read_row(png_ptr, p_row, NULL);
        transform_rgb_to_draw(p_row, surface->data + y * surface->row_bytes, channels, width);
    }
    free(p_row);

    *pSurface = surface;

    exit:
    png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
    if (result < 0 && surface != NULL) free(surface);
    return result;
}
开发者ID:TheNameIsNigel,项目名称:poc_bootable_recovery,代码行数:34,代码来源:resources.c

示例4: each_interlace_none

static VALUE each_interlace_none(struct each_args *args)
{
    struct readerdata *reader;
    unsigned char *inwidthbuf, *outwidthbuf, *yinbuf;
    struct xscaler *xs;
    struct yscaler *ys;
    uint32_t i, scaley;
    int cmp;

    reader = args->reader;
    xs = &args->xs;
    inwidthbuf = xscaler_psl_pos0(xs);
    outwidthbuf = args->outwidthbuf;
    ys = &args->ys;
    scaley = reader->scale_height;
    cmp = png_get_channels(reader->png, reader->info);

    png_write_info(args->wpng, args->winfo);

    for(i=0; i<scaley; i++) {
        while ((yinbuf = yscaler_next(ys))) {
            png_read_row(reader->png, inwidthbuf, NULL);
            xscaler_scale(xs, yinbuf);
        }
        yscaler_scale(ys, outwidthbuf, i, cmp, 0);
        png_write_row(args->wpng, outwidthbuf);
    }

    png_write_end(args->wpng, args->winfo);
    return Qnil;
}
开发者ID:ender672,项目名称:oil,代码行数:31,代码来源:png.c

示例5: Read3ByteRow

static void
Read3ByteRow(png_structp png_ptr, unsigned char *tmpRow, unsigned char *ImgData, int row_num, int width)
{
  int pos;
  unsigned char *img_ptr, *tmp_ptr;

  png_read_row(png_ptr, tmpRow, NULL);
  img_ptr = ImgData + (row_num * width * 4);
  tmp_ptr = tmpRow;
  for (pos = 0; pos < width; pos++)
  {
    *img_ptr = *tmp_ptr;
    img_ptr++;
    tmp_ptr++;
    *img_ptr = *tmp_ptr;
    img_ptr++;
    tmp_ptr++;
    *img_ptr = *tmp_ptr;
    img_ptr++;
    tmp_ptr++;

    *img_ptr = 255;		/* Alpha channel */
    img_ptr++;
  }
}
开发者ID:mcr,项目名称:vtwm,代码行数:25,代码来源:image_formats.c

示例6: p_gets

static VALUE
p_gets(VALUE self)
{
    struct png_data *reader;
    png_structp png_ptr;
    png_infop info_ptr;
    png_uint_32 sl_width;
    size_t height;
    VALUE sl;

    Data_Get_Struct(self, struct png_data, reader);
    png_ptr = reader->png_ptr;
    info_ptr = reader->info_ptr;

    height = png_get_image_height(png_ptr, info_ptr);
    if (reader->lineno >= height)
	return Qnil;

    sl_width = png_get_rowbytes(png_ptr, info_ptr);

    sl = rb_str_new(0, sl_width);
    png_read_row(png_ptr, (png_bytep)RSTRING_PTR(sl), (png_bytep)NULL);
    reader->lineno += 1;

    if (reader->lineno >= height)
	png_read_end(png_ptr, info_ptr);

    return sl;
}
开发者ID:ender672,项目名称:axon,代码行数:29,代码来源:png.c

示例7: png_read_image

/* Read the entire image.  If the image has an alpha channel or a tRNS
 * chunk, and you have called png_handle_alpha()[*], you will need to
 * initialize the image to the current image that PNG will be overlaying.
 * We set the num_rows again here, in case it was incorrectly set in
 * png_read_start_row() by a call to png_read_update_info() or
 * png_start_read_image() if png_set_interlace_handling() wasn't called
 * prior to either of these functions like it should have been.  You can
 * only call this function once.  If you desire to have an image for
 * each pass of a interlaced image, use png_read_rows() instead.
 *
 * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.8
 */
void PNGAPI
png_read_image(png_structp png_ptr, png_bytepp image)
{
  png_uint_32 i, image_height;
  int pass, j;
  png_bytepp rp;

  png_debug(1, "in png_read_image\n");

#ifdef PNG_READ_INTERLACING_SUPPORTED
  pass = png_set_interlace_handling(png_ptr);
#else

  if (png_ptr->interlaced)
    png_error(png_ptr,
              "Cannot read interlaced image -- interlace handler disabled.");

  pass = 1;
#endif


  image_height = png_ptr->height;
  png_ptr->num_rows = image_height; /* Make sure this is set correctly */

  for (j = 0; j < pass; j++) {
    rp = image;

    for (i = 0; i < image_height; i++) {
      png_read_row(png_ptr, *rp, png_bytep_NULL);
      rp++;
    }
  }
}
开发者ID:cafeinecake,项目名称:hge2,代码行数:45,代码来源:pngread.c

示例8: read_image_data

void read_image_data(const char* filename, png_bytep* input, png_bytep* output, size_t* w, size_t* h) {

   int i;

   /* Open input file */
   FILE *png_input;
   if((png_input = fopen("input.png", "rb")) == NULL) {
      perror("Can't read input image file");
      exit(1);
   }

   /* Read image data */
   png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
   png_infop info_ptr = png_create_info_struct(png_ptr);
   png_init_io(png_ptr, png_input);
   png_read_info(png_ptr, info_ptr);
   *w = png_get_image_width(png_ptr, info_ptr);
   *h = png_get_image_height(png_ptr, info_ptr);

   /* Allocate input/output memory and initialize data */
   input = (png_bytep*)malloc(*h * png_get_rowbytes(png_ptr, info_ptr));
   output = (png_bytep*)malloc(*h * png_get_rowbytes(png_ptr, info_ptr) * SCALE_FACTOR  * SCALE_FACTOR );
   for(i=0; i<*h; i++) {
      png_read_row(png_ptr, *input + i * png_get_rowbytes(png_ptr, info_ptr), NULL);
   }

   /* Close input file */
   png_read_end(png_ptr, info_ptr);
   png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
  // fclose(png_input);
}
开发者ID:Leinar,项目名称:trunk,代码行数:31,代码来源:main1.cpp

示例9: read_row

 /**
  * \brief Reads a row of image data at a time.
  */
 void read_row(byte* bytes)
 {
     if (setjmp(png_jmpbuf(m_png)))
     {
         throw error(m_error);
     }
     png_read_row(m_png, bytes, 0);
 }
开发者ID:LRacoci,项目名称:ImageEditor,代码行数:11,代码来源:reader.hpp

示例10: throw

bool emPngImageFileModel::TryContinueLoading() throw(emString)
{
	png_textp t;
	int e,i,n;

	if (!L->ImagePrepared) {
		Image.Setup(
			L->width,
			L->height,
			L->bytes_per_pixel
		);
		Signal(ChangeSignal);
		L->ImagePrepared=true;
		return false;
	}

	if (setjmp(L->jmpbuffer)) throw emString(L->errorText);

	if (L->y<(int)L->height && L->pass<L->number_of_passes) {
		png_read_row(
			L->png_ptr,
			Image.GetWritableMap()+L->y*Image.GetWidth()*Image.GetChannelCount(),
			NULL
		);
		L->y++;
		if (L->y>=(int)L->height) {
			L->y=0;
			L->pass++;
		}
		Signal(ChangeSignal);
		return false;
	}

	png_read_end(L->png_ptr,L->end_info_ptr);

	for (e=0; e<2; e++) {
		n=png_get_text(
			L->png_ptr,
			e ? L->end_info_ptr : L->info_ptr,
			&t,
			NULL
		);
		for (i=0; i<n; i++) {
			if (
				t[i].text && *t[i].text && t[i].key && (
					strcasecmp(t[i].key,"Comment")==0 ||
					strcasecmp(t[i].key,"Description")==0
				)
			) {
				if (!Comment.IsEmpty()) Comment+='\n';
				Comment+=t[i].text;
			}
		}
	}
	Signal(ChangeSignal);

	return true;
}
开发者ID:ackalker,项目名称:eaglemode,代码行数:58,代码来源:emPngImageFileModel.cpp

示例11: read_png

static int read_png ( FILE *fp ) {
    png_structp png_ptr = png_create_read_struct ( PNG_LIBPNG_VER_STRING,0,0,0 );
    png_infop info_ptr = NULL;
    png_bytep row = NULL, display = NULL;

    if ( png_ptr == NULL )
        return 0;

    if ( setjmp ( png_jmpbuf ( png_ptr ) ) ) {
        png_destroy_read_struct ( &png_ptr, &info_ptr, NULL );
        if ( row != NULL ) free ( row );
        if ( display != NULL ) free ( display );
        return 0;
    }

    png_init_io ( png_ptr, fp );

    info_ptr = png_create_info_struct ( png_ptr );
    if ( info_ptr == NULL )
        png_error ( png_ptr, "OOM allocating info structure" );

    png_read_info ( png_ptr, info_ptr );

    {
        png_size_t rowbytes = png_get_rowbytes ( png_ptr, info_ptr );

        row = malloc ( rowbytes );
        display = malloc ( rowbytes );

        if ( row == NULL || display == NULL )
            png_error ( png_ptr, "OOM allocating row buffers" );

        {
            png_uint_32 height = png_get_image_height ( png_ptr, info_ptr );
            int passes = png_set_interlace_handling ( png_ptr );
            int pass;

            png_start_read_image ( png_ptr );

            for ( pass = 0; pass < passes; ++pass ) {
                png_uint_32 y = height;

                /* NOTE: this trashes the row each time; interlace handling won't
                 * work, but this avoids memory thrashing for speed testing.
                 */
                while ( y-- > 0 )
                    png_read_row ( png_ptr, row, display );
            }
        }
    }

    /* Make sure to read to the end of the file: */
    png_read_end ( png_ptr, info_ptr );
    png_destroy_read_struct ( &png_ptr, &info_ptr, NULL );
    free ( row );
    free ( display );
    return 1;
}
开发者ID:tcoupin,项目名称:rok4,代码行数:58,代码来源:timepng.c

示例12: png_read_row

const unsigned char* CImageLoaderPng::ReadRow(void *row_ptr)
{
#ifdef _engine_COMPILE_WITH_LIBPNG_
	png_read_row((png_structp)row_ptr, (png_bytep)g_png_load_buffer, 0);
	return (const unsigned char*)g_png_load_buffer;
#else
	return 0;
#endif // _engine_COMPILE_WITH_LIBPNG_
}
开发者ID:jduranmaster,项目名称:ltegameengine,代码行数:9,代码来源:CImageLoaderPNG.cpp

示例13: read_scanline

static void read_scanline(struct oil_libpng *ol)
{
	int i;

	for (i=oil_scale_slots(&ol->os); i>0; i--) {
		png_read_row(ol->rpng, ol->inbuf, NULL);
		oil_scale_in(&ol->os, ol->inbuf);
	}
}
开发者ID:ender672,项目名称:liboil,代码行数:9,代码来源:oil_libpng.c

示例14: stencilize

int stencilize (InPng *in_png, char *output_filename)
{
    FILE *fh;
    png_structp png;
    png_infop png_info;
    png_bytep row;
    int i, j;

    if (!(fh = fopen(output_filename, "wb"))) {
	fail("failed to open output file");
    }

    png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
				  NULL, NULL, NULL);
    
    if (!png) {
	fail("could not create png");
    }

    png_info = png_create_info_struct(png);

    if (!png_info) {
	fail("could not create png_info");
    }

    png_init_io(png, fh);

    png_set_IHDR(png, png_info,
		 in_png->info->width,
		 in_png->info->height,
		 in_png->info->bit_depth,
		 in_png->info->color_type,
		 in_png->info->interlace_type,
		 PNG_COMPRESSION_TYPE_DEFAULT,
		 PNG_FILTER_TYPE_DEFAULT);

    png_write_info(png, png_info);

    row = in_png->row;
    for (i = 0; i < in_png->info->height; i++) {
	png_read_row(in_png->png, row, NULL);
	j = 0;
	while (j < in_png->rowstride) {
	    row[j + 0] = 0;
	    row[j + 1] = 0;
	    row[j + 2] = 0;
	    row[j + 3] = 255 - row[j + 3];
	    j += 4;
	}
	png_write_row(png, row);
    }

    png_write_end(png, png_info);
    fclose(fh);
    return 1;
}
开发者ID:xach,项目名称:stencilizer,代码行数:56,代码来源:stencilizer.c

示例15: onSkipScanlines

    bool onSkipScanlines(int count) override {
        if (setjmp(png_jmpbuf(fPng_ptr))) {
            SkCodecPrintf("Failed to skip row.\n");
            return false;
        }

        for (int row = 0; row < count; row++) {
            png_read_row(fPng_ptr, fSwizzlerSrcRow, nullptr);
        }
        return true;
    }
开发者ID:sylvestre,项目名称:skia,代码行数:11,代码来源:SkPngCodec.cpp


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