diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-05 16:38:34 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-05 18:13:09 +0000 |
commit | e40d62a0fe96b8b937017a3bc2f18766c411ec41 (patch) | |
tree | a00ea404aaf2f1ec3b97f01bf968c3085a8d0007 /src/cairo-output-stream.c | |
parent | 89616dee8f11c6a7de3fa476b13661420648786f (diff) |
[png] Attach the png representation to cairo_surface_create_from_png().
Attach the original png data as an alternate representation for image
surfaces created by cairo_surface_create_from_png().
Diffstat (limited to 'src/cairo-output-stream.c')
-rw-r--r-- | src/cairo-output-stream.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c index bae6ac4fe..c31c2da53 100644 --- a/src/cairo-output-stream.c +++ b/src/cairo-output-stream.c @@ -656,6 +656,32 @@ _cairo_memory_stream_create (void) return &stream->base; } +cairo_status_t +_cairo_memory_stream_destroy (cairo_output_stream_t *abstract_stream, + unsigned char **data_out, + unsigned int *length_out) +{ + memory_stream_t *stream; + cairo_status_t status; + + status = abstract_stream->status; + if (status) + return _cairo_output_stream_destroy (abstract_stream); + + stream = (memory_stream_t *) abstract_stream; + + *length_out = _cairo_array_num_elements (&stream->array); + *data_out = malloc (*length_out); + if (*data_out == NULL) { + status = _cairo_output_stream_destroy (abstract_stream); + assert (status == CAIRO_STATUS_SUCCESS); + return _cairo_error (CAIRO_STATUS_NO_MEMORY); + } + memcpy (*data_out, _cairo_array_index (&stream->array, 0), *length_out); + + return _cairo_output_stream_destroy (abstract_stream); +} + void _cairo_memory_stream_copy (cairo_output_stream_t *base, cairo_output_stream_t *dest) @@ -670,7 +696,7 @@ _cairo_memory_stream_copy (cairo_output_stream_t *base, return; } - _cairo_output_stream_write (dest, + _cairo_output_stream_write (dest, _cairo_array_index (&stream->array, 0), _cairo_array_num_elements (&stream->array)); } |