Module: Axon::JPEGNativeWriter
- Included in:
- JPEGWriter
- Defined in:
- ext/axon/jpeg_native_writer.c
Instance Method Summary collapse
-
#write ⇒ nil
Compress image and write the jpeg.
Instance Method Details
#write ⇒ nil
Compress image and write the jpeg.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'ext/axon/jpeg_native_writer.c', line 190
static VALUE
jpeg_native_write(VALUE self)
{
struct jpeg_compress_struct cinfo;
struct buf_dest_mgr mgr;
VALUE io, rb_bufsize, ensure_args[2];
int bufsize;
io = rb_funcall(self, id_io, 0);
rb_bufsize = rb_funcall(self, id_bufsize, 0);
bufsize = FIX2INT(rb_bufsize);
if (bufsize < 1)
rb_raise(rb_eRuntimeError, "Buffer size must be greater than zero");
cinfo.err = &jerr;
jpeg_create_compress(&cinfo);
mgr.pub.init_destination = init_destination;
mgr.pub.empty_output_buffer = empty_output_buffer;
mgr.pub.term_destination = term_destination;
mgr.alloc = bufsize;
mgr.io = io;
cinfo.dest = (struct jpeg_destination_mgr *)&mgr;
ensure_args[0] = self;
ensure_args[1] = (VALUE)&cinfo;
return rb_ensure(write2, (VALUE)ensure_args, write2_ensure,
(VALUE)ensure_args);
}
|