tioga 1.17 → 1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Tioga_README +14 -3
- data/ext/Dobjects/Dvector/dvector.c +123 -28
- data/ext/Tioga/FigureMaker/__shared_axes.c +6 -2
- data/ext/Tioga/FigureMaker/__shared_pdfimage.c +256 -66
- data/ext/Tioga/FigureMaker/figures.c +12 -7
- data/ext/Tioga/FigureMaker/figures.h +18 -1
- data/ext/Tioga/FigureMaker/pdfs.h +8 -0
- data/ext/Tioga/FigureMaker/shared/axes.c +6 -2
- data/ext/Tioga/FigureMaker/shared/pdfimage.c +256 -66
- data/ext/Tioga/FigureMaker/wrappers.c +67 -41
- data/ext/Tioga/FigureMaker/wrappers.h +22 -18
- data/lib/Dobjects/Dvector_extras.rb +2 -0
- data/lib/Tioga/FigMkr.rb +175 -68
- data/lib/Tioga/Images.rb +64 -4
- data/tests/tc_Dvector.rb +45 -0
- metadata +2 -2
@@ -507,13 +507,18 @@ void Init_FigureMaker(void) {
|
|
507
507
|
rb_define_method(cFM, "private_show_marker", FM_private_show_marker, 1);
|
508
508
|
rb_define_method(cFM, "marker_string_info", FM_marker_string_info, 3);
|
509
509
|
/* images */
|
510
|
-
|
511
|
-
rb_define_method(cFM, "
|
512
|
-
rb_define_method(cFM, "
|
513
|
-
rb_define_method(cFM, "
|
514
|
-
rb_define_method(cFM, "
|
515
|
-
rb_define_method(cFM, "
|
516
|
-
rb_define_method(cFM, "
|
510
|
+
|
511
|
+
rb_define_method(cFM, "private_register_jpg", FM_private_register_jpg, 4);
|
512
|
+
rb_define_method(cFM, "jpg_info", FM_jpg_info, 1);
|
513
|
+
rb_define_method(cFM, "private_register_rgb_image", FM_private_register_rgb_image, 7);
|
514
|
+
rb_define_method(cFM, "private_register_hls_image", FM_private_register_hls_image, 7);
|
515
|
+
rb_define_method(cFM, "private_register_cmyk_image", FM_private_register_cmyk_image, 7);
|
516
|
+
rb_define_method(cFM, "private_register_grayscale_image", FM_private_register_grayscale_image, 7);
|
517
|
+
rb_define_method(cFM, "private_register_monochrome_image", FM_private_register_monochrome_image, 7);
|
518
|
+
rb_define_method(cFM, "private_register_image", FM_private_register_image, 11);
|
519
|
+
rb_define_method(cFM, "private_show_image_from_ref", FM_private_show_image_from_ref, 7);
|
520
|
+
|
521
|
+
|
517
522
|
rb_define_method(cFM, "private_create_image_data", FM_private_create_image_data, 10);
|
518
523
|
rb_define_method(cFM, "private_create_monochrome_image_data", FM_private_create_monochrome_image_data, 7);
|
519
524
|
/* colormaps */
|
@@ -560,9 +560,26 @@ extern OBJ_PTR c_private_create_monochrome_image_data(OBJ_PTR fmkr, FM *p, OBJ_P
|
|
560
560
|
double boundary, bool reversed, int *ierr);
|
561
561
|
extern void c_private_show_jpg(OBJ_PTR fmkr, FM *p, char *filename,
|
562
562
|
int width, int height, OBJ_PTR image_destination, int mask_obj_num, int *ierr);
|
563
|
+
|
563
564
|
extern OBJ_PTR c_private_show_image(OBJ_PTR fmkr, FM *p, int image_type, double llx, double lly, double lrx, double lry,
|
564
565
|
double ulx, double uly, bool interpolate, bool reversed, int w, int h, unsigned char* data, long len,
|
565
|
-
|
566
|
+
OBJ_PTR mask_min, OBJ_PTR mask_max, OBJ_PTR hival, OBJ_PTR lookup_data, int mask_obj_num, int components, const char * filters, int *ierr);
|
567
|
+
|
568
|
+
extern int c_private_register_image(OBJ_PTR fmkr, FM *p, int image_type,
|
569
|
+
bool interpolate, bool reversed,
|
570
|
+
int w, int h, unsigned char* data, long len,
|
571
|
+
OBJ_PTR mask_min, OBJ_PTR mask_max, OBJ_PTR hival, OBJ_PTR lookup_data, int mask_obj_num, int components, const char * filters, int *ierr);
|
572
|
+
|
573
|
+
extern int c_private_register_jpg(OBJ_PTR fmkr, FM *p, char *filename,
|
574
|
+
int width, int height, int mask_obj_num,
|
575
|
+
int *ierr);
|
576
|
+
|
577
|
+
extern void c_private_show_image_from_ref(OBJ_PTR fmkr, FM *p,
|
578
|
+
int ref, double llx, double lly,
|
579
|
+
double lrx, double lry,
|
580
|
+
double ulx, double uly, int *ierr);
|
581
|
+
|
582
|
+
|
566
583
|
|
567
584
|
/*======================================================================*/
|
568
585
|
// pdfpath.c
|
@@ -66,9 +66,15 @@ typedef struct jpg_info {
|
|
66
66
|
int mask_obj_num;
|
67
67
|
char *filename;
|
68
68
|
} JPG_Info;
|
69
|
+
|
70
|
+
|
71
|
+
/* Parses a JPEG file */
|
72
|
+
JPG_Info * Parse_JPG(const char * file);
|
69
73
|
extern void Write_JPG(JPG_Info *xo, int *ierr);
|
70
74
|
extern void Free_JPG(JPG_Info *xo);
|
71
75
|
|
76
|
+
|
77
|
+
|
72
78
|
typedef struct sampled_info {
|
73
79
|
// start must match start of xobj_info
|
74
80
|
struct xobj_info *next;
|
@@ -88,6 +94,8 @@ typedef struct sampled_info {
|
|
88
94
|
int hival;
|
89
95
|
int lookup_len;
|
90
96
|
unsigned char *lookup;
|
97
|
+
int components; /* number of bits per element (one color) */
|
98
|
+
char * filters; /* PDF filters to be used "as-is" */
|
91
99
|
} Sampled_Info;
|
92
100
|
extern void Write_Sampled(Sampled_Info *xo, int *ierr);
|
93
101
|
extern void Free_Sampled(Sampled_Info *xo);
|
@@ -340,8 +340,12 @@ static char *Create_Label(double val, int scale, int prec,
|
|
340
340
|
/* Exponential, i.e. 10^-1, 1, 10, 10^2, etc */
|
341
341
|
double abs_diff = fabs(val - exponent);
|
342
342
|
if (abs_diff > 0.1) snprintf(buff, sizeof(buff), (s->vertical)? "\\tiogayaxisnumericlabel{10^{%0.1f}}" : "\\tiogaxaxisnumericlabel{10^{%0.1f}}", val);
|
343
|
-
else if (exponent == 0) strcpy(buff,
|
344
|
-
|
343
|
+
else if (exponent == 0) strcpy(buff, (s->vertical)?
|
344
|
+
"\\tiogayaxisnumericlabel{1}" :
|
345
|
+
"\\tiogaxaxisnumericlabel{1}");
|
346
|
+
else if (exponent == 1) strcpy(buff, (s->vertical)?
|
347
|
+
"\\tiogayaxisnumericlabel{10}" :
|
348
|
+
"\\tiogaxaxisnumericlabel{10}");
|
345
349
|
else snprintf(buff, sizeof(buff), (s->vertical)? "\\tiogayaxisnumericlabel{10^{%d}}" : "\\tiogaxaxisnumericlabel{10^{%d}}", exponent);
|
346
350
|
} else { /* Linear */
|
347
351
|
double scale2;
|
@@ -74,7 +74,122 @@
|
|
74
74
|
/Decode [1 0] means sample values of 1 are included in the output, values of 0 are excluded
|
75
75
|
|
76
76
|
*/
|
77
|
-
|
77
|
+
|
78
|
+
/*
|
79
|
+
Reads next byte, and set *eof on end of file
|
80
|
+
*/
|
81
|
+
static int read_byte(FILE * file, int *eof)
|
82
|
+
{
|
83
|
+
int c = fgetc(file);
|
84
|
+
if(c == EOF)
|
85
|
+
*eof = 1;
|
86
|
+
else
|
87
|
+
*eof = 0;
|
88
|
+
return c;
|
89
|
+
}
|
90
|
+
|
91
|
+
/* Reads a 16 bits word */
|
92
|
+
static unsigned read_word(FILE * file, int *eof)
|
93
|
+
{
|
94
|
+
int v = fgetc(file);
|
95
|
+
int c = fgetc(file);
|
96
|
+
if(v == EOF || c == EOF)
|
97
|
+
*eof = 1;
|
98
|
+
else
|
99
|
+
*eof = 0;
|
100
|
+
return ((unsigned) v) << 8 | ((unsigned) c);
|
101
|
+
}
|
102
|
+
|
103
|
+
/* Reads until the next tag, and returns its code */
|
104
|
+
static int read_next_tag(FILE * file, int *eof)
|
105
|
+
{
|
106
|
+
int c;
|
107
|
+
*eof = 0;
|
108
|
+
|
109
|
+
/* Discard non 0xFF bytes */
|
110
|
+
do {
|
111
|
+
c = read_byte(file, eof);
|
112
|
+
if(*eof)
|
113
|
+
return 0xFF;
|
114
|
+
} while(c != 0xFF);
|
115
|
+
|
116
|
+
do {
|
117
|
+
c = read_byte(file, eof);
|
118
|
+
if(*eof)
|
119
|
+
return 0xFF;
|
120
|
+
} while (c == 0xFF);
|
121
|
+
return c;
|
122
|
+
}
|
123
|
+
|
124
|
+
static void skip_variable_length(FILE * file, int *eof)
|
125
|
+
{
|
126
|
+
*eof = 0;
|
127
|
+
int len = read_word(file, eof);
|
128
|
+
if(*eof)
|
129
|
+
return;
|
130
|
+
if(len < 2) {
|
131
|
+
*eof = 1;
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
len -= 2;
|
135
|
+
while(len > 0) {
|
136
|
+
--len;
|
137
|
+
read_byte(file, eof);
|
138
|
+
if(*eof)
|
139
|
+
return;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
/* Parses a JPEG file and extracts the resolution data from it, and
|
145
|
+
returns a newly allocated JPG_Info structure.
|
146
|
+
*/
|
147
|
+
JPG_Info * Parse_JPG(const char * file)
|
148
|
+
{
|
149
|
+
|
150
|
+
FILE * f = fopen(file, "rb");
|
151
|
+
if(! f)
|
152
|
+
return NULL;
|
153
|
+
|
154
|
+
int eof = 0;
|
155
|
+
int tag = read_next_tag(f, &eof);
|
156
|
+
if(tag != 0xD8 || eof) {
|
157
|
+
fclose(f);
|
158
|
+
return NULL;
|
159
|
+
}
|
160
|
+
|
161
|
+
while(1) {
|
162
|
+
tag = read_next_tag(f, &eof);
|
163
|
+
if(eof) {
|
164
|
+
fclose(f);
|
165
|
+
return NULL;
|
166
|
+
}
|
167
|
+
switch(tag) {
|
168
|
+
case 0xC0: /* image data */
|
169
|
+
{
|
170
|
+
int len = read_word(f, &eof);
|
171
|
+
int bps = read_byte(f, &eof);
|
172
|
+
int y = read_word(f, &eof);
|
173
|
+
int x = read_word(f, &eof);
|
174
|
+
int cmps = read_byte(f, &eof);
|
175
|
+
fclose(f);
|
176
|
+
if(eof)
|
177
|
+
return NULL;
|
178
|
+
|
179
|
+
JPG_Info * val = (JPG_Info *)calloc(1, sizeof(JPG_Info));
|
180
|
+
val->filename = ALLOC_N_char(strlen(file)+1);
|
181
|
+
strcpy(val->filename, file);
|
182
|
+
val->width = x;
|
183
|
+
val->height = y;
|
184
|
+
return val;
|
185
|
+
}
|
186
|
+
default:
|
187
|
+
skip_variable_length(f, &eof);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
|
78
193
|
|
79
194
|
void
|
80
195
|
Free_JPG(JPG_Info *xo)
|
@@ -88,6 +203,7 @@ Free_Sampled(Sampled_Info *xo)
|
|
88
203
|
{
|
89
204
|
if (xo->image_data != NULL) free(xo->image_data);
|
90
205
|
if (xo->lookup != NULL) free(xo->lookup);
|
206
|
+
if (xo->filters != NULL) free(xo->filters);
|
91
207
|
}
|
92
208
|
|
93
209
|
|
@@ -164,7 +280,7 @@ void
|
|
164
280
|
Write_Sampled(Sampled_Info *xo, int *ierr)
|
165
281
|
{
|
166
282
|
fprintf(OF, "\n\t/Subtype /Image\n");
|
167
|
-
fprintf(OF, "\t/
|
283
|
+
fprintf(OF, "\t/Interpolate %s\n",
|
168
284
|
(xo->interpolate)? "true":"false");
|
169
285
|
fprintf(OF, "\t/Height %i\n", xo->height);
|
170
286
|
fprintf(OF, "\t/Width %i\n", xo->width);
|
@@ -172,19 +288,20 @@ Write_Sampled(Sampled_Info *xo, int *ierr)
|
|
172
288
|
unsigned long new_len;
|
173
289
|
unsigned char *image_data;
|
174
290
|
unsigned char *buffer;
|
291
|
+
unsigned char *wd;
|
175
292
|
switch (xo->image_type) {
|
176
293
|
case RGB_IMAGE:
|
177
294
|
case HLS_IMAGE:
|
178
295
|
fprintf(OF, "\t/ColorSpace /DeviceRGB\n");
|
179
|
-
fprintf(OF, "\t/BitsPerComponent
|
296
|
+
fprintf(OF, "\t/BitsPerComponent %d\n", xo->components);
|
180
297
|
break;
|
181
298
|
case CMYK_IMAGE:
|
182
299
|
fprintf(OF, "\t/ColorSpace /DeviceCMYK\n");
|
183
|
-
fprintf(OF, "\t/BitsPerComponent
|
300
|
+
fprintf(OF, "\t/BitsPerComponent %d\n", xo->components);
|
184
301
|
break;
|
185
302
|
case GRAY_IMAGE:
|
186
303
|
fprintf(OF, "\t/ColorSpace /DeviceGray\n");
|
187
|
-
fprintf(OF, "\t/BitsPerComponent
|
304
|
+
fprintf(OF, "\t/BitsPerComponent %d\n", xo->components);
|
188
305
|
break;
|
189
306
|
case MONO_IMAGE:
|
190
307
|
fprintf(OF, "\t/ImageMask true\n");
|
@@ -202,7 +319,7 @@ Write_Sampled(Sampled_Info *xo, int *ierr)
|
|
202
319
|
else fprintf(OF, "%x", c);
|
203
320
|
}
|
204
321
|
fprintf(OF, "> ]\n");
|
205
|
-
fprintf(OF, "\t/BitsPerComponent
|
322
|
+
fprintf(OF, "\t/BitsPerComponent %d\n", xo->components);
|
206
323
|
}
|
207
324
|
if (xo->mask_obj_num > 0) {
|
208
325
|
if (xo->image_type == MONO_IMAGE) {
|
@@ -226,22 +343,35 @@ Write_Sampled(Sampled_Info *xo, int *ierr)
|
|
226
343
|
} else {
|
227
344
|
image_data = xo->image_data;
|
228
345
|
}
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
346
|
+
|
347
|
+
buffer = NULL;
|
348
|
+
wd = image_data;
|
349
|
+
|
350
|
+
if(xo->filters) {
|
351
|
+
new_len = xo->length;
|
352
|
+
fprintf(OF, "%s", xo->filters);
|
353
|
+
}
|
354
|
+
else {
|
355
|
+
fprintf(OF, "\t/Filter /FlateDecode\n");
|
356
|
+
|
357
|
+
new_len = (xo->length * 11)/10 + 100;
|
358
|
+
buffer = ALLOC_N_unsigned_char(new_len);
|
359
|
+
if (do_flate_compress(buffer, &new_len, image_data, xo->length)
|
360
|
+
!= FLATE_OK) {
|
361
|
+
free(buffer);
|
362
|
+
RAISE_ERROR("Error compressing image data", ierr);
|
363
|
+
return;
|
364
|
+
}
|
365
|
+
wd = buffer;
|
237
366
|
}
|
238
367
|
fprintf(OF, "\t/Length %li\n", new_len);
|
239
368
|
fprintf(OF, "\t>>\nstream\n");
|
240
|
-
if (fwrite(
|
369
|
+
if (fwrite(wd, 1, new_len, OF) < new_len) {
|
241
370
|
RAISE_ERROR("Error writing image data", ierr);
|
242
371
|
return;
|
243
372
|
}
|
244
|
-
|
373
|
+
if(buffer)
|
374
|
+
free(buffer);
|
245
375
|
if (xo->image_type == HLS_IMAGE) free(image_data);
|
246
376
|
fprintf(OF, "\nendstream\nendobj\n");
|
247
377
|
}
|
@@ -258,8 +388,29 @@ Create_Transform_from_Points(double llx, double lly, double lrx, double lry,
|
|
258
388
|
}
|
259
389
|
|
260
390
|
|
391
|
+
/* Read the image here ?*/
|
392
|
+
int
|
393
|
+
c_private_register_jpg(OBJ_PTR fmkr, FM *p, char *filename,
|
394
|
+
int width, int height,
|
395
|
+
int mask_obj_num, int *ierr)
|
396
|
+
{
|
397
|
+
JPG_Info *xo = (JPG_Info *)calloc(1,sizeof(JPG_Info));
|
398
|
+
xo->xobj_subtype = JPG_SUBTYPE;
|
399
|
+
xo->next = xobj_list;
|
400
|
+
xobj_list = (XObject_Info *)xo;
|
401
|
+
xo->xo_num = next_available_xo_number++;
|
402
|
+
xo->obj_num = next_available_object_number++;
|
403
|
+
xo->filename = ALLOC_N_char(strlen(filename)+1);
|
404
|
+
strcpy(xo->filename, filename);
|
405
|
+
xo->width = width;
|
406
|
+
xo->height = height;
|
407
|
+
xo->mask_obj_num = mask_obj_num;
|
408
|
+
return xo->obj_num;
|
409
|
+
}
|
410
|
+
|
411
|
+
|
261
412
|
static void
|
262
|
-
|
413
|
+
Expand_Array(OBJ_PTR image_destination, double *dest, int *ierr)
|
263
414
|
{
|
264
415
|
int len = Array_Len(image_destination,ierr);
|
265
416
|
if (*ierr != 0) return;
|
@@ -272,58 +423,31 @@ Get_Image_Dest(FM *p, OBJ_PTR image_destination, double *dest, int *ierr)
|
|
272
423
|
for (i = 0; i < 6; i++) {
|
273
424
|
OBJ_PTR entry = Array_Entry(image_destination, i, ierr);
|
274
425
|
if (*ierr != 0) return;
|
275
|
-
|
276
|
-
dest[i] = convert_figure_to_output_x(p,Number_to_double(entry, ierr));
|
277
|
-
else
|
278
|
-
dest[i] = convert_figure_to_output_y(p,Number_to_double(entry, ierr));
|
426
|
+
dest[i] = Number_to_double(entry, ierr);
|
279
427
|
if (*ierr != 0) return;
|
280
428
|
}
|
281
429
|
}
|
282
430
|
|
283
|
-
|
284
|
-
static void
|
285
|
-
Show_JPEG(FM *p, char *filename, int width, int height, double *dest,
|
286
|
-
int subtype, int mask_obj_num)
|
287
|
-
{
|
288
|
-
JPG_Info *xo = (JPG_Info *)calloc(1,sizeof(JPG_Info));
|
289
|
-
xo->xobj_subtype = subtype;
|
290
|
-
double llx = dest[0], lly = dest[1], lrx = dest[2], lry = dest[3],
|
291
|
-
ulx = dest[4], uly = dest[5];
|
292
|
-
double a, b, c, d, e, f; // the transform to position the image
|
293
|
-
xo->next = xobj_list;
|
294
|
-
xobj_list = (XObject_Info *)xo;
|
295
|
-
xo->xo_num = next_available_xo_number++;
|
296
|
-
xo->obj_num = next_available_object_number++;
|
297
|
-
xo->filename = ALLOC_N_char(strlen(filename)+1);
|
298
|
-
strcpy(xo->filename, filename);
|
299
|
-
xo->width = width;
|
300
|
-
xo->height = height;
|
301
|
-
xo->mask_obj_num = mask_obj_num;
|
302
|
-
Create_Transform_from_Points(llx, lly, lrx, lry, ulx, uly,
|
303
|
-
&a, &b, &c, &d, &e, &f);
|
304
|
-
fprintf(TF, "q %0.2f %0.2f %0.2f %0.2f %0.2f %0.2f cm /XObj%i Do Q\n",
|
305
|
-
a, b, c, d, e, f, xo->xo_num);
|
306
|
-
update_bbox(p, llx, lly);
|
307
|
-
update_bbox(p, lrx, lry);
|
308
|
-
update_bbox(p, ulx, uly);
|
309
|
-
update_bbox(p, lrx+ulx-llx, lry+uly-lly);
|
310
|
-
}
|
311
|
-
|
312
|
-
|
313
431
|
void
|
314
432
|
c_private_show_jpg(OBJ_PTR fmkr, FM *p, char *filename,
|
315
433
|
int width, int height, OBJ_PTR image_destination,
|
316
434
|
int mask_obj_num, int *ierr)
|
317
435
|
{
|
318
436
|
double dest[6];
|
437
|
+
int ref;
|
319
438
|
if (constructing_path) {
|
320
439
|
RAISE_ERROR("Sorry: must finish with current path before "
|
321
440
|
"calling show_jpg", ierr);
|
322
441
|
return;
|
323
442
|
}
|
324
|
-
|
443
|
+
ref = c_private_register_jpg(fmkr, p, filename, width, height,
|
444
|
+
mask_obj_num, *ierr);
|
445
|
+
Expand_Array(image_destination, dest, ierr);
|
325
446
|
if (*ierr != 0) return;
|
326
|
-
|
447
|
+
|
448
|
+
c_private_show_image_from_ref(fmkr, p, ref, dest[0], dest[1],
|
449
|
+
dest[2], dest[3], dest[4], dest[5],
|
450
|
+
ierr);
|
327
451
|
}
|
328
452
|
|
329
453
|
|
@@ -465,7 +589,29 @@ c_private_show_image(OBJ_PTR fmkr, FM *p, int image_type, double llx,
|
|
465
589
|
double uly, bool interpolate, bool reversed,
|
466
590
|
int w, int h, unsigned char* data, long len,
|
467
591
|
OBJ_PTR mask_min, OBJ_PTR mask_max, OBJ_PTR hivalue,
|
468
|
-
OBJ_PTR lookup_data, int mask_obj_num, int
|
592
|
+
OBJ_PTR lookup_data, int mask_obj_num, int components,
|
593
|
+
const char * filters,
|
594
|
+
int *ierr)
|
595
|
+
{
|
596
|
+
int ref = c_private_register_image(fmkr, p, image_type,
|
597
|
+
interpolate, reversed,
|
598
|
+
w, h, data, len, mask_min,
|
599
|
+
mask_max, hivalue, lookup_data,
|
600
|
+
mask_obj_num, components, filters, ierr);
|
601
|
+
if (mask_obj_num != -1)
|
602
|
+
c_private_show_image_from_ref(fmkr, p, ref, llx, lly,
|
603
|
+
lrx, lry, ulx, uly, ierr);
|
604
|
+
return Integer_New(ref);
|
605
|
+
}
|
606
|
+
|
607
|
+
int
|
608
|
+
c_private_register_image(OBJ_PTR fmkr, FM *p, int image_type,
|
609
|
+
bool interpolate, bool reversed,
|
610
|
+
int w, int h, unsigned char* data, long len,
|
611
|
+
OBJ_PTR mask_min, OBJ_PTR mask_max, OBJ_PTR hivalue,
|
612
|
+
OBJ_PTR lookup_data, int mask_obj_num, int components,
|
613
|
+
const char * filters,
|
614
|
+
int *ierr)
|
469
615
|
{
|
470
616
|
unsigned char *lookup = NULL;
|
471
617
|
int value_mask_min = 256, value_mask_max = 256, lookup_len = 0, hival = 0;
|
@@ -483,12 +629,6 @@ c_private_show_image(OBJ_PTR fmkr, FM *p, int image_type, double llx,
|
|
483
629
|
if (*ierr != 0) RETURN_NIL;
|
484
630
|
}
|
485
631
|
|
486
|
-
llx = convert_figure_to_output_x(p, llx);
|
487
|
-
lly = convert_figure_to_output_y(p, lly);
|
488
|
-
lrx = convert_figure_to_output_x(p, lrx);
|
489
|
-
lry = convert_figure_to_output_y(p, lry);
|
490
|
-
ulx = convert_figure_to_output_x(p, ulx);
|
491
|
-
uly = convert_figure_to_output_y(p, uly);
|
492
632
|
|
493
633
|
Sampled_Info *xo = (Sampled_Info *)calloc(1, sizeof(Sampled_Info));
|
494
634
|
xo->xobj_subtype = SAMPLED_SUBTYPE;
|
@@ -502,8 +642,16 @@ c_private_show_image(OBJ_PTR fmkr, FM *p, int image_type, double llx,
|
|
502
642
|
xo->length = len;
|
503
643
|
xo->interpolate = interpolate;
|
504
644
|
xo->reversed = reversed;
|
645
|
+
xo->components = components;
|
505
646
|
memcpy(xo->image_data, data, len);
|
506
647
|
xo->image_type = image_type;
|
648
|
+
if(filters) {
|
649
|
+
int len = strlen(filters) + 1;
|
650
|
+
xo->filters = calloc(1, len);
|
651
|
+
memcpy(xo->filters, filters, len);
|
652
|
+
}
|
653
|
+
else
|
654
|
+
xo->filters = NULL;
|
507
655
|
if (image_type != COLORMAP_IMAGE) xo->lookup = NULL;
|
508
656
|
else {
|
509
657
|
if ((hival+1)*3 > lookup_len) {
|
@@ -523,17 +671,59 @@ c_private_show_image(OBJ_PTR fmkr, FM *p, int image_type, double llx,
|
|
523
671
|
xo->value_mask_min = value_mask_min;
|
524
672
|
xo->value_mask_max = value_mask_max;
|
525
673
|
xo->mask_obj_num = mask_obj_num;
|
526
|
-
|
527
|
-
|
528
|
-
|
674
|
+
return xo->obj_num;
|
675
|
+
}
|
676
|
+
|
677
|
+
/* Goes through the xobject list and find the one whose object number
|
678
|
+
matches the one given, and returns the Xobject number. -1 if not
|
679
|
+
found. */
|
680
|
+
|
681
|
+
int Find_XObjRef(int ref)
|
682
|
+
{
|
683
|
+
XObject_Info * info = xobj_list;
|
684
|
+
while(1) {
|
685
|
+
if(info->obj_num == ref)
|
686
|
+
return info->xo_num;
|
687
|
+
info = info->next;
|
688
|
+
if(! info)
|
689
|
+
break;
|
690
|
+
}
|
691
|
+
return -1;
|
692
|
+
}
|
693
|
+
|
694
|
+
void
|
695
|
+
c_private_show_image_from_ref(OBJ_PTR fmkr, FM *p, int ref, double llx,
|
696
|
+
double lly, double lrx, double lry, double ulx,
|
697
|
+
double uly,
|
698
|
+
int *ierr)
|
699
|
+
{
|
700
|
+
if (constructing_path) {
|
701
|
+
RAISE_ERROR("Sorry: must finish with current path before calling "
|
702
|
+
"show_image", ierr);
|
703
|
+
return;
|
704
|
+
}
|
705
|
+
|
706
|
+
double a, b, c, d, e, f; // the transform to position the image
|
707
|
+
int xo_num = Find_XObjRef(ref);
|
708
|
+
if(xo_num < 0) {
|
709
|
+
RAISE_ERROR_i("Could not find image PDF object %d", ref,
|
710
|
+
ierr);
|
711
|
+
return;
|
712
|
+
}
|
713
|
+
|
714
|
+
llx = convert_figure_to_output_x(p, llx);
|
715
|
+
lly = convert_figure_to_output_y(p, lly);
|
716
|
+
lrx = convert_figure_to_output_x(p, lrx);
|
717
|
+
lry = convert_figure_to_output_y(p, lry);
|
718
|
+
ulx = convert_figure_to_output_x(p, ulx);
|
719
|
+
uly = convert_figure_to_output_y(p, uly);
|
720
|
+
|
529
721
|
Create_Transform_from_Points(llx, lly, lrx, lry, ulx, uly,
|
530
722
|
&a, &b, &c, &d, &e, &f);
|
531
723
|
fprintf(TF, "q %0.2f %0.2f %0.2f %0.2f %0.2f %0.2f cm /XObj%i Do Q\n",
|
532
|
-
a, b, c, d, e, f,
|
724
|
+
a, b, c, d, e, f, xo_num);
|
533
725
|
update_bbox(p, llx, lly);
|
534
726
|
update_bbox(p, lrx, lry);
|
535
727
|
update_bbox(p, ulx, uly);
|
536
728
|
update_bbox(p, lrx+ulx-llx, lry+uly-lly);
|
537
|
-
return Integer_New(xo->obj_num);
|
538
729
|
}
|
539
|
-
|