Ejemplo n.º 1
0
static VALUE
png_buf_internal(VALUE obj, VALUE compression, VALUE interlace)
{
#if IM_MAJOR_VERSION > 7 || IM_MINOR_VERSION >= 23
    VipsImage *im_out;
    char *buf;
    int length;
    GetImg(obj, data, im);

    if (!(im_out = im_open("writer_png_buf", "p")))
        vips_lib_error();

    if (im_vips2bufpng(im, im_out, NUM2INT(compression), NUM2INT(interlace),
        &buf, &length)) {
		im_close(im_out);
        vips_lib_error();
	}

    im_close(im_out);

    return rb_tainted_str_new(buf, length);
#else
    rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
#endif
}
Ejemplo n.º 2
0
static VALUE
png_buf_internal(VALUE obj, VALUE compression, VALUE interlace)
{
#if IM_MAJOR_VERSION > 7 || IM_MINOR_VERSION >= 23
    char *buf;
    size_t length;
    GetImg(obj, data, im);

    if (im_vips2bufpng(im, NULL, NUM2INT(compression), NUM2INT(interlace),
        &buf, &length)) 
        vips_lib_error();

    return rb_tainted_str_new(buf, length);
#else
    rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
#endif
}
Ejemplo n.º 3
0
static VALUE
png_buf_internal(VALUE obj, VALUE compression, VALUE interlace)
{
    char *buf;
    size_t length;
    GetImg(obj, data, im);

#if ATLEAST_VIPS( 7, 28 )
    if (vips_pngsave_buffer(im, &buf, &length,
        "compression", NUM2INT(compression),
	"interlace", NUM2INT(interlace),
	NULL))
        vips_lib_error();
#elif ATLEAST_VIPS( 7, 23 )
    if (im_vips2bufpng(im, NULL, NUM2INT(compression), NUM2INT(interlace),
        &buf, &length)) 
        vips_lib_error();
#else
    rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
#endif

    return rb_tainted_str_new(buf, length);
}