• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ png_write_row函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: write_gray_alpha_to_gray_alpha

static void write_gray_alpha_to_gray_alpha (png_struct *png, png_byte *data, SLindex_Type num_cols, png_byte *tmpbuf)
{
   if (Is_Little_Endian == 0)
     {
	png_write_row (png, data);
	return;
     }

   byte_swap16 ((unsigned char *) data, (unsigned char *) tmpbuf, num_cols);
   png_write_row (png, tmpbuf);
}
开发者ID:Distrotech,项目名称:slang,代码行数:11,代码来源:png-module.c


示例2: dump_png24_impl

    static void dump_png24_impl(
        png_struct * ppng, png_info * pinfo,
        const uint8_t * data, const size_t width, const size_t height, const size_t rowsize,
        const bool bgr, IsOk is_ok
    ) {
        assert(align4(rowsize) == rowsize);

        png_set_IHDR(ppng, pinfo, width, height, 8,
                    PNG_COLOR_TYPE_RGB,
                    PNG_INTERLACE_NONE,
                    PNG_COMPRESSION_TYPE_BASE,
                    PNG_FILTER_TYPE_BASE);
        png_write_info(ppng, pinfo);

        // send image buffer to file, one pixel row at once
        const uint8_t * row = data;

        if (bgr) {
            uint8_t bgrtmp[8192*4];
            for (size_t k = 0 ; k < height && is_ok(); ++k) {
                const uint8_t * s = row;
                uint8_t * t = bgrtmp;
                uint8_t * e = t + (width / 4) * 12;
                for (; t < e; s += 12, t += 12){
                    t[0] = s[2];
                    t[1] = s[1];
                    t[2] = s[0];

                    t[3] = s[5];
                    t[4] = s[4];
                    t[5] = s[3];

                    t[6] = s[8];
                    t[7] = s[7];
                    t[8] = s[6];

                    t[9] = s[11];
                    t[10] = s[10];
                    t[11] = s[9];
                }
                png_write_row(ppng, const_cast<unsigned char*>(bgrtmp));
                row += rowsize;
            }
        }
        else {
            for (size_t k = 0 ; k < height && is_ok(); ++k) {
                png_write_row(ppng, const_cast<unsigned char*>(row));
                row += rowsize;
            }
        }
    }
开发者ID:speidy,项目名称:redemption,代码行数:51,代码来源:png.hpp


示例3: 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


示例4: each_interlace

static VALUE each_interlace(struct each_args *args)
{
    struct readerdata *reader;
    unsigned char *inwidthbuf, *outwidthbuf;
    uint32_t i, width, height, scaley;
    int cmp;
    struct xscaler *xs;

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

    png_write_info(args->wpng, args->winfo);
    png_read_image(args->reader->png, (png_bytepp)args->scanlines);

    for (i=0; i<scaley; i++) {
        yscaler_prealloc_scale(height, scaley,
                               (uint8_t **)args->scanlines, (uint8_t *)inwidthbuf,
                               i, width, cmp, 0);
        xscaler_scale(xs, outwidthbuf);
        png_write_row(args->wpng, outwidthbuf);
    }
    png_write_end(args->wpng, args->winfo);
    return Qnil;
}
开发者ID:ender672,项目名称:oil,代码行数:30,代码来源:png.c


示例5: save_rgba

/* save_rgba:
 *  Core save routine for 32 bpp images.
 */
static int save_rgba(png_structp png_ptr, BITMAP *bmp)
{
    unsigned char *rowdata;
    int x, y;

    ASSERT(bitmap_color_depth(bmp) == 32);

    rowdata = (unsigned char *)malloc(bmp->w * 4);
    if (!rowdata)
	return 0;

    for (y=0; y<bmp->h; y++) {
	unsigned char *p = rowdata;
	
        for (x=0; x<bmp->w; x++) {
            int c = getpixel(bmp, x, y);
	    *p++ = getr32(c);
	    *p++ = getg32(c);
	    *p++ = getb32(c);
	    *p++ = geta32(c);
        }

        png_write_row(png_ptr, rowdata);
    }

    free(rowdata);

    return 1;
}
开发者ID:zeromus,项目名称:ZeldaClassic,代码行数:32,代码来源:savepng.c


示例6: PNGWritePixels

bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned stride, const void* pixels) {
	png_bytep row = malloc(sizeof(png_bytep) * width * 3);
	if (!row) {
		return false;
	}
	const png_byte* pixelData = pixels;
	if (setjmp(png_jmpbuf(png))) {
		free(row);
		return false;
	}
	unsigned i;
	for (i = 0; i < height; ++i) {
		unsigned x;
		for (x = 0; x < width; ++x) {
#if defined(__POWERPC__) || defined(__PPC__)
			row[x * 3] = pixelData[stride * i * 4 + x * 4 + 3];
			row[x * 3 + 1] = pixelData[stride * i * 4 + x * 4 + 2];
			row[x * 3 + 2] = pixelData[stride * i * 4 + x * 4 + 1];
#else
			row[x * 3] = pixelData[stride * i * 4 + x * 4];
			row[x * 3 + 1] = pixelData[stride * i * 4 + x * 4 + 1];
			row[x * 3 + 2] = pixelData[stride * i * 4 + x * 4 + 2];
#endif
		}
		png_write_row(png, row);
	}
	free(row);
	return true;
}
开发者ID:Carlosamouco,项目名称:mgba,代码行数:29,代码来源:png-io.c


示例7: writepng_encode_row

int writepng_encode_row(mainprog_info *mainprog_ptr)  /* NON-interlaced only! */
{
  AMJU_CALL_STACK;

    png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr;
    png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr;


    /* as always, setjmp() must be called in every function that calls a
     * PNG-writing libpng function */

    if (setjmp(mainprog_ptr->jmpbuf)) {
        png_destroy_write_struct(&png_ptr, &info_ptr);
        mainprog_ptr->png_ptr = NULL;
        mainprog_ptr->info_ptr = NULL;
        return 2;
    }


    /* image_data points at our one row of image data */

    png_write_row(png_ptr, mainprog_ptr->image_data);

    return 0;
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:25,代码来源:SavePng.cpp


示例8: write_image_data

void write_image_data(const char* filename, png_bytep data, size_t w, size_t h) {

   unsigned int i;
   png_structp png_ptr;
   png_infop info_ptr;

   /* Open output file */
   FILE *png_output;
   if((png_output = fopen(filename, "wb")) == NULL) {
      perror("Create output image file");
      exit(1);
   }

   /* Write image data */
   png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
   info_ptr = png_create_info_struct(png_ptr);
   png_init_io(png_ptr, png_output);
   png_set_IHDR(png_ptr, info_ptr, w, h, 16,
         PNG_COLOR_TYPE_GRAY, PNG_INTERLACE_NONE,
         PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
   png_write_info(png_ptr, info_ptr);
   for(i=0; i<h; i++) {
      png_write_row(png_ptr, data + i*png_get_rowbytes(png_ptr, info_ptr));
   }

   /* Close file */
   png_write_end(png_ptr, NULL);
   png_destroy_write_struct(&png_ptr, &info_ptr);
   fclose(png_output);
}
开发者ID:hoyajigi,项目名称:helloopencl,代码行数:30,代码来源:simple_image.c


示例9: save_pixmap_png

int save_pixmap_png(struct pixmap *p, FILE *fp)
{
	int			 result = 0,
				 y;
	png_structp	 png_ptr;
	png_infop	 info_ptr;

	if (p) {
		if ((png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)) != NULL) {
			if ((info_ptr = png_create_info_struct(png_ptr)) != NULL) {
				if (setjmp(png_ptr->jmpbuf) == 0) {
					png_init_io(png_ptr, fp);
					png_set_IHDR(png_ptr, info_ptr, p->width, p->height, 8, (p->components == 1) ? PNG_COLOR_TYPE_GRAY : PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
					png_write_info(png_ptr, info_ptr);
					for (y = 0; y < p->height; y++) {
						png_write_row(png_ptr, (png_bytep)&GET_COMP(p, 0, y, 0));
					}
					png_write_end(png_ptr, info_ptr);
					png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
				} else
					result = -1;
			} else
				result = -1;

			png_destroy_write_struct(&png_ptr,  (png_infopp)NULL);
		} else
			result = -1;
	}

	return result;
}
开发者ID:rajbot,项目名称:gphoto,代码行数:31,代码来源:pixmaps.c


示例10: write_png_image

void write_png_image(char * dest, image_t * image)
{
        FILE *outfile;
        if ((outfile = fopen(dest, "wb")) == NULL) {
                fprintf(stderr, "can't open %s", dest);
                return;
        }
        png_structp  png_ptr;
        png_infop  info_ptr;

        png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
                        NULL, NULL, NULL);
        info_ptr = png_create_info_struct(png_ptr);
        png_init_io(png_ptr, outfile);
        png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);

        png_set_IHDR(png_ptr, info_ptr, image->size[0],
                        image->size[1], 8,
                        PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
                        PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
        png_write_info(png_ptr, info_ptr);

        for(int i = 0; i < image->size[1]; i++) {
                png_write_row(png_ptr
                                , &(*image->pixels)[i * image->size[0] * RGB_CHANNEL]);
        }
        png_write_end(png_ptr, NULL);
        fclose(outfile);
}
开发者ID:bonnefoa,项目名称:imagecmp,代码行数:29,代码来源:image_util.c


示例11: save_truecolour

/* save_truecolour:
 *  Core save routine for 32 bpp images.
 */
static int save_truecolour(png_structp png_ptr, BITMAP *bmp)
{
    unsigned char *row, *p;
    int i, j, c;

    // [OMAR]
    row = malloc(bmp->w * 3);
    //row = malloc(bmp->w * 4);
    if (!row)
	return 0;

    for (i=0; i<bmp->h; i++) {
	p = row;
        for (j = 0; j < bmp->w; j++) {
            c = getpixel(bmp, j, i);
	    *p++ = getr32(c);
	    *p++ = getg32(c);
	    *p++ = getb32(c);
        // [OMAR]
	    //*p++ = geta32(c);
        }

        png_write_row(png_ptr, row);
    }

    free(row);

    return 1;
}
开发者ID:dafyddcrosby,项目名称:meka,代码行数:32,代码来源:savepng.c


示例12: RageSurface_Save_PNG

/* Since libpng forces us to use longjmp, this function shouldn't create any C++
 * objects, and needs to watch out for memleaks. */
static bool RageSurface_Save_PNG( RageFile &f, char szErrorbuf[1024], RageSurface *pImgIn )
{
	bool bAlpha = pImgIn->format->Amask != 0;
	RageSurface *pImg;
	bool bDeleteImg = RageSurfaceUtils::ConvertSurface( pImgIn, pImg, pImgIn->w, pImgIn->h, 32,
			Swap32BE( 0xFF000000 ),
			Swap32BE( 0x00FF0000 ),
			Swap32BE( 0x0000FF00 ),
			Swap32BE( 0x000000FF ) );
	if( !bDeleteImg )
		pImg = pImgIn;

	error_info error;
	error.szErr = szErrorbuf;

	png_struct *pPng = png_create_write_struct( PNG_LIBPNG_VER_STRING, &error, PNG_Error, PNG_Warning );
	if( pPng == NULL )
	{
		sprintf( szErrorbuf, "creating png_create_write_struct failed");
		return false;
	}

	png_info *pInfo = png_create_info_struct(pPng);
	if( pInfo == NULL )
	{
		png_destroy_read_struct( &pPng, NULL, NULL );
		if( bDeleteImg )
			delete pImg;
		sprintf( szErrorbuf, "creating png_create_info_struct failed");
		return false;
	}

	if( setjmp(png_jmpbuf(pPng)) )
	{
		png_destroy_read_struct( &pPng, &pInfo, NULL );
		return false;
	}

	png_set_write_fn( pPng, &f, RageFile_png_write, RageFile_png_flush );
	png_set_compression_level( pPng, 1 );

	png_set_IHDR( pPng, pInfo, pImg->w, pImg->h, 8, bAlpha? PNG_COLOR_TYPE_RGBA:PNG_COLOR_TYPE_RGB,
		PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE );

	png_write_info( pPng, pInfo );
	png_set_filler( pPng, 0, PNG_FILLER_AFTER );

	png_byte *pixels = (png_byte *) pImg->pixels;
	for( int y = 0; y < pImg->h; y++ )
		png_write_row( pPng, pixels + pImg->pitch*y );

	png_write_end( pPng, pInfo );
	png_destroy_write_struct( &pPng, &pInfo );

	/* Free the converted image. */
	if( bDeleteImg )
		delete pImg;

	return true;
}
开发者ID:Ancaro,项目名称:stepmania,代码行数:62,代码来源:RageSurface_Save_PNG.cpp


示例13: rwpng_write_image_row

int rwpng_write_image_row(mainprog_info *mainprog_ptr)
{
    png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr;
    png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr;


    /* as always, setjmp() must be called in every function that calls a
     * PNG-writing libpng function */

    if (setjmp(mainprog_ptr->jmpbuf)) {
        png_destroy_write_struct(&png_ptr, &info_ptr);
        mainprog_ptr->png_ptr = NULL;
        mainprog_ptr->info_ptr = NULL;
        mainprog_ptr->retval = 55;   /* libpng error (via longjmp()) */
        return mainprog_ptr->retval;
    }


    /* indexed_data points at our one row of indexed data */

    png_write_row(png_ptr, mainprog_ptr->indexed_data);

    mainprog_ptr->retval = 0;
    return 0;
}
开发者ID:znerd,项目名称:improved-pngquant,代码行数:25,代码来源:rwpng.c


示例14: write_rgb_alpha_to_rgb_alpha

static void write_rgb_alpha_to_rgb_alpha (png_struct *png, png_byte *data, SLindex_Type num_cols, png_byte *tmpbuf)
{
   unsigned char *data_max;
   unsigned char *p;

   if (Is_Little_Endian)
     {
	byte_swap32 ((unsigned char *) data, (unsigned char *) tmpbuf, num_cols);
	data = tmpbuf;
     }
   data_max = data + 4 * num_cols;
   p = tmpbuf;
   /* Change ARGBARGB... to RGBARGBA... */
   while (data < data_max)
     {
	unsigned char a = data[0];
	p[0] = data[1];
	p[1] = data[2];
	p[2] = data[3];
	p[3] = a;
	data += 4;
	p += 4;
     }
   png_write_row (png, tmpbuf);
}
开发者ID:Distrotech,项目名称:slang,代码行数:25,代码来源:png-module.c


示例15: encodePNGAndAppendToBuffer

    bool encodePNGAndAppendToBuffer(unsigned char *pixmap, int width, int height, std::vector<char>& output)
    {
        png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);

        png_infop info_ptr = png_create_info_struct(png_ptr);

        if (setjmp(png_jmpbuf(png_ptr)))
        {
            png_destroy_write_struct(&png_ptr, NULL);
            return false;
        }

        png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);

        png_set_write_fn(png_ptr, &output, user_write_fn, user_flush_fn);
        png_set_write_status_fn(png_ptr, user_write_status_fn);

        png_write_info(png_ptr, info_ptr);

        for (int y = 0; y < height; ++y)
            png_write_row(png_ptr, pixmap + y * width * 4);

        png_write_end(png_ptr, info_ptr);

        png_destroy_write_struct(&png_ptr, NULL);

        return true;
    }
开发者ID:DanScharon,项目名称:online,代码行数:28,代码来源:Util.cpp


示例16: WritePNG

static int WritePNG(FILE* file, uint8_t* buffer, int width, int height)
{
    size_t pitch = width * 4;
    png_structp png_ptr;
    png_infop info_ptr;

    if (!(png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL))) goto png_error;
    if (!(info_ptr = png_create_info_struct(png_ptr))) goto info_error;

    if (setjmp(png_jmpbuf(png_ptr)))
    {
        png_destroy_write_struct(&png_ptr, &info_ptr);
        goto png_error;
    }

    png_init_io(png_ptr, file);
    png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
    png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
    png_write_info(png_ptr, info_ptr);

    for (int r = height * pitch - pitch; r >= 0; r -= pitch)
        png_write_row(png_ptr, buffer + r);

    png_write_end(png_ptr, info_ptr);
    png_destroy_write_struct(&png_ptr, &info_ptr);

    return 1;
info_error:
    png_destroy_write_struct(&png_ptr, NULL);
png_error:
    return 0;
}
开发者ID:rossy,项目名称:clearshot,代码行数:32,代码来源:clearshot.c


示例17: png_write_image

/* Write the image.  You only need to call this function once, even
 * if you are writing an interlaced image.
 */
void
png_write_image(png_structp png_ptr, png_bytepp image)
{
   png_uint_32 i; /* row index */
   int pass, num_pass; /* pass variables */
   png_bytepp rp; /* points to current row */

   png_debug(1, "in png_write_image\n");
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
   /* intialize interlace handling.  If image is not interlaced,
      this will set pass to 1 */
   num_pass = png_set_interlace_handling(png_ptr);
#else
   num_pass = 1;
#endif
   /* loop through passes */
   for (pass = 0; pass < num_pass; pass++)
   {
      /* loop through image */
      for (i = 0, rp = image; i < png_ptr->height; i++, rp++)
      {
         png_write_row(png_ptr, *rp);
      }
   }
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:28,代码来源:pngwrite.c


示例18: save_hicolour

/* save_hicolour:
 *  Core save routine for 15/16 bpp images, by Martijn Versteegh.
 */
static int save_hicolour(png_structp png_ptr, BITMAP *bmp, int depth)
{
    unsigned char *row, *p;
    int i, j, c;

    row = malloc(bmp->w * 3);
    if (!row)
	return 0;

    for (i=0; i<bmp->h; i++) {
	p = row;
        for (j = 0; j < bmp->w; j++) {
            c = getpixel(bmp, j, i);
            if (depth == 15) {
		*p++ = getr15(c);
		*p++ = getg15(c);
		*p++ = getb15(c);
            }
	    else {
		*p++ = getr16(c);
		*p++ = getg16(c);
		*p++ = getb16(c);
            }
        }

        png_write_row(png_ptr, row);
    }

    free(row);

    return 1;
}
开发者ID:dafyddcrosby,项目名称:meka,代码行数:35,代码来源:savepng.c


示例19: crop_image

static void crop_image(img_t *img, int base_offset, FILE *out) {

    int i, u, v;
    int ret, idx;
    int nr = img->sizeX / TILE_SIZE;
    png_bytep png_row_ptr;
    png_t png;
    png.fp = out;

    for (v = 0; v < nr; v++) {
        for (u = 0; u < nr; u++) {

            // update offset_map for zoom levels > 13
            if (base_offset < 5) {
                idx = u + v*nr;
                offset_map[idx + offsets[base_offset]] = (int) ftell(out);
            }

            ret = open_png_writer(&png, TILE_SIZE/(img->sizeX/img->sizeY));

            for (i = 0; i < img->sizeY/nr; i++) {
                png_row_ptr = (png_bytep) &img->raw_data[u*TILE_SIZE+v*(img->sizeY/nr)*img->sizeX+i*img->sizeX];
                png_write_row(png.png_ptr, png_row_ptr);
            }
            close_png_writer(&png);
        }
    }
}
开发者ID:kyroskoh,项目名称:png_tilegen,代码行数:28,代码来源:packed_tilegen.c


示例20: encodePixels

static bool encodePixels(IntSize imageSize, const unsigned char* inputPixels, bool premultiplied, Vector<unsigned char>* output)
{
    if (imageSize.width() <= 0 || imageSize.height() <= 0)
        return false;

    Vector<unsigned char> row;

    png_struct* png = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
    png_info* info = png_create_info_struct(png);
    if (!png || !info || setjmp(png_jmpbuf(png))) {
        png_destroy_write_struct(png ? &png : 0, info ? &info : 0);
        return false;
    }

    // Optimize compression for speed.
    // The parameters are the same as what libpng uses by default for RGB and RGBA images, except:
    // - the zlib compression level is 3 instead of 6, to avoid the lazy Ziv-Lempel match searching;
    // - the delta filter is 1 ("sub") instead of 5 ("all"), to reduce the filter computations.
    // The zlib memory level (8) and strategy (Z_FILTERED) will be set inside libpng.
    //
    // Avoid the zlib strategies Z_HUFFMAN_ONLY or Z_RLE.
    // Although they are the fastest for poorly-compressible images (e.g. photographs),
    // they are very slow for highly-compressible images (e.g. text, drawings or business graphics).
    png_set_compression_level(png, 3);
    png_set_filter(png, PNG_FILTER_TYPE_BASE, PNG_FILTER_SUB);

    png_set_write_fn(png, output, writeOutput, 0);
    png_set_IHDR(png, info, imageSize.width(), imageSize.height(),
                 8, PNG_COLOR_TYPE_RGB_ALPHA, 0, 0, 0);
    png_write_info(png, info);

    unsigned char* pixels = const_cast<unsigned char*>(inputPixels);
    row.resize(imageSize.width() * sizeof(SkPMColor));
    const size_t pixelRowStride = imageSize.width() * 4;
    for (int y = 0; y < imageSize.height(); ++y) {
        if (premultiplied) {
            preMultipliedBGRAtoRGBA(pixels, imageSize.width(), row.data());
            png_write_row(png, row.data());
        } else
            png_write_row(png, pixels);
        pixels += pixelRowStride;
    }

    png_write_end(png, info);
    png_destroy_write_struct(&png, &info);
    return true;
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:47,代码来源:PNGImageEncoder.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pnorm函数代码示例发布时间:2022-05-30
下一篇:
C++ png_write_png函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap