summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-image.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-11-11 16:05:30 +0000
committerRobin Watts <robin.watts@artifex.com>2016-11-14 16:09:39 +0000
commit37f95f87bdfb2e0b01d649afae5fffe60bf99d3a (patch)
treeda3491c62d6af86c1a5bc4e523e8f9ebe19793d1 /source/pdf/pdf-image.c
parentc0e1dfdab1a13def046e94d771f8a821ba2a10d9 (diff)
downloadmupdf-37f95f87bdfb2e0b01d649afae5fffe60bf99d3a.tar.xz
Make fz_buffer structure private to fitz.
Move the definition of the structure contents into new fitz-imp.h file. Make all code outside of fitz access the buffer through the defined API. Add a convenience API for people that want to get buffers as null terminated C strings.
Diffstat (limited to 'source/pdf/pdf-image.c')
-rw-r--r--source/pdf/pdf-image.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/source/pdf/pdf-image.c b/source/pdf/pdf-image.c
index 37e2ca50..b669948b 100644
--- a/source/pdf/pdf-image.c
+++ b/source/pdf/pdf-image.c
@@ -226,6 +226,9 @@ pdf_load_jpx(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int forcemask)
/* FIXME: We can't handle decode arrays for indexed images currently */
fz_try(ctx)
{
+ unsigned char *data;
+ size_t len;
+
obj = pdf_dict_get(ctx, dict, PDF_NAME_ColorSpace);
if (obj)
{
@@ -233,7 +236,8 @@ pdf_load_jpx(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int forcemask)
indexed = fz_colorspace_is_indexed(ctx, colorspace);
}
- pix = fz_load_jpx(ctx, buf->data, buf->len, colorspace, indexed);
+ len = fz_buffer_storage(ctx, buf, &data);
+ pix = fz_load_jpx(ctx, data, len, colorspace, indexed);
obj = pdf_dict_geta(ctx, dict, PDF_NAME_SMask, PDF_NAME_Mask);
if (pdf_is_dict(ctx, obj))
@@ -392,9 +396,8 @@ raw_or_unknown_compression:
s = pixmap->samples;
h = image->h;
size = image->w * n;
- buffer = fz_new_buffer(ctx, size * h);
- buffer->len = size * h;
- d = buffer->data;
+ d = fz_malloc(ctx, size * h);
+ buffer = fz_new_buffer_from_data(ctx, d, size * h);
if (pixmap->alpha == 0 || n == 1)
{
while (h--)