sharp 0.32.6 → 0.33.0-alpha.11

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.
@@ -1,1548 +0,0 @@
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, NULL,
217
- static_cast< int >( value.size() ) );
218
- array = vips_value_get_array_int( &pair->value, NULL );
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, NULL,
240
- static_cast< int >( value.size() ) );
241
- array = vips_value_get_array_double( &pair->value, NULL );
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, NULL );
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 = { 0 };
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, NULL, 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( NULL, 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( 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 ), 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, (void *) NULL );
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 = NULL;
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
- VRegion
781
- VImage::region() const
782
- {
783
- return VRegion::new_from_image( *this );
784
- }
785
-
786
- VRegion
787
- VImage::region( VipsRect *rect ) const
788
- {
789
- VRegion region = VRegion::new_from_image( *this );
790
-
791
- region.prepare( rect );
792
-
793
- return region;
794
- }
795
-
796
- VRegion
797
- VImage::region( int left, int top, int width, int height ) const
798
- {
799
- VRegion region = VRegion::new_from_image( *this );
800
-
801
- region.prepare( left, top, width, height );
802
-
803
- return region;
804
- }
805
-
806
- #include "vips-operators.cpp"
807
-
808
- std::vector<VImage>
809
- VImage::bandsplit( VOption *options ) const
810
- {
811
- std::vector<VImage> b;
812
- b.reserve(bands());
813
-
814
- for( int i = 0; i < bands(); i++ )
815
- b.push_back( extract_band( i ) );
816
-
817
- return( b );
818
- }
819
-
820
- VImage
821
- VImage::bandjoin( VImage other, VOption *options ) const
822
- {
823
- VImage v[2] = { *this, other };
824
- std::vector<VImage> vec( v, v + VIPS_NUMBER( v ) );
825
-
826
- return( bandjoin( vec, options ) );
827
- }
828
-
829
- VImage
830
- VImage::composite( VImage other, VipsBlendMode mode, VOption *options ) const
831
- {
832
- VImage v[2] = { *this, other };
833
- std::vector<VImage> ivec( v, v + VIPS_NUMBER( v ) );
834
- int m[1] = { static_cast<int>( mode ) };
835
- std::vector<int> mvec( m, m + VIPS_NUMBER( m ) );
836
-
837
- return( composite( ivec, mvec, options ) );
838
- }
839
-
840
- std::complex<double>
841
- VImage::minpos( VOption *options ) const
842
- {
843
- double x, y;
844
-
845
- (void) min(
846
- (options ? options : VImage::option()) ->
847
- set( "x", &x ) ->
848
- set( "y", &y ) );
849
-
850
- return( std::complex<double>( x, y ) );
851
- }
852
-
853
- std::complex<double>
854
- VImage::maxpos( VOption *options ) const
855
- {
856
- double x, y;
857
-
858
- (void) max(
859
- (options ? options : VImage::option()) ->
860
- set( "x", &x ) ->
861
- set( "y", &y ) );
862
-
863
- return( std::complex<double>( x, y ) );
864
- }
865
-
866
- // Operator overloads
867
-
868
- VImage
869
- VImage::operator[]( int index ) const
870
- {
871
- return( this->extract_band( index ) );
872
- }
873
-
874
- std::vector<double>
875
- VImage::operator()( int x, int y ) const
876
- {
877
- return( this->getpoint( x, y ) );
878
- }
879
-
880
- VImage
881
- operator+( const VImage a, const VImage b )
882
- {
883
- return( a.add( b ) );
884
- }
885
-
886
- VImage
887
- operator+( double a, const VImage b )
888
- {
889
- return( b.linear( 1.0, a ) );
890
- }
891
-
892
- VImage
893
- operator+( const VImage a, double b )
894
- {
895
- return( a.linear( 1.0, b ) );
896
- }
897
-
898
- VImage
899
- operator+( const std::vector<double> a, const VImage b )
900
- {
901
- return( b.linear( 1.0, a ) );
902
- }
903
-
904
- VImage
905
- operator+( const VImage a, const std::vector<double> b )
906
- {
907
- return( a.linear( 1.0, b ) );
908
- }
909
-
910
- VImage &
911
- operator+=( VImage &a, const VImage b )
912
- {
913
- return( a = a + b );
914
- }
915
-
916
- VImage &
917
- operator+=( VImage &a, const double b )
918
- {
919
- return( a = a + b );
920
- }
921
-
922
- VImage &
923
- operator+=( VImage &a, const std::vector<double> b )
924
- {
925
- return( a = a + b );
926
- }
927
-
928
- VImage
929
- operator-( const VImage a, const VImage b )
930
- {
931
- return( a.subtract( b ) );
932
- }
933
-
934
- VImage
935
- operator-( double a, const VImage b )
936
- {
937
- return( b.linear( -1.0, a ) );
938
- }
939
-
940
- VImage
941
- operator-( const VImage a, double b )
942
- {
943
- return( a.linear( 1.0, -b ) );
944
- }
945
-
946
- VImage
947
- operator-( const std::vector<double> a, const VImage b )
948
- {
949
- return( b.linear( -1.0, a ) );
950
- }
951
-
952
- VImage
953
- operator-( const VImage a, const std::vector<double> b )
954
- {
955
- return( a.linear( 1.0, vips::negate( b ) ) );
956
- }
957
-
958
- VImage &
959
- operator-=( VImage &a, const VImage b )
960
- {
961
- return( a = a - b );
962
- }
963
-
964
- VImage &
965
- operator-=( VImage &a, const double b )
966
- {
967
- return( a = a - b );
968
- }
969
-
970
- VImage &
971
- operator-=( VImage &a, const std::vector<double> b )
972
- {
973
- return( a = a - b );
974
- }
975
-
976
- VImage
977
- operator-( const VImage a )
978
- {
979
- return( a * -1 );
980
- }
981
-
982
- VImage
983
- operator*( const VImage a, const VImage b )
984
- {
985
- return( a.multiply( b ) );
986
- }
987
-
988
- VImage
989
- operator*( double a, const VImage b )
990
- {
991
- return( b.linear( a, 0.0 ) );
992
- }
993
-
994
- VImage
995
- operator*( const VImage a, double b )
996
- {
997
- return( a.linear( b, 0.0 ) );
998
- }
999
-
1000
- VImage
1001
- operator*( const std::vector<double> a, const VImage b )
1002
- {
1003
- return( b.linear( a, 0.0 ) );
1004
- }
1005
-
1006
- VImage
1007
- operator*( const VImage a, const std::vector<double> b )
1008
- {
1009
- return( a.linear( b, 0.0 ) );
1010
- }
1011
-
1012
- VImage &
1013
- operator*=( VImage &a, const VImage b )
1014
- {
1015
- return( a = a * b );
1016
- }
1017
-
1018
- VImage &
1019
- operator*=( VImage &a, const double b )
1020
- {
1021
- return( a = a * b );
1022
- }
1023
-
1024
- VImage &
1025
- operator*=( VImage &a, const std::vector<double> b )
1026
- {
1027
- return( a = a * b );
1028
- }
1029
-
1030
- VImage
1031
- operator/( const VImage a, const VImage b )
1032
- {
1033
- return( a.divide( b ) );
1034
- }
1035
-
1036
- VImage
1037
- operator/( double a, const VImage b )
1038
- {
1039
- return( b.pow( -1.0 ).linear( a, 0.0 ) );
1040
- }
1041
-
1042
- VImage
1043
- operator/( const VImage a, double b )
1044
- {
1045
- return( a.linear( 1.0 / b, 0.0 ) );
1046
- }
1047
-
1048
- VImage
1049
- operator/( const std::vector<double> a, const VImage b )
1050
- {
1051
- return( b.pow( -1.0 ).linear( a, 0.0 ) );
1052
- }
1053
-
1054
- VImage
1055
- operator/( const VImage a, const std::vector<double> b )
1056
- {
1057
- return( a.linear( vips::invert( b ), 0.0 ) );
1058
- }
1059
-
1060
- VImage &
1061
- operator/=( VImage &a, const VImage b )
1062
- {
1063
- return( a = a / b );
1064
- }
1065
-
1066
- VImage &
1067
- operator/=( VImage &a, const double b )
1068
- {
1069
- return( a = a / b );
1070
- }
1071
-
1072
- VImage &
1073
- operator/=( VImage &a, const std::vector<double> b )
1074
- {
1075
- return( a = a / b );
1076
- }
1077
-
1078
- VImage
1079
- operator%( const VImage a, const VImage b )
1080
- {
1081
- return( a.remainder( b ) );
1082
- }
1083
-
1084
- VImage
1085
- operator%( const VImage a, const double b )
1086
- {
1087
- return( a.remainder_const( to_vector( b ) ) );
1088
- }
1089
-
1090
- VImage
1091
- operator%( const VImage a, const std::vector<double> b )
1092
- {
1093
- return( a.remainder_const( b ) );
1094
- }
1095
-
1096
- VImage &
1097
- operator%=( VImage &a, const VImage b )
1098
- {
1099
- return( a = a % b );
1100
- }
1101
-
1102
- VImage &
1103
- operator%=( VImage &a, const double b )
1104
- {
1105
- return( a = a % b );
1106
- }
1107
-
1108
- VImage &
1109
- operator%=( VImage &a, const std::vector<double> b )
1110
- {
1111
- return( a = a % b );
1112
- }
1113
-
1114
- VImage
1115
- operator<( const VImage a, const VImage b )
1116
- {
1117
- return( a.relational( b, VIPS_OPERATION_RELATIONAL_LESS ) );
1118
- }
1119
-
1120
- VImage
1121
- operator<( const double a, const VImage b )
1122
- {
1123
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE,
1124
- to_vector( a ) ) );
1125
- }
1126
-
1127
- VImage
1128
- operator<( const VImage a, const double b )
1129
- {
1130
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS,
1131
- to_vector( b ) ) );
1132
- }
1133
-
1134
- VImage
1135
- operator<( const std::vector<double> a, const VImage b )
1136
- {
1137
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_MORE,
1138
- a ) );
1139
- }
1140
-
1141
- VImage
1142
- operator<( const VImage a, const std::vector<double> b )
1143
- {
1144
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESS,
1145
- b ) );
1146
- }
1147
-
1148
- VImage
1149
- operator<=( const VImage a, const VImage b )
1150
- {
1151
- return( a.relational( b, VIPS_OPERATION_RELATIONAL_LESSEQ ) );
1152
- }
1153
-
1154
- VImage
1155
- operator<=( const double a, const VImage b )
1156
- {
1157
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ,
1158
- to_vector( a ) ) );
1159
- }
1160
-
1161
- VImage
1162
- operator<=( const VImage a, const double b )
1163
- {
1164
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ,
1165
- to_vector( b ) ) );
1166
- }
1167
-
1168
- VImage
1169
- operator<=( const std::vector<double> a, const VImage b )
1170
- {
1171
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ,
1172
- a ) );
1173
- }
1174
-
1175
- VImage
1176
- operator<=( const VImage a, const std::vector<double> b )
1177
- {
1178
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ,
1179
- b ) );
1180
- }
1181
-
1182
- VImage
1183
- operator>( const VImage a, const VImage b )
1184
- {
1185
- return( a.relational( b, VIPS_OPERATION_RELATIONAL_MORE ) );
1186
- }
1187
-
1188
- VImage
1189
- operator>( const double a, const VImage b )
1190
- {
1191
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS,
1192
- to_vector( a ) ) );
1193
- }
1194
-
1195
- VImage
1196
- operator>( const VImage a, const double b )
1197
- {
1198
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE,
1199
- to_vector( b ) ) );
1200
- }
1201
-
1202
- VImage
1203
- operator>( const std::vector<double> a, const VImage b )
1204
- {
1205
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESS,
1206
- a ) );
1207
- }
1208
-
1209
- VImage
1210
- operator>( const VImage a, const std::vector<double> b )
1211
- {
1212
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_MORE,
1213
- b ) );
1214
- }
1215
-
1216
- VImage
1217
- operator>=( const VImage a, const VImage b )
1218
- {
1219
- return( a.relational( b, VIPS_OPERATION_RELATIONAL_MOREEQ ) );
1220
- }
1221
-
1222
- VImage
1223
- operator>=( const double a, const VImage b )
1224
- {
1225
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ,
1226
- to_vector( a ) ) );
1227
- }
1228
-
1229
- VImage
1230
- operator>=( const VImage a, const double b )
1231
- {
1232
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ,
1233
- to_vector( b ) ) );
1234
- }
1235
-
1236
- VImage
1237
- operator>=( const std::vector<double> a, const VImage b )
1238
- {
1239
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_LESSEQ,
1240
- a ) );
1241
- }
1242
-
1243
- VImage
1244
- operator>=( const VImage a, const std::vector<double> b )
1245
- {
1246
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_MOREEQ,
1247
- b ) );
1248
- }
1249
-
1250
- VImage
1251
- operator==( const VImage a, const VImage b )
1252
- {
1253
- return( a.relational( b, VIPS_OPERATION_RELATIONAL_EQUAL ) );
1254
- }
1255
-
1256
- VImage
1257
- operator==( const double a, const VImage b )
1258
- {
1259
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL,
1260
- to_vector( a ) ) );
1261
- }
1262
-
1263
- VImage
1264
- operator==( const VImage a, const double b )
1265
- {
1266
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL,
1267
- to_vector( b ) ) );
1268
- }
1269
-
1270
- VImage
1271
- operator==( const std::vector<double> a, const VImage b )
1272
- {
1273
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL,
1274
- a ) );
1275
- }
1276
-
1277
- VImage
1278
- operator==( const VImage a, const std::vector<double> b )
1279
- {
1280
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_EQUAL,
1281
- b ) );
1282
- }
1283
-
1284
- VImage
1285
- operator!=( const VImage a, const VImage b )
1286
- {
1287
- return( a.relational( b, VIPS_OPERATION_RELATIONAL_NOTEQ ) );
1288
- }
1289
-
1290
- VImage
1291
- operator!=( const double a, const VImage b )
1292
- {
1293
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ,
1294
- to_vector( a ) ) );
1295
- }
1296
-
1297
- VImage
1298
- operator!=( const VImage a, const double b )
1299
- {
1300
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ,
1301
- to_vector( b ) ) );
1302
- }
1303
-
1304
- VImage
1305
- operator!=( const std::vector<double> a, const VImage b )
1306
- {
1307
- return( b.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ,
1308
- a ) );
1309
- }
1310
-
1311
- VImage
1312
- operator!=( const VImage a, const std::vector<double> b )
1313
- {
1314
- return( a.relational_const( VIPS_OPERATION_RELATIONAL_NOTEQ,
1315
- b ) );
1316
- }
1317
-
1318
- VImage
1319
- operator&( const VImage a, const VImage b )
1320
- {
1321
- return( a.boolean( b, VIPS_OPERATION_BOOLEAN_AND ) );
1322
- }
1323
-
1324
- VImage
1325
- operator&( const double a, const VImage b )
1326
- {
1327
- return( b.boolean_const( VIPS_OPERATION_BOOLEAN_AND,
1328
- to_vector( a ) ) );
1329
- }
1330
-
1331
- VImage
1332
- operator&( const VImage a, const double b )
1333
- {
1334
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_AND,
1335
- to_vector( b ) ) );
1336
- }
1337
-
1338
- VImage
1339
- operator&( const std::vector<double> a, const VImage b )
1340
- {
1341
- return( b.boolean_const( VIPS_OPERATION_BOOLEAN_AND, a ) );
1342
- }
1343
-
1344
- VImage
1345
- operator&( const VImage a, const std::vector<double> b )
1346
- {
1347
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_AND, b ) );
1348
- }
1349
-
1350
- VImage &
1351
- operator&=( VImage &a, const VImage b )
1352
- {
1353
- return( a = a & b );
1354
- }
1355
-
1356
- VImage &
1357
- operator&=( VImage &a, const double b )
1358
- {
1359
- return( a = a & b );
1360
- }
1361
-
1362
- VImage &
1363
- operator&=( VImage &a, const std::vector<double> b )
1364
- {
1365
- return( a = a & b );
1366
- }
1367
-
1368
- VImage
1369
- operator|( const VImage a, const VImage b )
1370
- {
1371
- return( a.boolean( b, VIPS_OPERATION_BOOLEAN_OR ) );
1372
- }
1373
-
1374
- VImage
1375
- operator|( const double a, const VImage b )
1376
- {
1377
- return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR,
1378
- to_vector( a ) ) );
1379
- }
1380
-
1381
- VImage
1382
- operator|( const VImage a, const double b )
1383
- {
1384
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR,
1385
- to_vector( b ) ) );
1386
- }
1387
-
1388
- VImage
1389
- operator|( const std::vector<double> a, const VImage b )
1390
- {
1391
- return( b.boolean_const( VIPS_OPERATION_BOOLEAN_OR,
1392
- a ) );
1393
- }
1394
-
1395
- VImage
1396
- operator|( const VImage a, const std::vector<double> b )
1397
- {
1398
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_OR,
1399
- b ) );
1400
- }
1401
-
1402
- VImage &
1403
- operator|=( VImage &a, const VImage b )
1404
- {
1405
- return( a = a | b );
1406
- }
1407
-
1408
- VImage &
1409
- operator|=( VImage &a, const double b )
1410
- {
1411
- return( a = a | b );
1412
- }
1413
-
1414
- VImage &
1415
- operator|=( VImage &a, const std::vector<double> b )
1416
- {
1417
- return( a = a | b );
1418
- }
1419
-
1420
- VImage
1421
- operator^( const VImage a, const VImage b )
1422
- {
1423
- return( a.boolean( b, VIPS_OPERATION_BOOLEAN_EOR ) );
1424
- }
1425
-
1426
- VImage
1427
- operator^( const double a, const VImage b )
1428
- {
1429
- return( b.boolean_const( VIPS_OPERATION_BOOLEAN_EOR,
1430
- to_vector( a ) ) );
1431
- }
1432
-
1433
- VImage
1434
- operator^( const VImage a, const double b )
1435
- {
1436
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_EOR,
1437
- to_vector( b ) ) );
1438
- }
1439
-
1440
- VImage
1441
- operator^( const std::vector<double> a, const VImage b )
1442
- {
1443
- return( b.boolean_const( VIPS_OPERATION_BOOLEAN_EOR,
1444
- a ) );
1445
- }
1446
-
1447
- VImage
1448
- operator^( const VImage a, const std::vector<double> b )
1449
- {
1450
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_EOR,
1451
- b ) );
1452
- }
1453
-
1454
- VImage &
1455
- operator^=( VImage &a, const VImage b )
1456
- {
1457
- return( a = a ^ b );
1458
- }
1459
-
1460
- VImage &
1461
- operator^=( VImage &a, const double b )
1462
- {
1463
- return( a = a ^ b );
1464
- }
1465
-
1466
- VImage &
1467
- operator^=( VImage &a, const std::vector<double> b )
1468
- {
1469
- return( a = a ^ b );
1470
- }
1471
-
1472
- VImage
1473
- operator<<( const VImage a, const VImage b )
1474
- {
1475
- return( a.boolean( b, VIPS_OPERATION_BOOLEAN_LSHIFT ) );
1476
- }
1477
-
1478
- VImage
1479
- operator<<( const VImage a, const double b )
1480
- {
1481
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT,
1482
- to_vector( b ) ) );
1483
- }
1484
-
1485
- VImage
1486
- operator<<( const VImage a, const std::vector<double> b )
1487
- {
1488
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_LSHIFT,
1489
- b ) );
1490
- }
1491
-
1492
- VImage &
1493
- operator<<=( VImage &a, const VImage b )
1494
- {
1495
- return( a = a << b );
1496
- }
1497
-
1498
- VImage &
1499
- operator<<=( VImage &a, const double b )
1500
- {
1501
- return( a = a << b );
1502
- }
1503
-
1504
- VImage &
1505
- operator<<=( VImage &a, const std::vector<double> b )
1506
- {
1507
- return( a = a << b );
1508
- }
1509
-
1510
- VImage
1511
- operator>>( const VImage a, const VImage b )
1512
- {
1513
- return( a.boolean( b, VIPS_OPERATION_BOOLEAN_RSHIFT ) );
1514
- }
1515
-
1516
- VImage
1517
- operator>>( const VImage a, const double b )
1518
- {
1519
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_RSHIFT,
1520
- to_vector( b ) ) );
1521
- }
1522
-
1523
- VImage
1524
- operator>>( const VImage a, const std::vector<double> b )
1525
- {
1526
- return( a.boolean_const( VIPS_OPERATION_BOOLEAN_RSHIFT,
1527
- b ) );
1528
- }
1529
-
1530
- VImage &
1531
- operator>>=( VImage &a, const VImage b )
1532
- {
1533
- return( a = a << b );
1534
- }
1535
-
1536
- VImage &
1537
- operator>>=( VImage &a, const double b )
1538
- {
1539
- return( a = a << b );
1540
- }
1541
-
1542
- VImage &
1543
- operator>>=( VImage &a, const std::vector<double> b )
1544
- {
1545
- return( a = a << b );
1546
- }
1547
-
1548
- VIPS_NAMESPACE_END