Module: Axon::PNGNativeWriter
- Included in:
- PNGWriter
- Defined in:
- ext/axon/png_native_writer.c
Instance Method Summary collapse
-
#write(io) ⇒ nil
Compress image and write the png to io.
Instance Method Details
#write(io) ⇒ nil
Compress image and write the png to io.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'ext/axon/png_native_writer.c', line 118
static VALUE
pngwrite(VALUE self, VALUE io)
{
VALUE ensure_args[3];
png_structp png_ptr;
png_infop info_ptr;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
(png_error_ptr)png_error_fn,
(png_error_ptr)png_warning_fn);
if (png_ptr == NULL)
rb_raise(rb_eRuntimeError, "unable to allocate a png object");
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
png_destroy_write_struct(&png_ptr, png_infopp_NULL);
rb_raise(rb_eRuntimeError, "unable to allocate a png info object");
}
png_set_write_fn(png_ptr, (void *)io, write_data, flush_data);
ensure_args[0] = self;
ensure_args[1] = (VALUE)png_ptr;
ensure_args[2] = (VALUE)info_ptr;
return rb_ensure(write2, (VALUE)ensure_args, write2_ensure,
(VALUE)ensure_args);
}
|