|
|
@ -30,6 +30,7 @@ init_closure_destination(j_compress_ptr cinfo){ |
|
|
|
|
|
|
|
boolean |
|
|
|
empty_closure_output_buffer(j_compress_ptr cinfo){ |
|
|
|
NanScope(); |
|
|
|
closure_destination_mgr *dest = (closure_destination_mgr *) cinfo->dest; |
|
|
|
Local<Object> buf = NanNewBufferHandle((char *)dest->buffer, dest->bufsize); |
|
|
|
Local<Value> argv[3] = { |
|
|
@ -45,6 +46,7 @@ empty_closure_output_buffer(j_compress_ptr cinfo){ |
|
|
|
|
|
|
|
void |
|
|
|
term_closure_destination(j_compress_ptr cinfo){ |
|
|
|
NanScope(); |
|
|
|
closure_destination_mgr *dest = (closure_destination_mgr *) cinfo->dest; |
|
|
|
/* emit remaining data */ |
|
|
|
size_t remaining = dest->bufsize - cinfo->dest->free_in_buffer; |
|
|
@ -95,6 +97,16 @@ jpeg_closure_dest(j_compress_ptr cinfo, closure_t * closure, int bufsize){ |
|
|
|
cinfo->dest->free_in_buffer = dest->bufsize; |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
|
jpeg_free_custom_allocations(j_compress_ptr cinfo){ |
|
|
|
closure_destination_mgr * dest; |
|
|
|
dest = (closure_destination_mgr *) cinfo->dest; |
|
|
|
if (dest->buffer) { |
|
|
|
free(dest->buffer); |
|
|
|
dest->buffer = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
|
write_to_jpeg_stream(cairo_surface_t *surface, int bufsize, int quality, bool progressive, closure_t *closure){ |
|
|
|
int w = cairo_image_surface_get_width(surface); |
|
|
@ -137,6 +149,7 @@ write_to_jpeg_stream(cairo_surface_t *surface, int bufsize, int quality, bool pr |
|
|
|
} |
|
|
|
free(dst); |
|
|
|
jpeg_finish_compress(&cinfo); |
|
|
|
jpeg_free_custom_allocations(&cinfo); |
|
|
|
jpeg_destroy_compress(&cinfo); |
|
|
|
} |
|
|
|
|
|
|
|