@revizly/sharp-libvips-dev 1.0.20 → 1.0.21
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.
- package/cplusplus/VConnection.cpp +151 -1
- package/cplusplus/VError.cpp +51 -1
- package/cplusplus/VImage.cpp +1611 -1
- package/cplusplus/VInterpolate.cpp +62 -1
- package/cplusplus/VRegion.cpp +27 -1
- package/cplusplus/vips-operators.cpp +3900 -1
- package/package.json +1 -1
package/cplusplus/VImage.cpp
CHANGED
|
@@ -1 +1,1611 @@
|
|
|
1
|
-
|
|
1
|
+
/* Object part of VImage class
|
|
2
|
+
*
|
|
3
|
+
* 30/12/14
|
|
4
|
+
* - allow set enum value from string
|
|
5
|
+
* 10/6/16
|
|
6
|
+
* - missing implementation of VImage::write()
|
|
7
|
+
* 11/6/16
|
|
8
|
+
* - added arithmetic assignment overloads, += etc.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
|
|
13
|
+
Copyright (C) 1991-2001 The National Gallery
|
|
14
|
+
|
|
15
|
+
This program is free software; you can redistribute it and/or modify
|
|
16
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
17
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
18
|
+
(at your option) any later version.
|
|
19
|
+
|
|
20
|
+
This program is distributed in the hope that it will be useful,
|
|
21
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23
|
+
GNU Lesser General Public License for more details.
|
|
24
|
+
|
|
25
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
26
|
+
along with this program; if not, write to the Free Software
|
|
27
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
28
|
+
02110-1301 USA
|
|
29
|
+
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
|
|
34
|
+
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
|
35
|
+
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
#ifdef HAVE_CONFIG_H
|
|
39
|
+
#include <config.h>
|
|
40
|
+
#endif /*HAVE_CONFIG_H*/
|
|
41
|
+
|
|
42
|
+
#include <vips/vips8>
|
|
43
|
+
|
|
44
|
+
#include <vips/debug.h>
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
#define VIPS_DEBUG
|
|
48
|
+
#define VIPS_DEBUG_VERBOSE
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
VIPS_NAMESPACE_START
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* \namespace vips
|
|
55
|
+
*
|
|
56
|
+
* General docs for the vips namespace.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
std::vector<double>
|
|
60
|
+
to_vectorv(int n, ...)
|
|
61
|
+
{
|
|
62
|
+
std::vector<double> vector(n);
|
|
63
|
+
va_list ap;
|
|
64
|
+
|
|
65
|
+
va_start(ap, n);
|
|
66
|
+
for (int i = 0; i < n; i++)
|
|
67
|
+
vector[i] = va_arg(ap, double);
|
|
68
|
+
va_end(ap);
|
|
69
|
+
|
|
70
|
+
return vector;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
std::vector<double>
|
|
74
|
+
to_vector(double value)
|
|
75
|
+
{
|
|
76
|
+
return to_vectorv(1, value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
std::vector<double>
|
|
80
|
+
to_vector(int n, double array[])
|
|
81
|
+
{
|
|
82
|
+
std::vector<double> vector(n);
|
|
83
|
+
|
|
84
|
+
for (int i = 0; i < n; i++)
|
|
85
|
+
vector[i] = array[i];
|
|
86
|
+
|
|
87
|
+
return vector;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
std::vector<double>
|
|
91
|
+
negate(std::vector<double> vector)
|
|
92
|
+
{
|
|
93
|
+
std::vector<double> new_vector(vector.size());
|
|
94
|
+
|
|
95
|
+
for (std::vector<double>::size_type i = 0; i < vector.size(); i++)
|
|
96
|
+
new_vector[i] = vector[i] * -1;
|
|
97
|
+
|
|
98
|
+
return new_vector;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
std::vector<double>
|
|
102
|
+
invert(std::vector<double> vector)
|
|
103
|
+
{
|
|
104
|
+
std::vector<double> new_vector(vector.size());
|
|
105
|
+
|
|
106
|
+
for (std::vector<double>::size_type i = 0; i < vector.size(); i++)
|
|
107
|
+
new_vector[i] = 1.0 / vector[i];
|
|
108
|
+
|
|
109
|
+
return new_vector;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
VOption::~VOption()
|
|
113
|
+
{
|
|
114
|
+
std::list<Pair *>::iterator i;
|
|
115
|
+
|
|
116
|
+
for (i = options.begin(); i != options.end(); ++i)
|
|
117
|
+
delete *i;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// input bool
|
|
121
|
+
VOption *
|
|
122
|
+
VOption::set(const char *name, bool value)
|
|
123
|
+
{
|
|
124
|
+
Pair *pair = new Pair(name);
|
|
125
|
+
|
|
126
|
+
pair->input = true;
|
|
127
|
+
g_value_init(&pair->value, G_TYPE_BOOLEAN);
|
|
128
|
+
g_value_set_boolean(&pair->value, value);
|
|
129
|
+
options.push_back(pair);
|
|
130
|
+
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// input int ... this path is used for enums as well
|
|
135
|
+
VOption *
|
|
136
|
+
VOption::set(const char *name, int value)
|
|
137
|
+
{
|
|
138
|
+
Pair *pair = new Pair(name);
|
|
139
|
+
|
|
140
|
+
pair->input = true;
|
|
141
|
+
g_value_init(&pair->value, G_TYPE_INT);
|
|
142
|
+
g_value_set_int(&pair->value, value);
|
|
143
|
+
options.push_back(pair);
|
|
144
|
+
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// input guint64
|
|
149
|
+
VOption *
|
|
150
|
+
VOption::set(const char *name, guint64 value)
|
|
151
|
+
{
|
|
152
|
+
Pair *pair = new Pair(name);
|
|
153
|
+
|
|
154
|
+
pair->input = true;
|
|
155
|
+
g_value_init(&pair->value, G_TYPE_UINT64);
|
|
156
|
+
g_value_set_uint64(&pair->value, value);
|
|
157
|
+
options.push_back(pair);
|
|
158
|
+
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// input double
|
|
163
|
+
VOption *
|
|
164
|
+
VOption::set(const char *name, double value)
|
|
165
|
+
{
|
|
166
|
+
Pair *pair = new Pair(name);
|
|
167
|
+
|
|
168
|
+
pair->input = true;
|
|
169
|
+
g_value_init(&pair->value, G_TYPE_DOUBLE);
|
|
170
|
+
g_value_set_double(&pair->value, value);
|
|
171
|
+
options.push_back(pair);
|
|
172
|
+
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
VOption *
|
|
177
|
+
VOption::set(const char *name, const char *value)
|
|
178
|
+
{
|
|
179
|
+
Pair *pair = new Pair(name);
|
|
180
|
+
|
|
181
|
+
pair->input = true;
|
|
182
|
+
g_value_init(&pair->value, G_TYPE_STRING);
|
|
183
|
+
g_value_set_string(&pair->value, value);
|
|
184
|
+
options.push_back(pair);
|
|
185
|
+
|
|
186
|
+
return this;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// input vips object (image, source, target, etc. etc.)
|
|
190
|
+
VOption *
|
|
191
|
+
VOption::set(const char *name, const VObject value)
|
|
192
|
+
{
|
|
193
|
+
Pair *pair = new Pair(name);
|
|
194
|
+
VipsObject *object = value.get_object();
|
|
195
|
+
GType type = G_OBJECT_TYPE(object);
|
|
196
|
+
|
|
197
|
+
pair->input = true;
|
|
198
|
+
g_value_init(&pair->value, type);
|
|
199
|
+
g_value_set_object(&pair->value, object);
|
|
200
|
+
options.push_back(pair);
|
|
201
|
+
|
|
202
|
+
return this;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// input int array
|
|
206
|
+
VOption *
|
|
207
|
+
VOption::set(const char *name, std::vector<int> value)
|
|
208
|
+
{
|
|
209
|
+
Pair *pair = new Pair(name);
|
|
210
|
+
|
|
211
|
+
int *array;
|
|
212
|
+
|
|
213
|
+
pair->input = true;
|
|
214
|
+
|
|
215
|
+
g_value_init(&pair->value, VIPS_TYPE_ARRAY_INT);
|
|
216
|
+
vips_value_set_array_int(&pair->value, nullptr,
|
|
217
|
+
static_cast<int>(value.size()));
|
|
218
|
+
array = vips_value_get_array_int(&pair->value, nullptr);
|
|
219
|
+
|
|
220
|
+
for (std::vector<double>::size_type i = 0; i < value.size(); i++)
|
|
221
|
+
array[i] = value[i];
|
|
222
|
+
|
|
223
|
+
options.push_back(pair);
|
|
224
|
+
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// input double array
|
|
229
|
+
VOption *
|
|
230
|
+
VOption::set(const char *name, std::vector<double> value)
|
|
231
|
+
{
|
|
232
|
+
Pair *pair = new Pair(name);
|
|
233
|
+
|
|
234
|
+
double *array;
|
|
235
|
+
|
|
236
|
+
pair->input = true;
|
|
237
|
+
|
|
238
|
+
g_value_init(&pair->value, VIPS_TYPE_ARRAY_DOUBLE);
|
|
239
|
+
vips_value_set_array_double(&pair->value, nullptr,
|
|
240
|
+
static_cast<int>(value.size()));
|
|
241
|
+
array = vips_value_get_array_double(&pair->value, nullptr);
|
|
242
|
+
|
|
243
|
+
for (std::vector<double>::size_type i = 0; i < value.size(); i++)
|
|
244
|
+
array[i] = value[i];
|
|
245
|
+
|
|
246
|
+
options.push_back(pair);
|
|
247
|
+
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// input image array
|
|
252
|
+
VOption *
|
|
253
|
+
VOption::set(const char *name, std::vector<VImage> value)
|
|
254
|
+
{
|
|
255
|
+
Pair *pair = new Pair(name);
|
|
256
|
+
|
|
257
|
+
VipsImage **array;
|
|
258
|
+
|
|
259
|
+
pair->input = true;
|
|
260
|
+
|
|
261
|
+
g_value_init(&pair->value, VIPS_TYPE_ARRAY_IMAGE);
|
|
262
|
+
vips_value_set_array_image(&pair->value,
|
|
263
|
+
static_cast<int>(value.size()));
|
|
264
|
+
array = vips_value_get_array_image(&pair->value, nullptr);
|
|
265
|
+
|
|
266
|
+
for (std::vector<double>::size_type i = 0; i < value.size(); i++) {
|
|
267
|
+
VipsImage *vips_image = value[i].get_image();
|
|
268
|
+
|
|
269
|
+
array[i] = vips_image;
|
|
270
|
+
g_object_ref(vips_image);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
options.push_back(pair);
|
|
274
|
+
|
|
275
|
+
return this;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// input blob
|
|
279
|
+
VOption *
|
|
280
|
+
VOption::set(const char *name, VipsBlob *value)
|
|
281
|
+
{
|
|
282
|
+
Pair *pair = new Pair(name);
|
|
283
|
+
|
|
284
|
+
pair->input = true;
|
|
285
|
+
g_value_init(&pair->value, VIPS_TYPE_BLOB);
|
|
286
|
+
g_value_set_boxed(&pair->value, value);
|
|
287
|
+
options.push_back(pair);
|
|
288
|
+
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// output bool
|
|
293
|
+
VOption *
|
|
294
|
+
VOption::set(const char *name, bool *value)
|
|
295
|
+
{
|
|
296
|
+
Pair *pair = new Pair(name);
|
|
297
|
+
|
|
298
|
+
pair->input = false;
|
|
299
|
+
pair->vbool = value;
|
|
300
|
+
g_value_init(&pair->value, G_TYPE_BOOLEAN);
|
|
301
|
+
|
|
302
|
+
options.push_back(pair);
|
|
303
|
+
|
|
304
|
+
return this;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// output int
|
|
308
|
+
VOption *
|
|
309
|
+
VOption::set(const char *name, int *value)
|
|
310
|
+
{
|
|
311
|
+
Pair *pair = new Pair(name);
|
|
312
|
+
|
|
313
|
+
pair->input = false;
|
|
314
|
+
pair->vint = value;
|
|
315
|
+
g_value_init(&pair->value, G_TYPE_INT);
|
|
316
|
+
|
|
317
|
+
options.push_back(pair);
|
|
318
|
+
|
|
319
|
+
return this;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// output double
|
|
323
|
+
VOption *
|
|
324
|
+
VOption::set(const char *name, double *value)
|
|
325
|
+
{
|
|
326
|
+
Pair *pair = new Pair(name);
|
|
327
|
+
|
|
328
|
+
pair->input = false;
|
|
329
|
+
pair->vdouble = value;
|
|
330
|
+
g_value_init(&pair->value, G_TYPE_DOUBLE);
|
|
331
|
+
|
|
332
|
+
options.push_back(pair);
|
|
333
|
+
|
|
334
|
+
return this;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// output image
|
|
338
|
+
VOption *
|
|
339
|
+
VOption::set(const char *name, VImage *value)
|
|
340
|
+
{
|
|
341
|
+
Pair *pair = new Pair(name);
|
|
342
|
+
|
|
343
|
+
pair->input = false;
|
|
344
|
+
pair->vimage = value;
|
|
345
|
+
g_value_init(&pair->value, VIPS_TYPE_IMAGE);
|
|
346
|
+
|
|
347
|
+
options.push_back(pair);
|
|
348
|
+
|
|
349
|
+
return this;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// output doublearray
|
|
353
|
+
VOption *
|
|
354
|
+
VOption::set(const char *name, std::vector<double> *value)
|
|
355
|
+
{
|
|
356
|
+
Pair *pair = new Pair(name);
|
|
357
|
+
|
|
358
|
+
pair->input = false;
|
|
359
|
+
pair->vvector = value;
|
|
360
|
+
g_value_init(&pair->value, VIPS_TYPE_ARRAY_DOUBLE);
|
|
361
|
+
|
|
362
|
+
options.push_back(pair);
|
|
363
|
+
|
|
364
|
+
return this;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// output blob
|
|
368
|
+
VOption *
|
|
369
|
+
VOption::set(const char *name, VipsBlob **value)
|
|
370
|
+
{
|
|
371
|
+
Pair *pair = new Pair(name);
|
|
372
|
+
|
|
373
|
+
pair->input = false;
|
|
374
|
+
pair->vblob = value;
|
|
375
|
+
g_value_init(&pair->value, VIPS_TYPE_BLOB);
|
|
376
|
+
|
|
377
|
+
options.push_back(pair);
|
|
378
|
+
|
|
379
|
+
return this;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// just g_object_set_property(), except we allow set enum from string
|
|
383
|
+
static void
|
|
384
|
+
set_property(VipsObject *object, const char *name, const GValue *value)
|
|
385
|
+
{
|
|
386
|
+
VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS(object);
|
|
387
|
+
GType type = G_VALUE_TYPE(value);
|
|
388
|
+
|
|
389
|
+
GParamSpec *pspec;
|
|
390
|
+
VipsArgumentClass *argument_class;
|
|
391
|
+
VipsArgumentInstance *argument_instance;
|
|
392
|
+
|
|
393
|
+
if (vips_object_get_argument(object, name,
|
|
394
|
+
&pspec, &argument_class, &argument_instance)) {
|
|
395
|
+
g_warning("%s", vips_error_buffer());
|
|
396
|
+
vips_error_clear();
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (G_IS_PARAM_SPEC_ENUM(pspec) &&
|
|
401
|
+
type == G_TYPE_STRING) {
|
|
402
|
+
GType pspec_type = G_PARAM_SPEC_VALUE_TYPE(pspec);
|
|
403
|
+
|
|
404
|
+
int enum_value;
|
|
405
|
+
GValue value2 = G_VALUE_INIT;
|
|
406
|
+
|
|
407
|
+
if ((enum_value = vips_enum_from_nick(object_class->nickname,
|
|
408
|
+
pspec_type, g_value_get_string(value))) < 0) {
|
|
409
|
+
g_warning("%s", vips_error_buffer());
|
|
410
|
+
vips_error_clear();
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
g_value_init(&value2, pspec_type);
|
|
415
|
+
g_value_set_enum(&value2, enum_value);
|
|
416
|
+
g_object_set_property(G_OBJECT(object), name, &value2);
|
|
417
|
+
g_value_unset(&value2);
|
|
418
|
+
}
|
|
419
|
+
else
|
|
420
|
+
g_object_set_property(G_OBJECT(object), name, value);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// walk the options and set props on the operation
|
|
424
|
+
void
|
|
425
|
+
VOption::set_operation(VipsOperation *operation)
|
|
426
|
+
{
|
|
427
|
+
std::list<Pair *>::iterator i;
|
|
428
|
+
|
|
429
|
+
for (i = options.begin(); i != options.end(); ++i)
|
|
430
|
+
if ((*i)->input) {
|
|
431
|
+
#ifdef VIPS_DEBUG_VERBOSE
|
|
432
|
+
printf("set_operation: ");
|
|
433
|
+
vips_object_print_name(VIPS_OBJECT(operation));
|
|
434
|
+
char *str_value =
|
|
435
|
+
g_strdup_value_contents(&(*i)->value);
|
|
436
|
+
printf(".%s = %s\n", (*i)->name, str_value);
|
|
437
|
+
g_free(str_value);
|
|
438
|
+
#endif /*VIPS_DEBUG_VERBOSE*/
|
|
439
|
+
|
|
440
|
+
set_property(VIPS_OBJECT(operation),
|
|
441
|
+
(*i)->name, &(*i)->value);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// walk the options and fetch any requested outputs
|
|
446
|
+
void
|
|
447
|
+
VOption::get_operation(VipsOperation *operation)
|
|
448
|
+
{
|
|
449
|
+
std::list<Pair *>::iterator i;
|
|
450
|
+
|
|
451
|
+
for (i = options.begin(); i != options.end(); ++i)
|
|
452
|
+
if (!(*i)->input) {
|
|
453
|
+
const char *name = (*i)->name;
|
|
454
|
+
|
|
455
|
+
g_object_get_property(G_OBJECT(operation),
|
|
456
|
+
name, &(*i)->value);
|
|
457
|
+
|
|
458
|
+
#ifdef VIPS_DEBUG_VERBOSE
|
|
459
|
+
printf("get_operation: ");
|
|
460
|
+
vips_object_print_name(VIPS_OBJECT(operation));
|
|
461
|
+
char *str_value = g_strdup_value_contents(
|
|
462
|
+
&(*i)->value);
|
|
463
|
+
printf(".%s = %s\n", name, str_value);
|
|
464
|
+
g_free(str_value);
|
|
465
|
+
#endif /*VIPS_DEBUG_VERBOSE*/
|
|
466
|
+
|
|
467
|
+
GValue *value = &(*i)->value;
|
|
468
|
+
GType type = G_VALUE_TYPE(value);
|
|
469
|
+
|
|
470
|
+
if (type == VIPS_TYPE_IMAGE) {
|
|
471
|
+
// rebox object
|
|
472
|
+
VipsImage *image = VIPS_IMAGE(
|
|
473
|
+
g_value_get_object(value));
|
|
474
|
+
*((*i)->vimage) = VImage(image);
|
|
475
|
+
}
|
|
476
|
+
else if (type == G_TYPE_INT)
|
|
477
|
+
*((*i)->vint) = g_value_get_int(value);
|
|
478
|
+
else if (type == G_TYPE_BOOLEAN)
|
|
479
|
+
*((*i)->vbool) = g_value_get_boolean(value);
|
|
480
|
+
else if (type == G_TYPE_DOUBLE)
|
|
481
|
+
*((*i)->vdouble) = g_value_get_double(value);
|
|
482
|
+
else if (type == VIPS_TYPE_ARRAY_DOUBLE) {
|
|
483
|
+
int length;
|
|
484
|
+
double *array =
|
|
485
|
+
vips_value_get_array_double(value,
|
|
486
|
+
&length);
|
|
487
|
+
|
|
488
|
+
((*i)->vvector)->resize(length);
|
|
489
|
+
for (int j = 0; j < length; j++)
|
|
490
|
+
(*((*i)->vvector))[j] = array[j];
|
|
491
|
+
}
|
|
492
|
+
else if (type == VIPS_TYPE_BLOB) {
|
|
493
|
+
// our caller gets a reference
|
|
494
|
+
*((*i)->vblob) =
|
|
495
|
+
(VipsBlob *) g_value_dup_boxed(value);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
void
|
|
501
|
+
VImage::call_option_string(const char *operation_name,
|
|
502
|
+
const char *option_string, VOption *options)
|
|
503
|
+
{
|
|
504
|
+
VipsOperation *operation;
|
|
505
|
+
|
|
506
|
+
VIPS_DEBUG_MSG("call_option_string: starting for %s ...\n",
|
|
507
|
+
operation_name);
|
|
508
|
+
|
|
509
|
+
if (!(operation = vips_operation_new(operation_name))) {
|
|
510
|
+
delete options;
|
|
511
|
+
throw(VError());
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/* Set str options before vargs options, so the user can't
|
|
515
|
+
* override things we set deliberately.
|
|
516
|
+
*/
|
|
517
|
+
if (option_string &&
|
|
518
|
+
vips_object_set_from_string(VIPS_OBJECT(operation),
|
|
519
|
+
option_string)) {
|
|
520
|
+
vips_object_unref_outputs(VIPS_OBJECT(operation));
|
|
521
|
+
g_object_unref(operation);
|
|
522
|
+
delete options;
|
|
523
|
+
throw(VError());
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (options)
|
|
527
|
+
options->set_operation(operation);
|
|
528
|
+
|
|
529
|
+
/* Build from cache.
|
|
530
|
+
*/
|
|
531
|
+
if (vips_cache_operation_buildp(&operation)) {
|
|
532
|
+
vips_object_unref_outputs(VIPS_OBJECT(operation));
|
|
533
|
+
g_object_unref(operation);
|
|
534
|
+
delete options;
|
|
535
|
+
throw(VError());
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/* Walk args again, writing output.
|
|
539
|
+
*/
|
|
540
|
+
if (options)
|
|
541
|
+
options->get_operation(operation);
|
|
542
|
+
|
|
543
|
+
/* We're done with options!
|
|
544
|
+
*/
|
|
545
|
+
delete options;
|
|
546
|
+
|
|
547
|
+
/* The operation we have built should now have been reffed by
|
|
548
|
+
* one of its arguments or have finished its work. Either
|
|
549
|
+
* way, we can unref.
|
|
550
|
+
*/
|
|
551
|
+
g_object_unref(operation);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
void
|
|
555
|
+
VImage::call(const char *operation_name, VOption *options)
|
|
556
|
+
{
|
|
557
|
+
call_option_string(operation_name, nullptr, options);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
VImage
|
|
561
|
+
VImage::new_from_file(const char *name, VOption *options)
|
|
562
|
+
{
|
|
563
|
+
char filename[VIPS_PATH_MAX];
|
|
564
|
+
char option_string[VIPS_PATH_MAX];
|
|
565
|
+
const char *operation_name;
|
|
566
|
+
|
|
567
|
+
VImage out;
|
|
568
|
+
|
|
569
|
+
vips__filename_split8(name, filename, option_string);
|
|
570
|
+
if (!(operation_name = vips_foreign_find_load(filename))) {
|
|
571
|
+
delete options;
|
|
572
|
+
throw VError();
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
call_option_string(operation_name, option_string,
|
|
576
|
+
(options ? options : VImage::option())
|
|
577
|
+
->set("filename", filename)
|
|
578
|
+
->set("out", &out));
|
|
579
|
+
|
|
580
|
+
return out;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
VImage
|
|
584
|
+
VImage::new_from_buffer(const void *buf, size_t len, const char *option_string,
|
|
585
|
+
VOption *options)
|
|
586
|
+
{
|
|
587
|
+
const char *operation_name;
|
|
588
|
+
VipsBlob *blob;
|
|
589
|
+
VImage out;
|
|
590
|
+
|
|
591
|
+
if (!(operation_name = vips_foreign_find_load_buffer(buf, len))) {
|
|
592
|
+
delete options;
|
|
593
|
+
throw(VError());
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/* We don't take a copy of the data or free it.
|
|
597
|
+
*/
|
|
598
|
+
blob = vips_blob_new(nullptr, buf, len);
|
|
599
|
+
options = (options ? options : VImage::option())
|
|
600
|
+
->set("buffer", blob)
|
|
601
|
+
->set("out", &out);
|
|
602
|
+
vips_area_unref(VIPS_AREA(blob));
|
|
603
|
+
|
|
604
|
+
call_option_string(operation_name, option_string, options);
|
|
605
|
+
|
|
606
|
+
return out;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
VImage
|
|
610
|
+
VImage::new_from_buffer(const std::string &buf, const char *option_string,
|
|
611
|
+
VOption *options)
|
|
612
|
+
{
|
|
613
|
+
return new_from_buffer(buf.c_str(), buf.size(),
|
|
614
|
+
option_string, options);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
VImage
|
|
618
|
+
VImage::new_from_source(VSource source, const char *option_string,
|
|
619
|
+
VOption *options)
|
|
620
|
+
{
|
|
621
|
+
const char *operation_name;
|
|
622
|
+
VImage out;
|
|
623
|
+
|
|
624
|
+
if (!(operation_name = vips_foreign_find_load_source(
|
|
625
|
+
source.get_source()))) {
|
|
626
|
+
delete options;
|
|
627
|
+
throw(VError());
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
options = (options ? options : VImage::option())
|
|
631
|
+
->set("source", source)
|
|
632
|
+
->set("out", &out);
|
|
633
|
+
|
|
634
|
+
call_option_string(operation_name, option_string, options);
|
|
635
|
+
|
|
636
|
+
return out;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
VImage
|
|
640
|
+
VImage::new_from_memory_steal(const void *data, size_t size,
|
|
641
|
+
int width, int height, int bands, VipsBandFormat format)
|
|
642
|
+
{
|
|
643
|
+
VipsImage *image;
|
|
644
|
+
|
|
645
|
+
if (!(image = vips_image_new_from_memory(data, size,
|
|
646
|
+
width, height, bands, format)))
|
|
647
|
+
throw(VError());
|
|
648
|
+
|
|
649
|
+
g_signal_connect(image, "postclose",
|
|
650
|
+
G_CALLBACK(vips_image_free_buffer), const_cast<void *>(data));
|
|
651
|
+
|
|
652
|
+
return VImage(image);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
VImage
|
|
656
|
+
VImage::new_matrix(int width, int height)
|
|
657
|
+
{
|
|
658
|
+
return VImage(vips_image_new_matrix(width, height));
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
VImage
|
|
662
|
+
VImage::new_matrixv(int width, int height, ...)
|
|
663
|
+
{
|
|
664
|
+
VImage matrix = new_matrix(width, height);
|
|
665
|
+
VipsImage *vips_matrix = matrix.get_image();
|
|
666
|
+
|
|
667
|
+
va_list ap;
|
|
668
|
+
|
|
669
|
+
va_start(ap, height);
|
|
670
|
+
for (int y = 0; y < height; y++)
|
|
671
|
+
for (int x = 0; x < width; x++)
|
|
672
|
+
*VIPS_MATRIX(vips_matrix, x, y) =
|
|
673
|
+
va_arg(ap, double);
|
|
674
|
+
va_end(ap);
|
|
675
|
+
|
|
676
|
+
return matrix;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
VImage
|
|
680
|
+
VImage::write(VImage out) const
|
|
681
|
+
{
|
|
682
|
+
if (vips_image_write(this->get_image(), out.get_image()))
|
|
683
|
+
throw VError();
|
|
684
|
+
|
|
685
|
+
return out;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
void
|
|
689
|
+
VImage::write_to_file(const char *name, VOption *options) const
|
|
690
|
+
{
|
|
691
|
+
char filename[VIPS_PATH_MAX];
|
|
692
|
+
char option_string[VIPS_PATH_MAX];
|
|
693
|
+
const char *operation_name;
|
|
694
|
+
|
|
695
|
+
vips__filename_split8(name, filename, option_string);
|
|
696
|
+
if (!(operation_name = vips_foreign_find_save(filename))) {
|
|
697
|
+
delete options;
|
|
698
|
+
throw VError();
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
call_option_string(operation_name, option_string,
|
|
702
|
+
(options ? options : VImage::option())
|
|
703
|
+
->set("in", *this)
|
|
704
|
+
->set("filename", filename));
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
void
|
|
708
|
+
VImage::write_to_buffer(const char *suffix, void **buf, size_t *size,
|
|
709
|
+
VOption *options) const
|
|
710
|
+
{
|
|
711
|
+
char filename[VIPS_PATH_MAX];
|
|
712
|
+
char option_string[VIPS_PATH_MAX];
|
|
713
|
+
const char *operation_name;
|
|
714
|
+
VipsBlob *blob;
|
|
715
|
+
|
|
716
|
+
/* Save with the new target API if we can. Fall back to the older
|
|
717
|
+
* mechanism in case the saver we need has not been converted yet.
|
|
718
|
+
*
|
|
719
|
+
* We need to hide any errors from this first phase.
|
|
720
|
+
*/
|
|
721
|
+
vips__filename_split8(suffix, filename, option_string);
|
|
722
|
+
|
|
723
|
+
vips_error_freeze();
|
|
724
|
+
operation_name = vips_foreign_find_save_target(filename);
|
|
725
|
+
vips_error_thaw();
|
|
726
|
+
|
|
727
|
+
if (operation_name) {
|
|
728
|
+
VTarget target = VTarget::new_to_memory();
|
|
729
|
+
|
|
730
|
+
call_option_string(operation_name, option_string,
|
|
731
|
+
(options ? options : VImage::option())
|
|
732
|
+
->set("in", *this)
|
|
733
|
+
->set("target", target));
|
|
734
|
+
|
|
735
|
+
g_object_get(target.get_target(), "blob", &blob, nullptr);
|
|
736
|
+
}
|
|
737
|
+
else if ((operation_name = vips_foreign_find_save_buffer(filename))) {
|
|
738
|
+
call_option_string(operation_name, option_string,
|
|
739
|
+
(options ? options : VImage::option())
|
|
740
|
+
->set("in", *this)
|
|
741
|
+
->set("buffer", &blob));
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
delete options;
|
|
745
|
+
throw VError();
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (blob) {
|
|
749
|
+
if (buf) {
|
|
750
|
+
*buf = VIPS_AREA(blob)->data;
|
|
751
|
+
VIPS_AREA(blob)->free_fn = nullptr;
|
|
752
|
+
}
|
|
753
|
+
if (size)
|
|
754
|
+
*size = VIPS_AREA(blob)->length;
|
|
755
|
+
|
|
756
|
+
vips_area_unref(VIPS_AREA(blob));
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
void
|
|
761
|
+
VImage::write_to_target(const char *suffix, VTarget target,
|
|
762
|
+
VOption *options) const
|
|
763
|
+
{
|
|
764
|
+
char filename[VIPS_PATH_MAX];
|
|
765
|
+
char option_string[VIPS_PATH_MAX];
|
|
766
|
+
const char *operation_name;
|
|
767
|
+
|
|
768
|
+
vips__filename_split8(suffix, filename, option_string);
|
|
769
|
+
if (!(operation_name = vips_foreign_find_save_target(filename))) {
|
|
770
|
+
delete options;
|
|
771
|
+
throw VError();
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
call_option_string(operation_name, option_string,
|
|
775
|
+
(options ? options : VImage::option())
|
|
776
|
+
->set("in", *this)
|
|
777
|
+
->set("target", target));
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
VImage
|
|
781
|
+
VImage::thumbnail_buffer(void *buf, size_t len, int width, VOption *options)
|
|
782
|
+
{
|
|
783
|
+
VipsBlob *blob;
|
|
784
|
+
VImage out;
|
|
785
|
+
|
|
786
|
+
/* We don't take a copy of the data or free it.
|
|
787
|
+
*/
|
|
788
|
+
blob = vips_blob_new(nullptr, buf, len);
|
|
789
|
+
options = (options ? options : VImage::option())->set("buffer", blob)->set("width", width)->set("out", &out);
|
|
790
|
+
vips_area_unref(VIPS_AREA(blob));
|
|
791
|
+
|
|
792
|
+
call("thumbnail_buffer", options);
|
|
793
|
+
|
|
794
|
+
return out;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
VRegion
|
|
798
|
+
VImage::region() const
|
|
799
|
+
{
|
|
800
|
+
return VRegion::new_from_image(*this);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
VRegion
|
|
804
|
+
VImage::region(VipsRect *rect) const
|
|
805
|
+
{
|
|
806
|
+
VRegion region = VRegion::new_from_image(*this);
|
|
807
|
+
|
|
808
|
+
region.prepare(rect);
|
|
809
|
+
|
|
810
|
+
return region;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
VRegion
|
|
814
|
+
VImage::region(int left, int top, int width, int height) const
|
|
815
|
+
{
|
|
816
|
+
VRegion region = VRegion::new_from_image(*this);
|
|
817
|
+
|
|
818
|
+
region.prepare(left, top, width, height);
|
|
819
|
+
|
|
820
|
+
return region;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
#include "vips-operators.cpp"
|
|
824
|
+
|
|
825
|
+
std::vector<VImage>
|
|
826
|
+
VImage::bandsplit(VOption *options) const
|
|
827
|
+
{
|
|
828
|
+
std::vector<VImage> b;
|
|
829
|
+
b.reserve(bands());
|
|
830
|
+
|
|
831
|
+
for (int i = 0; i < bands(); i++)
|
|
832
|
+
b.push_back(extract_band(i));
|
|
833
|
+
|
|
834
|
+
return b;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
VImage
|
|
838
|
+
VImage::bandjoin(VImage other, VOption *options) const
|
|
839
|
+
{
|
|
840
|
+
VImage v[2] = { *this, other };
|
|
841
|
+
std::vector<VImage> vec(v, v + VIPS_NUMBER(v));
|
|
842
|
+
|
|
843
|
+
return bandjoin(vec, options);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
VImage
|
|
847
|
+
VImage::composite(VImage other, VipsBlendMode mode, VOption *options) const
|
|
848
|
+
{
|
|
849
|
+
VImage v[2] = { *this, other };
|
|
850
|
+
std::vector<VImage> ivec(v, v + VIPS_NUMBER(v));
|
|
851
|
+
int m[1] = { static_cast<int>(mode) };
|
|
852
|
+
std::vector<int> mvec(m, m + VIPS_NUMBER(m));
|
|
853
|
+
|
|
854
|
+
return composite(ivec, mvec, options);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
std::complex<double>
|
|
858
|
+
VImage::minpos(VOption *options) const
|
|
859
|
+
{
|
|
860
|
+
double x, y;
|
|
861
|
+
|
|
862
|
+
(void) min(
|
|
863
|
+
(options ? options : VImage::option())
|
|
864
|
+
->set("x", &x)
|
|
865
|
+
->set("y", &y));
|
|
866
|
+
|
|
867
|
+
return std::complex<double>(x, y);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
std::complex<double>
|
|
871
|
+
VImage::maxpos(VOption *options) const
|
|
872
|
+
{
|
|
873
|
+
double x, y;
|
|
874
|
+
|
|
875
|
+
(void) max(
|
|
876
|
+
(options ? options : VImage::option())
|
|
877
|
+
->set("x", &x)
|
|
878
|
+
->set("y", &y));
|
|
879
|
+
|
|
880
|
+
return std::complex<double>(x, y);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// Operator overloads
|
|
884
|
+
|
|
885
|
+
VImage
|
|
886
|
+
VImage::operator[](int index) const
|
|
887
|
+
{
|
|
888
|
+
return this->extract_band(index);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
std::vector<double>
|
|
892
|
+
VImage::operator()(int x, int y) const
|
|
893
|
+
{
|
|
894
|
+
return this->getpoint(x, y);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
VImage
|
|
898
|
+
operator+(const VImage a, const VImage b)
|
|
899
|
+
{
|
|
900
|
+
return a.add(b);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
VImage
|
|
904
|
+
operator+(double a, const VImage b)
|
|
905
|
+
{
|
|
906
|
+
return b.linear(1.0, a);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
VImage
|
|
910
|
+
operator+(const VImage a, double b)
|
|
911
|
+
{
|
|
912
|
+
return a.linear(1.0, b);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
VImage
|
|
916
|
+
operator+(const std::vector<double> a, const VImage b)
|
|
917
|
+
{
|
|
918
|
+
return b.linear(1.0, a);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
VImage
|
|
922
|
+
operator+(const VImage a, const std::vector<double> b)
|
|
923
|
+
{
|
|
924
|
+
return a.linear(1.0, b);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
VImage &
|
|
928
|
+
operator+=(VImage &a, const VImage b)
|
|
929
|
+
{
|
|
930
|
+
a = a + b;
|
|
931
|
+
return a;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
VImage &
|
|
935
|
+
operator+=(VImage &a, const double b)
|
|
936
|
+
{
|
|
937
|
+
a = a + b;
|
|
938
|
+
return a;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
VImage &
|
|
942
|
+
operator+=(VImage &a, const std::vector<double> b)
|
|
943
|
+
{
|
|
944
|
+
a = a + b;
|
|
945
|
+
return a;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
VImage
|
|
949
|
+
operator-(const VImage a, const VImage b)
|
|
950
|
+
{
|
|
951
|
+
return a.subtract(b);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
VImage
|
|
955
|
+
operator-(double a, const VImage b)
|
|
956
|
+
{
|
|
957
|
+
return b.linear(-1.0, a);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
VImage
|
|
961
|
+
operator-(const VImage a, double b)
|
|
962
|
+
{
|
|
963
|
+
return a.linear(1.0, -b);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
VImage
|
|
967
|
+
operator-(const std::vector<double> a, const VImage b)
|
|
968
|
+
{
|
|
969
|
+
return b.linear(-1.0, a);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
VImage
|
|
973
|
+
operator-(const VImage a, const std::vector<double> b)
|
|
974
|
+
{
|
|
975
|
+
return a.linear(1.0, vips::negate(b));
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
VImage &
|
|
979
|
+
operator-=(VImage &a, const VImage b)
|
|
980
|
+
{
|
|
981
|
+
a = a - b;
|
|
982
|
+
return a;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
VImage &
|
|
986
|
+
operator-=(VImage &a, const double b)
|
|
987
|
+
{
|
|
988
|
+
a = a - b;
|
|
989
|
+
return a;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
VImage &
|
|
993
|
+
operator-=(VImage &a, const std::vector<double> b)
|
|
994
|
+
{
|
|
995
|
+
a = a - b;
|
|
996
|
+
return a;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
VImage
|
|
1000
|
+
operator-(const VImage a)
|
|
1001
|
+
{
|
|
1002
|
+
return a * -1;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
VImage
|
|
1006
|
+
operator*(const VImage a, const VImage b)
|
|
1007
|
+
{
|
|
1008
|
+
return a.multiply(b);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
VImage
|
|
1012
|
+
operator*(double a, const VImage b)
|
|
1013
|
+
{
|
|
1014
|
+
return b.linear(a, 0.0);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
VImage
|
|
1018
|
+
operator*(const VImage a, double b)
|
|
1019
|
+
{
|
|
1020
|
+
return a.linear(b, 0.0);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
VImage
|
|
1024
|
+
operator*(const std::vector<double> a, const VImage b)
|
|
1025
|
+
{
|
|
1026
|
+
return b.linear(a, 0.0);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
VImage
|
|
1030
|
+
operator*(const VImage a, const std::vector<double> b)
|
|
1031
|
+
{
|
|
1032
|
+
return a.linear(b, 0.0);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
VImage &
|
|
1036
|
+
operator*=(VImage &a, const VImage b)
|
|
1037
|
+
{
|
|
1038
|
+
a = a * b;
|
|
1039
|
+
return a;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
VImage &
|
|
1043
|
+
operator*=(VImage &a, const double b)
|
|
1044
|
+
{
|
|
1045
|
+
a = a * b;
|
|
1046
|
+
return a;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
VImage &
|
|
1050
|
+
operator*=(VImage &a, const std::vector<double> b)
|
|
1051
|
+
{
|
|
1052
|
+
a = a * b;
|
|
1053
|
+
return a;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
VImage
|
|
1057
|
+
operator/(const VImage a, const VImage b)
|
|
1058
|
+
{
|
|
1059
|
+
return a.divide(b);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
VImage
|
|
1063
|
+
operator/(double a, const VImage b)
|
|
1064
|
+
{
|
|
1065
|
+
return b.pow(-1.0).linear(a, 0.0);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
VImage
|
|
1069
|
+
operator/(const VImage a, double b)
|
|
1070
|
+
{
|
|
1071
|
+
return a.linear(1.0 / b, 0.0);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
VImage
|
|
1075
|
+
operator/(const std::vector<double> a, const VImage b)
|
|
1076
|
+
{
|
|
1077
|
+
return b.pow(-1.0).linear(a, 0.0);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
VImage
|
|
1081
|
+
operator/(const VImage a, const std::vector<double> b)
|
|
1082
|
+
{
|
|
1083
|
+
return a.linear(vips::invert(b), 0.0);
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
VImage &
|
|
1087
|
+
operator/=(VImage &a, const VImage b)
|
|
1088
|
+
{
|
|
1089
|
+
a = a / b;
|
|
1090
|
+
return a;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
VImage &
|
|
1094
|
+
operator/=(VImage &a, const double b)
|
|
1095
|
+
{
|
|
1096
|
+
a = a / b;
|
|
1097
|
+
return a;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
VImage &
|
|
1101
|
+
operator/=(VImage &a, const std::vector<double> b)
|
|
1102
|
+
{
|
|
1103
|
+
a = a / b;
|
|
1104
|
+
return a;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
VImage
|
|
1108
|
+
operator%(const VImage a, const VImage b)
|
|
1109
|
+
{
|
|
1110
|
+
return a.remainder(b);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
VImage
|
|
1114
|
+
operator%(const VImage a, const double b)
|
|
1115
|
+
{
|
|
1116
|
+
return a.remainder_const(to_vector(b));
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
VImage
|
|
1120
|
+
operator%(const VImage a, const std::vector<double> b)
|
|
1121
|
+
{
|
|
1122
|
+
return a.remainder_const(b);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
VImage &
|
|
1126
|
+
operator%=(VImage &a, const VImage b)
|
|
1127
|
+
{
|
|
1128
|
+
a = a % b;
|
|
1129
|
+
return a;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
VImage &
|
|
1133
|
+
operator%=(VImage &a, const double b)
|
|
1134
|
+
{
|
|
1135
|
+
a = a % b;
|
|
1136
|
+
return a;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
VImage &
|
|
1140
|
+
operator%=(VImage &a, const std::vector<double> b)
|
|
1141
|
+
{
|
|
1142
|
+
a = a % b;
|
|
1143
|
+
return a;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
VImage
|
|
1147
|
+
operator<(const VImage a, const VImage b)
|
|
1148
|
+
{
|
|
1149
|
+
return a.relational(b, VIPS_OPERATION_RELATIONAL_LESS);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
VImage
|
|
1153
|
+
operator<(const double a, const VImage b)
|
|
1154
|
+
{
|
|
1155
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_MORE,
|
|
1156
|
+
to_vector(a));
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
VImage
|
|
1160
|
+
operator<(const VImage a, const double b)
|
|
1161
|
+
{
|
|
1162
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_LESS,
|
|
1163
|
+
to_vector(b));
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
VImage
|
|
1167
|
+
operator<(const std::vector<double> a, const VImage b)
|
|
1168
|
+
{
|
|
1169
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_MORE,
|
|
1170
|
+
a);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
VImage
|
|
1174
|
+
operator<(const VImage a, const std::vector<double> b)
|
|
1175
|
+
{
|
|
1176
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_LESS,
|
|
1177
|
+
b);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
VImage
|
|
1181
|
+
operator<=(const VImage a, const VImage b)
|
|
1182
|
+
{
|
|
1183
|
+
return a.relational(b, VIPS_OPERATION_RELATIONAL_LESSEQ);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
VImage
|
|
1187
|
+
operator<=(const double a, const VImage b)
|
|
1188
|
+
{
|
|
1189
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_MOREEQ,
|
|
1190
|
+
to_vector(a));
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
VImage
|
|
1194
|
+
operator<=(const VImage a, const double b)
|
|
1195
|
+
{
|
|
1196
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_LESSEQ,
|
|
1197
|
+
to_vector(b));
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
VImage
|
|
1201
|
+
operator<=(const std::vector<double> a, const VImage b)
|
|
1202
|
+
{
|
|
1203
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_MOREEQ,
|
|
1204
|
+
a);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
VImage
|
|
1208
|
+
operator<=(const VImage a, const std::vector<double> b)
|
|
1209
|
+
{
|
|
1210
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_LESSEQ,
|
|
1211
|
+
b);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
VImage
|
|
1215
|
+
operator>(const VImage a, const VImage b)
|
|
1216
|
+
{
|
|
1217
|
+
return a.relational(b, VIPS_OPERATION_RELATIONAL_MORE);
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
VImage
|
|
1221
|
+
operator>(const double a, const VImage b)
|
|
1222
|
+
{
|
|
1223
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_LESS,
|
|
1224
|
+
to_vector(a));
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
VImage
|
|
1228
|
+
operator>(const VImage a, const double b)
|
|
1229
|
+
{
|
|
1230
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_MORE,
|
|
1231
|
+
to_vector(b));
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
VImage
|
|
1235
|
+
operator>(const std::vector<double> a, const VImage b)
|
|
1236
|
+
{
|
|
1237
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_LESS,
|
|
1238
|
+
a);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
VImage
|
|
1242
|
+
operator>(const VImage a, const std::vector<double> b)
|
|
1243
|
+
{
|
|
1244
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_MORE,
|
|
1245
|
+
b);
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
VImage
|
|
1249
|
+
operator>=(const VImage a, const VImage b)
|
|
1250
|
+
{
|
|
1251
|
+
return a.relational(b, VIPS_OPERATION_RELATIONAL_MOREEQ);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
VImage
|
|
1255
|
+
operator>=(const double a, const VImage b)
|
|
1256
|
+
{
|
|
1257
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_LESSEQ,
|
|
1258
|
+
to_vector(a));
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
VImage
|
|
1262
|
+
operator>=(const VImage a, const double b)
|
|
1263
|
+
{
|
|
1264
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_MOREEQ,
|
|
1265
|
+
to_vector(b));
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
VImage
|
|
1269
|
+
operator>=(const std::vector<double> a, const VImage b)
|
|
1270
|
+
{
|
|
1271
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_LESSEQ,
|
|
1272
|
+
a);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
VImage
|
|
1276
|
+
operator>=(const VImage a, const std::vector<double> b)
|
|
1277
|
+
{
|
|
1278
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_MOREEQ,
|
|
1279
|
+
b);
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
VImage
|
|
1283
|
+
operator==(const VImage a, const VImage b)
|
|
1284
|
+
{
|
|
1285
|
+
return a.relational(b, VIPS_OPERATION_RELATIONAL_EQUAL);
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
VImage
|
|
1289
|
+
operator==(const double a, const VImage b)
|
|
1290
|
+
{
|
|
1291
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_EQUAL,
|
|
1292
|
+
to_vector(a));
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
VImage
|
|
1296
|
+
operator==(const VImage a, const double b)
|
|
1297
|
+
{
|
|
1298
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_EQUAL,
|
|
1299
|
+
to_vector(b));
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
VImage
|
|
1303
|
+
operator==(const std::vector<double> a, const VImage b)
|
|
1304
|
+
{
|
|
1305
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_EQUAL,
|
|
1306
|
+
a);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
VImage
|
|
1310
|
+
operator==(const VImage a, const std::vector<double> b)
|
|
1311
|
+
{
|
|
1312
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_EQUAL,
|
|
1313
|
+
b);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
VImage
|
|
1317
|
+
operator!=(const VImage a, const VImage b)
|
|
1318
|
+
{
|
|
1319
|
+
return a.relational(b, VIPS_OPERATION_RELATIONAL_NOTEQ);
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
VImage
|
|
1323
|
+
operator!=(const double a, const VImage b)
|
|
1324
|
+
{
|
|
1325
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_NOTEQ,
|
|
1326
|
+
to_vector(a));
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
VImage
|
|
1330
|
+
operator!=(const VImage a, const double b)
|
|
1331
|
+
{
|
|
1332
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_NOTEQ,
|
|
1333
|
+
to_vector(b));
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
VImage
|
|
1337
|
+
operator!=(const std::vector<double> a, const VImage b)
|
|
1338
|
+
{
|
|
1339
|
+
return b.relational_const(VIPS_OPERATION_RELATIONAL_NOTEQ,
|
|
1340
|
+
a);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
VImage
|
|
1344
|
+
operator!=(const VImage a, const std::vector<double> b)
|
|
1345
|
+
{
|
|
1346
|
+
return a.relational_const(VIPS_OPERATION_RELATIONAL_NOTEQ,
|
|
1347
|
+
b);
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
VImage
|
|
1351
|
+
operator&(const VImage a, const VImage b)
|
|
1352
|
+
{
|
|
1353
|
+
return a.boolean(b, VIPS_OPERATION_BOOLEAN_AND);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
VImage
|
|
1357
|
+
operator&(const double a, const VImage b)
|
|
1358
|
+
{
|
|
1359
|
+
return b.boolean_const(VIPS_OPERATION_BOOLEAN_AND,
|
|
1360
|
+
to_vector(a));
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
VImage
|
|
1364
|
+
operator&(const VImage a, const double b)
|
|
1365
|
+
{
|
|
1366
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_AND,
|
|
1367
|
+
to_vector(b));
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
VImage
|
|
1371
|
+
operator&(const std::vector<double> a, const VImage b)
|
|
1372
|
+
{
|
|
1373
|
+
return b.boolean_const(VIPS_OPERATION_BOOLEAN_AND, a);
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
VImage
|
|
1377
|
+
operator&(const VImage a, const std::vector<double> b)
|
|
1378
|
+
{
|
|
1379
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_AND, b);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
VImage &
|
|
1383
|
+
operator&=(VImage &a, const VImage b)
|
|
1384
|
+
{
|
|
1385
|
+
a = a & b;
|
|
1386
|
+
return a;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
VImage &
|
|
1390
|
+
operator&=(VImage &a, const double b)
|
|
1391
|
+
{
|
|
1392
|
+
a = a & b;
|
|
1393
|
+
return a;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
VImage &
|
|
1397
|
+
operator&=(VImage &a, const std::vector<double> b)
|
|
1398
|
+
{
|
|
1399
|
+
a = a & b;
|
|
1400
|
+
return a;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
VImage
|
|
1404
|
+
operator|(const VImage a, const VImage b)
|
|
1405
|
+
{
|
|
1406
|
+
return a.boolean(b, VIPS_OPERATION_BOOLEAN_OR);
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
VImage
|
|
1410
|
+
operator|(const double a, const VImage b)
|
|
1411
|
+
{
|
|
1412
|
+
return b.boolean_const(VIPS_OPERATION_BOOLEAN_OR,
|
|
1413
|
+
to_vector(a));
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
VImage
|
|
1417
|
+
operator|(const VImage a, const double b)
|
|
1418
|
+
{
|
|
1419
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_OR,
|
|
1420
|
+
to_vector(b));
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
VImage
|
|
1424
|
+
operator|(const std::vector<double> a, const VImage b)
|
|
1425
|
+
{
|
|
1426
|
+
return b.boolean_const(VIPS_OPERATION_BOOLEAN_OR,
|
|
1427
|
+
a);
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
VImage
|
|
1431
|
+
operator|(const VImage a, const std::vector<double> b)
|
|
1432
|
+
{
|
|
1433
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_OR,
|
|
1434
|
+
b);
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
VImage &
|
|
1438
|
+
operator|=(VImage &a, const VImage b)
|
|
1439
|
+
{
|
|
1440
|
+
a = a | b;
|
|
1441
|
+
return a;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
VImage &
|
|
1445
|
+
operator|=(VImage &a, const double b)
|
|
1446
|
+
{
|
|
1447
|
+
a = a | b;
|
|
1448
|
+
return a;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
VImage &
|
|
1452
|
+
operator|=(VImage &a, const std::vector<double> b)
|
|
1453
|
+
{
|
|
1454
|
+
a = a | b;
|
|
1455
|
+
return a;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
VImage
|
|
1459
|
+
operator^(const VImage a, const VImage b)
|
|
1460
|
+
{
|
|
1461
|
+
return a.boolean(b, VIPS_OPERATION_BOOLEAN_EOR);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
VImage
|
|
1465
|
+
operator^(const double a, const VImage b)
|
|
1466
|
+
{
|
|
1467
|
+
return b.boolean_const(VIPS_OPERATION_BOOLEAN_EOR,
|
|
1468
|
+
to_vector(a));
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
VImage
|
|
1472
|
+
operator^(const VImage a, const double b)
|
|
1473
|
+
{
|
|
1474
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_EOR,
|
|
1475
|
+
to_vector(b));
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
VImage
|
|
1479
|
+
operator^(const std::vector<double> a, const VImage b)
|
|
1480
|
+
{
|
|
1481
|
+
return b.boolean_const(VIPS_OPERATION_BOOLEAN_EOR,
|
|
1482
|
+
a);
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
VImage
|
|
1486
|
+
operator^(const VImage a, const std::vector<double> b)
|
|
1487
|
+
{
|
|
1488
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_EOR,
|
|
1489
|
+
b);
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
VImage &
|
|
1493
|
+
operator^=(VImage &a, const VImage b)
|
|
1494
|
+
{
|
|
1495
|
+
a = a ^ b;
|
|
1496
|
+
return a;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
VImage &
|
|
1500
|
+
operator^=(VImage &a, const double b)
|
|
1501
|
+
{
|
|
1502
|
+
a = a ^ b;
|
|
1503
|
+
return a;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
VImage &
|
|
1507
|
+
operator^=(VImage &a, const std::vector<double> b)
|
|
1508
|
+
{
|
|
1509
|
+
a = a ^ b;
|
|
1510
|
+
return a;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
VImage
|
|
1514
|
+
operator<<(const VImage a, const VImage b)
|
|
1515
|
+
{
|
|
1516
|
+
return a.boolean(b, VIPS_OPERATION_BOOLEAN_LSHIFT);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
VImage
|
|
1520
|
+
operator<<(const VImage a, const double b)
|
|
1521
|
+
{
|
|
1522
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_LSHIFT,
|
|
1523
|
+
to_vector(b));
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
VImage
|
|
1527
|
+
operator<<(const VImage a, const std::vector<double> b)
|
|
1528
|
+
{
|
|
1529
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_LSHIFT,
|
|
1530
|
+
b);
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
VImage &
|
|
1534
|
+
operator<<=(VImage &a, const VImage b)
|
|
1535
|
+
{
|
|
1536
|
+
a = a << b;
|
|
1537
|
+
return a;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
VImage &
|
|
1541
|
+
operator<<=(VImage &a, const double b)
|
|
1542
|
+
{
|
|
1543
|
+
a = a << b;
|
|
1544
|
+
return a;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
VImage &
|
|
1548
|
+
operator<<=(VImage &a, const std::vector<double> b)
|
|
1549
|
+
{
|
|
1550
|
+
a = a << b;
|
|
1551
|
+
return a;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
VImage
|
|
1555
|
+
operator>>(const VImage a, const VImage b)
|
|
1556
|
+
{
|
|
1557
|
+
return a.boolean(b, VIPS_OPERATION_BOOLEAN_RSHIFT);
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
VImage
|
|
1561
|
+
operator>>(const VImage a, const double b)
|
|
1562
|
+
{
|
|
1563
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_RSHIFT,
|
|
1564
|
+
to_vector(b));
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
VImage
|
|
1568
|
+
operator>>(const VImage a, const std::vector<double> b)
|
|
1569
|
+
{
|
|
1570
|
+
return a.boolean_const(VIPS_OPERATION_BOOLEAN_RSHIFT,
|
|
1571
|
+
b);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
VImage &
|
|
1575
|
+
operator>>=(VImage &a, const VImage b)
|
|
1576
|
+
{
|
|
1577
|
+
a = a << b;
|
|
1578
|
+
return a;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
VImage &
|
|
1582
|
+
operator>>=(VImage &a, const double b)
|
|
1583
|
+
{
|
|
1584
|
+
a = a << b;
|
|
1585
|
+
return a;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
VImage &
|
|
1589
|
+
operator>>=(VImage &a, const std::vector<double> b)
|
|
1590
|
+
{
|
|
1591
|
+
a = a << b;
|
|
1592
|
+
return a;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
// Compat operations
|
|
1596
|
+
|
|
1597
|
+
VImage
|
|
1598
|
+
VImage::new_from_memory_steal(void *data, size_t size,
|
|
1599
|
+
int width, int height, int bands, VipsBandFormat format)
|
|
1600
|
+
{
|
|
1601
|
+
return new_from_memory_steal(static_cast<const void *>(data), size,
|
|
1602
|
+
width, height, bands, format);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
void
|
|
1606
|
+
VImage::rawsave_fd(int fd, VOption *options) const
|
|
1607
|
+
{
|
|
1608
|
+
rawsave_target(VTarget::new_to_descriptor(fd), options);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
VIPS_NAMESPACE_END
|