forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hpdf_image.c
664 lines (511 loc) · 18.5 KB
/
hpdf_image.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
/*
* << Haru Free PDF Library >> -- hpdf_image.c
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#include "hpdf_conf.h"
#include "hpdf_utils.h"
#include "hpdf.h"
static const char *COL_CMYK = "DeviceCMYK";
static const char *COL_RGB = "DeviceRGB";
static const char *COL_GRAY = "DeviceGray";
static HPDF_STATUS
LoadJpegHeader (HPDF_Image image,
HPDF_Stream stream);
/*---------------------------------------------------------------------------*/
static HPDF_STATUS
LoadJpegHeader (HPDF_Image image,
HPDF_Stream stream)
{
HPDF_UINT16 tag;
HPDF_UINT16 height;
HPDF_UINT16 width;
HPDF_BYTE precision;
HPDF_BYTE num_components;
const char *color_space_name;
HPDF_UINT len;
HPDF_STATUS ret;
HPDF_Array array;
HPDF_PTRACE ((" HPDF_Image_LoadJpegHeader\n"));
len = 2;
if (HPDF_Stream_Read (stream, (HPDF_BYTE *)&tag, &len) != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
HPDF_UInt16Swap (&tag);
if (tag != 0xFFD8)
return HPDF_INVALID_JPEG_DATA;
/* find SOF record */
for (;;) {
HPDF_UINT16 size;
len = 2;
if (HPDF_Stream_Read (stream, (HPDF_BYTE *)&tag, &len) != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
HPDF_UInt16Swap (&tag);
len = 2;
if (HPDF_Stream_Read (stream, (HPDF_BYTE *)&size, &len) != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
HPDF_UInt16Swap (&size);
HPDF_PTRACE (("tag=%04X size=%u\n", tag, size));
if (tag == 0xFFC0 || tag == 0xFFC1 ||
tag == 0xFFC2 || tag == 0xFFC9) {
len = 1;
if (HPDF_Stream_Read (stream, (HPDF_BYTE *)&precision, &len) !=
HPDF_OK)
return HPDF_Error_GetCode (stream->error);
len = 2;
if (HPDF_Stream_Read (stream, (HPDF_BYTE *)&height, &len) !=
HPDF_OK)
return HPDF_Error_GetCode (stream->error);
HPDF_UInt16Swap (&height);
len = 2;
if (HPDF_Stream_Read (stream, (HPDF_BYTE *)&width, &len) != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
HPDF_UInt16Swap (&width);
len = 1;
if (HPDF_Stream_Read (stream, (HPDF_BYTE *)&num_components, &len) !=
HPDF_OK)
return HPDF_Error_GetCode (stream->error);
break;
} else if ((tag | 0x00FF) != 0xFFFF)
/* lost marker */
return HPDF_SetError (image->error, HPDF_UNSUPPORTED_JPEG_FORMAT,
0);
if (HPDF_Stream_Seek (stream, size - 2, HPDF_SEEK_CUR) != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
}
if (HPDF_Dict_AddNumber (image, "Height", height) != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
if (HPDF_Dict_AddNumber (image, "Width", width) != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
/* classification of RGB and CMYK is less than perfect
* YCbCr and YCCK are classified into RGB or CMYK.
*
* It is necessary to read APP14 data to distinguish colorspace perfectly.
*/
switch (num_components) {
case 1:
color_space_name = COL_GRAY;
break;
case 3:
color_space_name = COL_RGB;
break;
case 4:
array = HPDF_Array_New (image->mmgr);
if (!array)
return HPDF_Error_GetCode (stream->error);
ret = HPDF_Dict_Add (image, "Decode", array);
if (ret != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
ret += HPDF_Array_Add (array, HPDF_Number_New (image->mmgr, 1));
ret += HPDF_Array_Add (array, HPDF_Number_New (image->mmgr, 0));
ret += HPDF_Array_Add (array, HPDF_Number_New (image->mmgr, 1));
ret += HPDF_Array_Add (array, HPDF_Number_New (image->mmgr, 0));
ret += HPDF_Array_Add (array, HPDF_Number_New (image->mmgr, 1));
ret += HPDF_Array_Add (array, HPDF_Number_New (image->mmgr, 0));
ret += HPDF_Array_Add (array, HPDF_Number_New (image->mmgr, 1));
ret += HPDF_Array_Add (array, HPDF_Number_New (image->mmgr, 0));
if (ret != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
color_space_name = COL_CMYK;
break;
default:
return HPDF_SetError (image->error, HPDF_UNSUPPORTED_JPEG_FORMAT,
0);
}
if (HPDF_Dict_Add (image, "ColorSpace",
HPDF_Name_New (image->mmgr, color_space_name)) != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
if (HPDF_Dict_Add (image, "BitsPerComponent",
HPDF_Number_New (image->mmgr, precision)) != HPDF_OK)
return HPDF_Error_GetCode (stream->error);
return HPDF_OK;
}
HPDF_Image
HPDF_Image_LoadJpegImage (HPDF_MMgr mmgr,
HPDF_Stream jpeg_data,
HPDF_Xref xref)
{
HPDF_Dict image;
HPDF_STATUS ret = HPDF_OK;
HPDF_PTRACE ((" HPDF_Image_LoadJpegImage\n"));
image = HPDF_DictStream_New (mmgr, xref);
if (!image)
return NULL;
image->header.obj_class |= HPDF_OSUBCLASS_XOBJECT;
/* add requiered elements */
image->filter = HPDF_STREAM_FILTER_DCT_DECODE;
ret += HPDF_Dict_AddName (image, "Type", "XObject");
ret += HPDF_Dict_AddName (image, "Subtype", "Image");
if (ret != HPDF_OK)
return NULL;
if (LoadJpegHeader (image, jpeg_data) != HPDF_OK)
return NULL;
if (HPDF_Stream_Seek (jpeg_data, 0, HPDF_SEEK_SET) != HPDF_OK)
return NULL;
for (;;) {
HPDF_BYTE buf[HPDF_STREAM_BUF_SIZ];
HPDF_UINT len = HPDF_STREAM_BUF_SIZ;
HPDF_STATUS ret = HPDF_Stream_Read (jpeg_data, buf,
&len);
if (ret != HPDF_OK) {
if (ret == HPDF_STREAM_EOF) {
if (len > 0) {
ret = HPDF_Stream_Write (image->stream, buf, len);
if (ret != HPDF_OK)
return NULL;
}
break;
} else
return NULL;
}
if (HPDF_Stream_Write (image->stream, buf, len) != HPDF_OK)
return NULL;
}
return image;
}
HPDF_Image
HPDF_Image_LoadJpegImageFromMem (HPDF_MMgr mmgr,
const HPDF_BYTE *buf,
HPDF_UINT size,
HPDF_Xref xref)
{
HPDF_Stream jpeg_data;
HPDF_Image image;
HPDF_PTRACE ((" HPDF_Image_LoadJpegImageFromMem\n"));
jpeg_data = HPDF_MemStream_New(mmgr,size);
if (!HPDF_Stream_Validate (jpeg_data)) {
HPDF_RaiseError (mmgr->error, HPDF_INVALID_STREAM, 0);
return NULL;
}
if (HPDF_Stream_Write (jpeg_data, buf, size) != HPDF_OK) {
HPDF_Stream_Free (jpeg_data);
return NULL;
}
image = HPDF_Image_LoadJpegImage(mmgr,jpeg_data,xref);
/* destroy file stream */
HPDF_Stream_Free (jpeg_data);
return image;
}
HPDF_Image
HPDF_Image_LoadRawImage (HPDF_MMgr mmgr,
HPDF_Stream raw_data,
HPDF_Xref xref,
HPDF_UINT width,
HPDF_UINT height,
HPDF_ColorSpace color_space)
{
HPDF_Dict image;
HPDF_STATUS ret = HPDF_OK;
HPDF_UINT size;
HPDF_PTRACE ((" HPDF_Image_LoadRawImage\n"));
if (color_space != HPDF_CS_DEVICE_GRAY &&
color_space != HPDF_CS_DEVICE_RGB &&
color_space != HPDF_CS_DEVICE_CMYK) {
HPDF_SetError (mmgr->error, HPDF_INVALID_COLOR_SPACE, 0);
return NULL;
}
image = HPDF_DictStream_New (mmgr, xref);
if (!image)
return NULL;
image->header.obj_class |= HPDF_OSUBCLASS_XOBJECT;
ret += HPDF_Dict_AddName (image, "Type", "XObject");
ret += HPDF_Dict_AddName (image, "Subtype", "Image");
if (ret != HPDF_OK)
return NULL;
if (color_space == HPDF_CS_DEVICE_GRAY) {
size = width * height;
ret = HPDF_Dict_AddName (image, "ColorSpace", COL_GRAY);
} else if (color_space == HPDF_CS_DEVICE_CMYK) {
size = width * height * 4;
ret = HPDF_Dict_AddName (image, "ColorSpace", COL_CMYK);
} else {
size = width * height * 3;
ret = HPDF_Dict_AddName (image, "ColorSpace", COL_RGB);
}
if (ret != HPDF_OK)
return NULL;
if (HPDF_Dict_AddNumber (image, "Width", width) != HPDF_OK)
return NULL;
if (HPDF_Dict_AddNumber (image, "Height", height) != HPDF_OK)
return NULL;
if (HPDF_Dict_AddNumber (image, "BitsPerComponent", 8) != HPDF_OK)
return NULL;
if (HPDF_Stream_WriteToStream (raw_data, image->stream, 0, NULL) != HPDF_OK)
return NULL;
if (image->stream->size != size) {
HPDF_SetError (image->error, HPDF_INVALID_IMAGE, 0);
return NULL;
}
return image;
}
HPDF_Image
HPDF_Image_LoadRawImageFromMem (HPDF_MMgr mmgr,
const HPDF_BYTE *buf,
HPDF_Xref xref,
HPDF_UINT width,
HPDF_UINT height,
HPDF_ColorSpace color_space,
HPDF_UINT bits_per_component)
{
HPDF_Dict image;
HPDF_STATUS ret = HPDF_OK;
HPDF_UINT size=0;
HPDF_PTRACE ((" HPDF_Image_LoadRawImageFromMem\n"));
if (color_space != HPDF_CS_DEVICE_GRAY &&
color_space != HPDF_CS_DEVICE_RGB &&
color_space != HPDF_CS_DEVICE_CMYK) {
HPDF_SetError (mmgr->error, HPDF_INVALID_COLOR_SPACE, 0);
return NULL;
}
if (bits_per_component != 1 && bits_per_component != 2 &&
bits_per_component != 4 && bits_per_component != 8) {
HPDF_SetError (mmgr->error, HPDF_INVALID_IMAGE, 0);
return NULL;
}
image = HPDF_DictStream_New (mmgr, xref);
if (!image)
return NULL;
image->header.obj_class |= HPDF_OSUBCLASS_XOBJECT;
ret += HPDF_Dict_AddName (image, "Type", "XObject");
ret += HPDF_Dict_AddName (image, "Subtype", "Image");
if (ret != HPDF_OK)
return NULL;
switch (color_space) {
case HPDF_CS_DEVICE_GRAY:
size = (HPDF_UINT)((HPDF_DOUBLE)width * height / (8 / bits_per_component) + 0.876);
ret = HPDF_Dict_AddName (image, "ColorSpace", COL_GRAY);
break;
case HPDF_CS_DEVICE_RGB:
size = (HPDF_UINT)((HPDF_DOUBLE)width * height / (8 / bits_per_component) + 0.876);
size *= 3;
ret = HPDF_Dict_AddName (image, "ColorSpace", COL_RGB);
break;
case HPDF_CS_DEVICE_CMYK:
size = (HPDF_UINT)((HPDF_DOUBLE)width * height / (8 / bits_per_component) + 0.876);
size *= 4;
ret = HPDF_Dict_AddName (image, "ColorSpace", COL_CMYK);
break;
default:;
}
if (ret != HPDF_OK)
return NULL;
if (HPDF_Dict_AddNumber (image, "Width", width) != HPDF_OK)
return NULL;
if (HPDF_Dict_AddNumber (image, "Height", height) != HPDF_OK)
return NULL;
if (HPDF_Dict_AddNumber (image, "BitsPerComponent", bits_per_component)
!= HPDF_OK)
return NULL;
if (HPDF_Stream_Write (image->stream, buf, size) != HPDF_OK)
return NULL;
return image;
}
HPDF_BOOL
HPDF_Image_Validate (HPDF_Image image)
{
HPDF_Name subtype;
HPDF_PTRACE ((" HPDF_Image_Validate\n"));
if (!image)
return HPDF_FALSE;
if (image->header.obj_class != (HPDF_OSUBCLASS_XOBJECT |
HPDF_OCLASS_DICT)) {
HPDF_RaiseError (image->error, HPDF_INVALID_IMAGE, 0);
return HPDF_FALSE;
}
subtype = HPDF_Dict_GetItem (image, "Subtype", HPDF_OCLASS_NAME);
if (!subtype || HPDF_StrCmp (subtype->value, "Image") != 0) {
HPDF_RaiseError (image->error, HPDF_INVALID_IMAGE, 0);
return HPDF_FALSE;
}
return HPDF_TRUE;
}
HPDF_EXPORT(HPDF_Point)
HPDF_Image_GetSize (HPDF_Image image)
{
HPDF_Number width;
HPDF_Number height;
HPDF_Point ret = {0, 0};
HPDF_PTRACE ((" HPDF_Image_GetSize\n"));
if (!HPDF_Image_Validate (image))
return ret;
width = HPDF_Dict_GetItem (image, "Width", HPDF_OCLASS_NUMBER);
height = HPDF_Dict_GetItem (image, "Height", HPDF_OCLASS_NUMBER);
if (width && height) {
ret.x = (HPDF_REAL)width->value;
ret.y = (HPDF_REAL)height->value;
}
return ret;
}
HPDF_EXPORT(HPDF_STATUS)
HPDF_Image_GetSize2 (HPDF_Image image, HPDF_Point *size)
{
HPDF_Number width;
HPDF_Number height;
size->x = 0;
size->y = 0;
HPDF_PTRACE ((" HPDF_Image_GetSize\n"));
if (!HPDF_Image_Validate (image))
return HPDF_INVALID_IMAGE;
width = HPDF_Dict_GetItem (image, "Width", HPDF_OCLASS_NUMBER);
height = HPDF_Dict_GetItem (image, "Height", HPDF_OCLASS_NUMBER);
if (width && height) {
size->x = (HPDF_REAL)width->value;
size->y = (HPDF_REAL)height->value;
}
return HPDF_OK;
}
HPDF_EXPORT(HPDF_UINT)
HPDF_Image_GetBitsPerComponent (HPDF_Image image)
{
HPDF_Number n;
HPDF_PTRACE ((" HPDF_Image_GetBitsPerComponent\n"));
if (!HPDF_Image_Validate (image))
return 0;
n = HPDF_Dict_GetItem (image, "BitsPerComponent", HPDF_OCLASS_NUMBER);
if (!n)
return 0;
return n->value;
}
HPDF_EXPORT(const char*)
HPDF_Image_GetColorSpace (HPDF_Image image)
{
HPDF_Name n;
HPDF_PTRACE ((" HPDF_Image_GetColorSpace\n"));
n = HPDF_Dict_GetItem (image, "ColorSpace", HPDF_OCLASS_NAME);
if (!n) {
HPDF_Array a;
HPDF_Error_Reset(image->error);
a = HPDF_Dict_GetItem (image, "ColorSpace", HPDF_OCLASS_ARRAY);
if (a) {
n = HPDF_Array_GetItem (a, 0, HPDF_OCLASS_NAME);
}
}
if (!n) {
HPDF_CheckError (image->error);
return NULL;
}
return n->value;
}
HPDF_EXPORT(HPDF_UINT)
HPDF_Image_GetWidth (HPDF_Image image)
{
return (HPDF_UINT)HPDF_Image_GetSize (image).x;
}
HPDF_EXPORT(HPDF_UINT)
HPDF_Image_GetHeight (HPDF_Image image)
{
return (HPDF_UINT)HPDF_Image_GetSize (image).y;
}
HPDF_STATUS
HPDF_Image_SetMask (HPDF_Image image,
HPDF_BOOL mask)
{
HPDF_Boolean image_mask;
if (!HPDF_Image_Validate (image))
return HPDF_INVALID_IMAGE;
if (mask && HPDF_Image_GetBitsPerComponent (image) != 1)
return HPDF_SetError (image->error, HPDF_INVALID_BIT_PER_COMPONENT,
0);
image_mask = HPDF_Dict_GetItem (image, "ImageMask", HPDF_OCLASS_BOOLEAN);
if (!image_mask) {
HPDF_STATUS ret;
image_mask = HPDF_Boolean_New (image->mmgr, HPDF_FALSE);
if ((ret = HPDF_Dict_Add (image, "ImageMask", image_mask)) != HPDF_OK)
return ret;
}
image_mask->value = mask;
return HPDF_OK;
}
HPDF_EXPORT(HPDF_STATUS)
HPDF_Image_SetMaskImage (HPDF_Image image,
HPDF_Image mask_image)
{
if (!HPDF_Image_Validate (image))
return HPDF_INVALID_IMAGE;
if (!HPDF_Image_Validate (mask_image))
return HPDF_INVALID_IMAGE;
if (HPDF_Image_SetMask (mask_image, HPDF_TRUE) != HPDF_OK)
return HPDF_CheckError (image->error);
return HPDF_Dict_Add (image, "Mask", mask_image);
}
HPDF_EXPORT(HPDF_STATUS)
HPDF_Image_SetColorMask (HPDF_Image image,
HPDF_UINT rmin,
HPDF_UINT rmax,
HPDF_UINT gmin,
HPDF_UINT gmax,
HPDF_UINT bmin,
HPDF_UINT bmax)
{
HPDF_Array array;
const char *name;
HPDF_STATUS ret = HPDF_OK;
if (!HPDF_Image_Validate (image))
return HPDF_INVALID_IMAGE;
if (HPDF_Dict_GetItem (image, "ImageMask", HPDF_OCLASS_BOOLEAN))
return HPDF_RaiseError (image->error, HPDF_INVALID_OPERATION, 0);
if (HPDF_Image_GetBitsPerComponent (image) != 8)
return HPDF_RaiseError (image->error, HPDF_INVALID_BIT_PER_COMPONENT,
0);
name = HPDF_Image_GetColorSpace (image);
if (!name || HPDF_StrCmp (COL_RGB, name) != 0)
return HPDF_RaiseError (image->error, HPDF_INVALID_COLOR_SPACE, 0);
/* Each integer must be in the range 0 to 2^BitsPerComponent - 1 */
if (rmax > 255 || gmax > 255 || bmax > 255)
return HPDF_RaiseError (image->error, HPDF_INVALID_PARAMETER, 0);
array = HPDF_Array_New (image->mmgr);
if (!array)
return HPDF_CheckError (image->error);
ret += HPDF_Dict_Add (image, "Mask", array);
ret += HPDF_Array_AddNumber (array, rmin);
ret += HPDF_Array_AddNumber (array, rmax);
ret += HPDF_Array_AddNumber (array, gmin);
ret += HPDF_Array_AddNumber (array, gmax);
ret += HPDF_Array_AddNumber (array, bmin);
ret += HPDF_Array_AddNumber (array, bmax);
if (ret != HPDF_OK)
return HPDF_CheckError (image->error);
return HPDF_OK;
}
HPDF_EXPORT(HPDF_STATUS)
HPDF_Image_AddSMask (HPDF_Image image,
HPDF_Image smask)
{
const char *name;
if (!HPDF_Image_Validate (image))
return HPDF_INVALID_IMAGE;
if (!HPDF_Image_Validate (smask))
return HPDF_INVALID_IMAGE;
if (HPDF_Dict_GetItem (image, "SMask", HPDF_OCLASS_BOOLEAN))
return HPDF_RaiseError (image->error, HPDF_INVALID_OPERATION, 0);
name = HPDF_Image_GetColorSpace (smask);
if (!name || HPDF_StrCmp (COL_GRAY, name) != 0)
return HPDF_RaiseError (smask->error, HPDF_INVALID_COLOR_SPACE, 0);
return HPDF_Dict_Add (image, "SMask", smask);
}
HPDF_STATUS
HPDF_Image_SetColorSpace (HPDF_Image image,
HPDF_Array colorspace)
{
if (!HPDF_Image_Validate (image))
return HPDF_INVALID_IMAGE;
return HPDF_Dict_Add (image, "ColorSpace", colorspace);
}
HPDF_STATUS
HPDF_Image_SetRenderingIntent (HPDF_Image image,
const char* intent)
{
if (!HPDF_Image_Validate (image))
return HPDF_INVALID_IMAGE;
return HPDF_Dict_AddName (image, "Intent", intent);
}