~ubuntu-branches/ubuntu/saucy/vips/saucy

« back to all changes in this revision

Viewing changes to libvips/iofuncs/dispatch_types.c

  • Committer: Bazaar Package Importer
  • Author(s): Jay Berkenbilt
  • Date: 2010-12-27 14:24:43 UTC
  • mfrom: (1.1.14 upstream) (2.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20101227142443-2o2fwf24zy0wkdo8
Tags: 7.24.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * Modified:
6
6
 * 21/5/07
7
7
 *      - any length vector (Tom)
 
8
 * 23/8/10
 
9
 *      - add IM_TYPE_RW flag for im__rw_image
8
10
 */
9
11
 
10
12
/*
87
89
/* Input display type.
88
90
 */
89
91
im_type_desc im__input_display = {
90
 
        IM_TYPE_DISPLAY,        /* Its a display */
91
 
        0,                      /* No storage needed */
92
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
93
 
        input_display_init,     /* Init function */
94
 
        NULL                    /* Destroy function */
 
92
        IM_TYPE_DISPLAY,                /* It's a display */
 
93
        0,                              /* No storage needed */
 
94
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
95
        input_display_init,             /* Init function */
 
96
        NULL                            /* Destroy function */
95
97
};
96
98
 
97
99
/* Output display type.
98
100
 */
99
101
im_type_desc im__output_display = {
100
 
        IM_TYPE_DISPLAY,        /* Its a display */
 
102
        IM_TYPE_DISPLAY,                /* It's a display */
101
103
        sizeof( struct im_col_display ),/* Memory to allocate */
102
 
        IM_TYPE_OUTPUT,         /* Output object */
103
 
        NULL,                   /* Init function */
104
 
        NULL                    /* Destroy function */
 
104
        IM_TYPE_OUTPUT,                 /* Output object */
 
105
        NULL,                           /* Init function */
 
106
        NULL                            /* Destroy function */
105
107
};
106
108
 
107
109
/* Init function for input images.
111
113
{
112
114
        IMAGE **im = (IMAGE **) obj;
113
115
 
114
 
        return( !(*im = im_open( str, "r" )) );
 
116
        return( !(*im = im_open( str, "rd" )) );
115
117
}
116
118
 
117
119
/* Input image type.
118
120
 */
119
121
im_type_desc im__input_image = {
120
 
        IM_TYPE_IMAGE,          /* Its an image */
121
 
        0,                      /* No storage needed */
122
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
 
122
        IM_TYPE_IMAGE,                  /* It's an image */
 
123
        0,                              /* No storage needed */
 
124
        IM_TYPE_ARG,                    /* It requires a command-line arg */
123
125
        (im_init_obj_fn) input_image_init,/* Init function */
124
 
        (im_dest_obj_fn) im_close/* Destroy function */
 
126
        (im_dest_obj_fn) im_close       /* Destroy function */
125
127
};
126
128
 
127
129
/* Init function for output images.
137
139
/* Output image type.
138
140
 */
139
141
im_type_desc im__output_image = {
140
 
        IM_TYPE_IMAGE,          /* Its an image */
141
 
        0,                      /* No storage to be allocated */
142
 
        IM_TYPE_OUTPUT | IM_TYPE_ARG,           /* Flags! */
143
 
        (im_init_obj_fn) output_image_init,     /* Init function */
144
 
        (im_dest_obj_fn) im_close               /* Destroy function */
 
142
        IM_TYPE_IMAGE,                  /* It's an image */
 
143
        0,                              /* No storage to be allocated */
 
144
        IM_TYPE_OUTPUT | IM_TYPE_ARG,   /* Flags! */
 
145
        (im_init_obj_fn) output_image_init,/* Init function */
 
146
        (im_dest_obj_fn) im_close       /* Destroy function */
145
147
};
146
148
 
147
149
/* Init function for RW images.
157
159
/* RW image type.
158
160
 */
159
161
im_type_desc im__rw_image = {
160
 
        IM_TYPE_IMAGE,          /* Its an image */
161
 
        0,                      /* No storage to be allocated */
162
 
        IM_TYPE_ARG,            /* Flags! Pretend its an input type */
 
162
        IM_TYPE_IMAGE,                  /* It's an image */
 
163
        0,                              /* No storage to be allocated */
 
164
        IM_TYPE_ARG | IM_TYPE_RW,       /* Read-write object, needs an arg */
163
165
        (im_init_obj_fn) rw_image_init, /* Init function */
164
166
        (im_dest_obj_fn) im_close       /* Destroy function */
165
167
};
213
215
                iv->vec[i] = NULL;
214
216
 
215
217
        for( i = 0; i < nargs; i++ ) 
216
 
                if( !(iv->vec[i] = im_open( strv[i], "r" )) ) {
 
218
                if( !(iv->vec[i] = im_open( strv[i], "rd" )) ) {
217
219
                        g_strfreev( strv );
218
220
                        return( -1 );
219
221
                }
226
228
/* Input image vector type.
227
229
 */
228
230
im_type_desc im__input_imagevec = {
229
 
        IM_TYPE_IMAGEVEC,       /* Its an array of IMAGE */
230
 
        sizeof( im_imagevec_object ), /* Memory to allocate in vec build */
231
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
232
 
        input_imagevec_init,    /* Init function */
233
 
        imagevec_dest           /* Destroy function */
 
231
        IM_TYPE_IMAGEVEC,               /* It's an array of IMAGE */
 
232
        sizeof( im_imagevec_object ),   /* Memory to allocate in vec build */
 
233
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
234
        input_imagevec_init,            /* Init function */
 
235
        imagevec_dest                   /* Destroy function */
234
236
};
235
237
 
236
238
/* Init function for masks. "str" can be NULL for output masks.
344
346
/* Output dmask type.
345
347
 */
346
348
im_type_desc im__output_dmask = {
347
 
        IM_TYPE_DMASK,          /* Its a mask */
348
 
        sizeof( im_mask_object ),/* Storage for mask object */
 
349
        IM_TYPE_DMASK,                  /* It's a mask */
 
350
        sizeof( im_mask_object ),       /* Storage for mask object */
349
351
        IM_TYPE_OUTPUT | IM_TYPE_ARG,   /* Flags */
350
 
        mask_init,              /* Init function */
351
 
        save_dmask_dest /* Save and destroy function */
 
352
        mask_init,                      /* Init function */
 
353
        save_dmask_dest                 /* Save and destroy function */
352
354
};
353
355
 
354
356
/* Input dmask type.
355
357
 */
356
358
im_type_desc im__input_dmask = {
357
 
        IM_TYPE_DMASK,          /* Its a mask */
358
 
        sizeof( im_mask_object ),/* Storage for mask object */
359
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
360
 
        dmask_init,             /* Init function */
361
 
        dmask_dest              /* Destroy function */
 
359
        IM_TYPE_DMASK,                  /* It's a mask */
 
360
        sizeof( im_mask_object ),       /* Storage for mask object */
 
361
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
362
        dmask_init,                     /* Init function */
 
363
        dmask_dest                      /* Destroy function */
362
364
};
363
365
 
364
366
/* Output imask type.
365
367
 */
366
368
im_type_desc im__output_imask = {
367
 
        IM_TYPE_IMASK,          /* Its a mask */
368
 
        sizeof( im_mask_object ),/* Storage for mask object */
 
369
        IM_TYPE_IMASK,                  /* It's a mask */
 
370
        sizeof( im_mask_object ),       /* Storage for mask object */
369
371
        IM_TYPE_OUTPUT | IM_TYPE_ARG,   /* Flags */
370
 
        mask_init,              /* Init function */
371
 
        save_imask_dest /* Save and destroy function */
 
372
        mask_init,                      /* Init function */
 
373
        save_imask_dest                 /* Save and destroy function */
372
374
};
373
375
 
374
376
/* Input imask type.
375
377
 */
376
378
im_type_desc im__input_imask = {
377
 
        IM_TYPE_IMASK,          /* Its a mask */
378
 
        sizeof( im_mask_object ),/* Storage for mask object */
379
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
380
 
        imask_init,             /* Init function */
381
 
        imask_dest              /* Destroy function */
 
379
        IM_TYPE_IMASK,                  /* It's a mask */
 
380
        sizeof( im_mask_object ),       /* Storage for mask object */
 
381
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
382
        imask_init,                     /* Init function */
 
383
        imask_dest                      /* Destroy function */
382
384
};
383
385
 
384
386
/* Output dmask to screen type. Set a `print' function to get actual output.
385
387
 * Used for things like "stats".
386
388
 */
387
389
im_type_desc im__output_dmask_screen = {
388
 
        IM_TYPE_DMASK,          /* Its a mask */
389
 
        sizeof( im_mask_object ),/* Storage for mask object */
390
 
        IM_TYPE_OUTPUT,         /* Its an output argument */
391
 
        mask_init,              /* Init function */
392
 
        dmask_dest              /* Destroy function */
 
390
        IM_TYPE_DMASK,                  /* It's a mask */
 
391
        sizeof( im_mask_object ),       /* Storage for mask object */
 
392
        IM_TYPE_OUTPUT,                 /* It's an output argument */
 
393
        mask_init,                      /* Init function */
 
394
        dmask_dest                      /* Destroy function */
393
395
};
394
396
 
395
397
/* Init function for double input.
407
409
/* Input double type.
408
410
 */
409
411
im_type_desc im__input_double = {
410
 
        IM_TYPE_DOUBLE,         /* Its a double */
411
 
        sizeof( double ),       /* Memory to allocate */
412
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
413
 
        input_double_init,      /* Init function */
414
 
        NULL                    /* Destroy function */
 
412
        IM_TYPE_DOUBLE,                 /* It's a double */
 
413
        sizeof( double ),               /* Memory to allocate */
 
414
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
415
        input_double_init,              /* Init function */
 
416
        NULL                            /* Destroy function */
415
417
};
416
418
 
417
419
/* im_doublevec_object destroy function.
467
469
/* Input double vector type.
468
470
 */
469
471
im_type_desc im__input_doublevec = {
470
 
        IM_TYPE_DOUBLEVEC,      /* Its an array of double */
471
 
        sizeof( im_doublevec_object ), /* Memory to allocate in vec build */
472
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
473
 
        input_doublevec_init,   /* Init function */
474
 
        doublevec_dest          /* Destroy function */
 
472
        IM_TYPE_DOUBLEVEC,              /* It's an array of double */
 
473
        sizeof( im_doublevec_object ),  /* Memory to allocate in vec build */
 
474
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
475
        input_doublevec_init,           /* Init function */
 
476
        doublevec_dest                  /* Destroy function */
475
477
};
476
478
 
477
479
/* Print function for doublevec output.
492
494
/* Output double vector type.
493
495
 */
494
496
im_type_desc im__output_doublevec = {
495
 
        IM_TYPE_DOUBLEVEC,      /* Its an array of double */
496
 
        sizeof( im_doublevec_object ), /* Memory to allocate in vec build */
497
 
        IM_TYPE_OUTPUT,         /* Output type */
498
 
        NULL,                   /* Init function */
499
 
        doublevec_dest          /* Destroy function */
 
497
        IM_TYPE_DOUBLEVEC,              /* It's an array of double */
 
498
        sizeof( im_doublevec_object ),  /* Memory to allocate in vec build */
 
499
        IM_TYPE_OUTPUT,                 /* Output type */
 
500
        NULL,                           /* Init function */
 
501
        doublevec_dest                  /* Destroy function */
500
502
};
501
503
 
502
504
/* im_intvec_object destroy function.
558
560
/* Input int vector type.
559
561
 */
560
562
im_type_desc im__input_intvec = {
561
 
        IM_TYPE_INTVEC,         /* It's an array of int */
562
 
        sizeof( im_intvec_object ), /* Memory to allocate in vec build */
563
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
564
 
        input_intvec_init,      /* Init function */
565
 
        intvec_dest             /* Destroy function */
 
563
        IM_TYPE_INTVEC,                 /* It's an array of int */
 
564
        sizeof( im_intvec_object ),     /* Memory to allocate in vec build */
 
565
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
566
        input_intvec_init,              /* Init function */
 
567
        intvec_dest                     /* Destroy function */
566
568
};
567
569
 
568
570
/* Print function for intvec output.
583
585
/* Output int vector type.
584
586
 */
585
587
im_type_desc im__output_intvec = {
586
 
        IM_TYPE_INTVEC,         /* It's an array of int */
587
 
        sizeof( im_intvec_object ), /* Memory to allocate in vec build */
588
 
        IM_TYPE_OUTPUT,         /* Output arg */
589
 
        (im_init_obj_fn)NULL,                   /* Init function */
590
 
        (im_dest_obj_fn)intvec_dest             /* Destroy function */
 
588
        IM_TYPE_INTVEC,                 /* It's an array of int */
 
589
        sizeof( im_intvec_object ),     /* Memory to allocate in vec build */
 
590
        IM_TYPE_OUTPUT,                 /* Output arg */
 
591
        (im_init_obj_fn)NULL,           /* Init function */
 
592
        (im_dest_obj_fn)intvec_dest     /* Destroy function */
591
593
};
592
594
 
593
595
/* Init function for int input.
609
611
/* Input int type.
610
612
 */
611
613
im_type_desc im__input_int = {
612
 
        IM_TYPE_INT,            /* Its an int */
613
 
        sizeof( int ),          /* Memory to allocate */
614
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
615
 
        input_int_init,         /* Init function */
616
 
        NULL                    /* Destroy function */
 
614
        IM_TYPE_INT,                    /* It's an int */
 
615
        sizeof( int ),                  /* Memory to allocate */
 
616
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
617
        input_int_init,                 /* Init function */
 
618
        NULL                            /* Destroy function */
617
619
};
618
620
 
619
621
/* Init function for string input.
630
632
/* Input string type.
631
633
 */
632
634
im_type_desc im__input_string = {
633
 
        IM_TYPE_STRING,         /* Its a string */
634
 
        0,                      /* Memory to allocate */
635
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
636
 
        input_string_init,      /* Init function */
637
 
        im_free         /* Destroy function */
 
635
        IM_TYPE_STRING,                 /* It's a string */
 
636
        0,                              /* Memory to allocate */
 
637
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
638
        input_string_init,              /* Init function */
 
639
        im_free                         /* Destroy function */
638
640
};
639
641
 
640
642
/* Output string type.
641
643
 */
642
644
im_type_desc im__output_string = {
643
 
        IM_TYPE_STRING,         /* Its a string */
644
 
        0,                      /* Memory to allocate */
645
 
        IM_TYPE_OUTPUT,         /* Its an output argument */
646
 
        NULL,                   /* Init function */
647
 
        im_free         /* Destroy function */
 
645
        IM_TYPE_STRING,                 /* It's a string */
 
646
        0,                              /* Memory to allocate */
 
647
        IM_TYPE_OUTPUT,                 /* It's an output argument */
 
648
        NULL,                           /* Init function */
 
649
        im_free                         /* Destroy function */
648
650
};
649
651
 
650
652
/* Output double type.
651
653
 */
652
654
im_type_desc im__output_double = {
653
 
        IM_TYPE_DOUBLE,         /* Its a double */
654
 
        sizeof( double ),       /* Memory to allocate */
655
 
        IM_TYPE_OUTPUT,         /* Its an output argument */
656
 
        NULL,                   /* Init function */
657
 
        NULL                    /* Destroy function */
 
655
        IM_TYPE_DOUBLE,                 /* It's a double */
 
656
        sizeof( double ),               /* Memory to allocate */
 
657
        IM_TYPE_OUTPUT,                 /* It's an output argument */
 
658
        NULL,                           /* Init function */
 
659
        NULL                            /* Destroy function */
658
660
};
659
661
 
660
662
/* Output complex type.
661
663
 */
662
664
im_type_desc im__output_complex = {
663
 
        IM_TYPE_COMPLEX,        /* Its a complex */
664
 
        2 * sizeof( double ),   /* Memory to allocate */
665
 
        IM_TYPE_OUTPUT,         /* Its an output argument */
666
 
        NULL,                   /* Init function */
667
 
        NULL                    /* Destroy function */
 
665
        IM_TYPE_COMPLEX,                /* It's a complex */
 
666
        2 * sizeof( double ),           /* Memory to allocate */
 
667
        IM_TYPE_OUTPUT,                 /* It's an output argument */
 
668
        NULL,                           /* Init function */
 
669
        NULL                            /* Destroy function */
668
670
};
669
671
 
670
672
/* Output int type.
671
673
 */
672
674
im_type_desc im__output_int = {
673
 
        IM_TYPE_INT,            /* Its an int */
674
 
        sizeof( int ),          /* Memory to allocate */
675
 
        IM_TYPE_OUTPUT,         /* Its an output argument */
676
 
        NULL,                   /* Init function */
677
 
        NULL                    /* Destroy function */
 
675
        IM_TYPE_INT,                    /* It's an int */
 
676
        sizeof( int ),                  /* Memory to allocate */
 
677
        IM_TYPE_OUTPUT,                 /* It's an output argument */
 
678
        NULL,                           /* Init function */
 
679
        NULL                            /* Destroy function */
678
680
};
679
681
 
680
682
/* Print function for int output.
841
843
 */
842
844
im_type_desc im__input_gvalue = {
843
845
        IM_TYPE_GVALUE,         
844
 
        sizeof( GValue ),       /* Need some storage */
845
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
 
846
        sizeof( GValue ),               /* Need some storage */
 
847
        IM_TYPE_ARG,                    /* It requires a command-line arg */
846
848
        (im_init_obj_fn) input_gvalue_init,     /* Init function */
847
849
        (im_dest_obj_fn) gvalue_free    /* Destroy function */
848
850
};
904
906
 
905
907
im_type_desc im__input_interpolate = {
906
908
        IM_TYPE_INTERPOLATE,    
907
 
        0,                      /* No storage required */
908
 
        IM_TYPE_ARG,            /* It requires a command-line arg */
909
 
        input_interpolate_init, /* Init function */
910
 
        input_interpolate_dest  /* Destroy function */
 
909
        0,                              /* No storage required */
 
910
        IM_TYPE_ARG,                    /* It requires a command-line arg */
 
911
        input_interpolate_init,         /* Init function */
 
912
        input_interpolate_dest          /* Destroy function */
911
913
};
912
914