1 /* Object part of the VSource and VTarget class
2  */
3 
4 /*
5 
6     Copyright (C) 1991-2001 The National Gallery
7 
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU Lesser General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU Lesser General Public License for more details.
17 
18     You should have received a copy of the GNU Lesser General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21     02110-1301  USA
22 
23  */
24 
25 /*
26 
27     These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
28 
29  */
30 
31 #ifdef HAVE_CONFIG_H
32 #include <config.h>
33 #endif /*HAVE_CONFIG_H*/
34 #include <vips/intl.h>
35 
36 #include <vips/vips8>
37 
38 #include <vips/debug.h>
39 
40 /*
41 #define VIPS_DEBUG
42 #define VIPS_DEBUG_VERBOSE
43  */
44 
45 VIPS_NAMESPACE_START
46 
47 VSource
new_from_descriptor(int descriptor)48 VSource::new_from_descriptor( int descriptor )
49 {
50 	VipsSource *input;
51 
52 	if( !(input = vips_source_new_from_descriptor( descriptor )) )
53 		throw VError();
54 
55 	VSource out( input );
56 
57 	return( out );
58 }
59 
60 VSource
new_from_file(const char * filename)61 VSource::new_from_file( const char *filename )
62 {
63 	VipsSource *input;
64 
65 	if( !(input = vips_source_new_from_file( filename )) )
66 		throw VError();
67 
68 	VSource out( input );
69 
70 	return( out );
71 }
72 
73 VSource
new_from_blob(VipsBlob * blob)74 VSource::new_from_blob( VipsBlob *blob )
75 {
76 	VipsSource *input;
77 
78 	if( !(input = vips_source_new_from_blob( blob )) )
79 		throw VError();
80 
81 	VSource out( input );
82 
83 	return( out );
84 }
85 
86 VSource
new_from_memory(const void * data,size_t size)87 VSource::new_from_memory( const void *data,
88 	size_t size )
89 {
90 	VipsSource *input;
91 
92 	if( !(input = vips_source_new_from_memory( data, size )) )
93 		throw VError();
94 
95 	VSource out( input );
96 
97 	return( out );
98 }
99 
100 VSource
new_from_options(const char * options)101 VSource::new_from_options( const char *options )
102 {
103 	VipsSource *input;
104 
105 	if( !(input = vips_source_new_from_options( options )) )
106 		throw VError();
107 
108 	VSource out( input );
109 
110 	return( out );
111 }
112 
113 VTarget
new_to_descriptor(int descriptor)114 VTarget::new_to_descriptor( int descriptor )
115 {
116 	VipsTarget *output;
117 
118 	if( !(output = vips_target_new_to_descriptor( descriptor )) )
119 		throw VError();
120 
121 	VTarget out( output );
122 
123 	return( out );
124 }
125 
126 VTarget
new_to_file(const char * filename)127 VTarget::new_to_file( const char *filename )
128 {
129 	VipsTarget *output;
130 
131 	if( !(output = vips_target_new_to_file( filename )) )
132 		throw VError();
133 
134 	VTarget out( output );
135 
136 	return( out );
137 }
138 
139 VTarget
new_to_memory()140 VTarget::new_to_memory()
141 {
142 	VipsTarget *output;
143 
144 	if( !(output = vips_target_new_to_memory()) )
145 		throw VError();
146 
147 	VTarget out( output );
148 
149 	return( out );
150 }
151 
152 VIPS_NAMESPACE_END
153