Add svgload_stream to the descriptors test
Seems to work!
This commit is contained in:
parent
609fdb4fb6
commit
41c08b0ffb
@ -475,8 +475,7 @@ vips_foreign_load_svg_stream_is_a( VipsStreami *input )
|
|||||||
{
|
{
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
if( vips_streami_unminimise( input ) ||
|
if( vips_streami_rewind( input ) )
|
||||||
vips_streami_rewind( input ) )
|
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
|
|
||||||
g_byte_array_set_size( input->sniff, SVG_HEADER_SIZE );
|
g_byte_array_set_size( input->sniff, SVG_HEADER_SIZE );
|
||||||
|
@ -898,7 +898,6 @@ vips_streami_seek( VipsStreami *streami, gint64 offset, int whence )
|
|||||||
vips_error( vips_stream_nick( VIPS_STREAM( streami ) ),
|
vips_error( vips_stream_nick( VIPS_STREAM( streami ) ),
|
||||||
"%s", _( "bad 'whence'" ) );
|
"%s", _( "bad 'whence'" ) );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( streami->is_pipe ) {
|
else if( streami->is_pipe ) {
|
||||||
@ -926,7 +925,6 @@ vips_streami_seek( VipsStreami *streami, gint64 offset, int whence )
|
|||||||
vips_error( vips_stream_nick( VIPS_STREAM( streami ) ),
|
vips_error( vips_stream_nick( VIPS_STREAM( streami ) ),
|
||||||
"%s", _( "bad 'whence'" ) );
|
"%s", _( "bad 'whence'" ) );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1029,8 +1027,7 @@ vips_streami_sniff( VipsStreami *streami, size_t length )
|
|||||||
|
|
||||||
SANITY( streami );
|
SANITY( streami );
|
||||||
|
|
||||||
if( vips_streami_unminimise( streami ) ||
|
if( vips_streami_rewind( streami ) )
|
||||||
vips_streami_rewind( streami ) )
|
|
||||||
return( NULL );
|
return( NULL );
|
||||||
|
|
||||||
g_byte_array_set_size( streami->sniff, length );
|
g_byte_array_set_size( streami->sniff, length );
|
||||||
|
@ -78,7 +78,7 @@ vips_streamiw_get_property( GObject *object, guint prop_id,
|
|||||||
{
|
{
|
||||||
VipsStreamiw *streamiw = VIPS_STREAMIW( object );
|
VipsStreamiw *streamiw = VIPS_STREAMIW( object );
|
||||||
|
|
||||||
switch (prop_id) {
|
switch( prop_id ) {
|
||||||
case PROP_STREAM:
|
case PROP_STREAM:
|
||||||
g_value_set_object( value, streamiw->streami );
|
g_value_set_object( value, streamiw->streami );
|
||||||
break;
|
break;
|
||||||
@ -89,11 +89,11 @@ vips_streamiw_get_property( GObject *object, guint prop_id,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
vips_streamiw_set_property( GObject *object, guint prop_id,
|
vips_streamiw_set_property( GObject *object, guint prop_id,
|
||||||
const GValue *value, GParamSpec *pspec)
|
const GValue *value, GParamSpec *pspec )
|
||||||
{
|
{
|
||||||
VipsStreamiw *streamiw = VIPS_STREAMIW( object );
|
VipsStreamiw *streamiw = VIPS_STREAMIW( object );
|
||||||
|
|
||||||
switch (prop_id) {
|
switch( prop_id ) {
|
||||||
case PROP_STREAM:
|
case PROP_STREAM:
|
||||||
streamiw->streami = g_value_dup_object( value );
|
streamiw->streami = g_value_dup_object( value );
|
||||||
break;
|
break;
|
||||||
@ -125,9 +125,9 @@ vips_streamiw_tell( GSeekable *seekable )
|
|||||||
pos = vips_streami_seek( streami, 0, SEEK_CUR );
|
pos = vips_streami_seek( streami, 0, SEEK_CUR );
|
||||||
|
|
||||||
if( pos == -1 )
|
if( pos == -1 )
|
||||||
return 0;
|
return( 0 );
|
||||||
|
|
||||||
return pos;
|
return( pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -135,22 +135,22 @@ vips_streamiw_can_seek( GSeekable *seekable )
|
|||||||
{
|
{
|
||||||
VipsStreami *streami = VIPS_STREAMIW( seekable )->streami;
|
VipsStreami *streami = VIPS_STREAMIW( seekable )->streami;
|
||||||
|
|
||||||
VIPS_DEBUG_MSG( "vips_streamiw_can_seek: %d\n", !streami->is_pipe);
|
VIPS_DEBUG_MSG( "vips_streamiw_can_seek: %d\n", !streami->is_pipe );
|
||||||
|
|
||||||
return !streami->is_pipe;
|
return( !streami->is_pipe );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
seek_type_to_lseek( GSeekType type )
|
seek_type_to_lseek( GSeekType type )
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch( type ) {
|
||||||
default:
|
default:
|
||||||
case G_SEEK_CUR:
|
case G_SEEK_CUR:
|
||||||
return SEEK_CUR;
|
return( SEEK_CUR );
|
||||||
case G_SEEK_SET:
|
case G_SEEK_SET:
|
||||||
return SEEK_SET;
|
return( SEEK_SET );
|
||||||
case G_SEEK_END:
|
case G_SEEK_END:
|
||||||
return SEEK_END;
|
return( SEEK_END );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ vips_streamiw_read( GInputStream *stream, void *buffer, gsize count,
|
|||||||
|
|
||||||
VIPS_DEBUG_MSG( "vips_streamiw_read: count: %zd\n", count );
|
VIPS_DEBUG_MSG( "vips_streamiw_read: count: %zd\n", count );
|
||||||
|
|
||||||
if ( g_cancellable_set_error_if_cancelled( cancellable, error ) )
|
if( g_cancellable_set_error_if_cancelled( cancellable, error ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( (res = vips_streami_read( streami, buffer, count )) == -1 )
|
if( (res = vips_streami_read( streami, buffer, count )) == -1 )
|
||||||
@ -234,14 +234,13 @@ vips_streamiw_skip( GInputStream *stream, gsize count,
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
start = vips_streami_seek( streami, 0, SEEK_CUR );
|
start = vips_streami_seek( streami, 0, SEEK_CUR );
|
||||||
|
|
||||||
if( start == -1 )
|
if( start == -1 )
|
||||||
{
|
{
|
||||||
g_set_error( error, G_IO_ERROR,
|
g_set_error( error, G_IO_ERROR,
|
||||||
G_IO_ERROR_FAILED,
|
G_IO_ERROR_FAILED,
|
||||||
_("Error while seeking: %s"),
|
_("Error while seeking: %s"),
|
||||||
vips_error_buffer() );
|
vips_error_buffer() );
|
||||||
return -1;
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
end = vips_streami_seek( streami, 0, SEEK_END );
|
end = vips_streami_seek( streami, 0, SEEK_END );
|
||||||
@ -251,7 +250,7 @@ vips_streamiw_skip( GInputStream *stream, gsize count,
|
|||||||
G_IO_ERROR_FAILED,
|
G_IO_ERROR_FAILED,
|
||||||
_("Error while seeking: %s"),
|
_("Error while seeking: %s"),
|
||||||
vips_error_buffer() );
|
vips_error_buffer() );
|
||||||
return -1;
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( end - start > count )
|
if( end - start > count )
|
||||||
@ -264,7 +263,7 @@ vips_streamiw_skip( GInputStream *stream, gsize count,
|
|||||||
G_IO_ERROR_FAILED,
|
G_IO_ERROR_FAILED,
|
||||||
_("Error while seeking: %s"),
|
_("Error while seeking: %s"),
|
||||||
vips_error_buffer() );
|
vips_error_buffer() );
|
||||||
return -1;
|
return( -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +310,7 @@ vips_streamiw_class_init( VipsStreamiwClass *class )
|
|||||||
_("Input"),
|
_("Input"),
|
||||||
_("Stream to wrap"),
|
_("Stream to wrap"),
|
||||||
VIPS_TYPE_STREAMI, G_PARAM_CONSTRUCT_ONLY |
|
VIPS_TYPE_STREAMI, G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) );
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class TestStream:
|
|||||||
|
|
||||||
assert x.filename() == JPEG_FILE
|
assert x.filename() == JPEG_FILE
|
||||||
|
|
||||||
@skip_if_no("jpegload")
|
@skip_if_no("jpegload_stream")
|
||||||
def test_image_new_from_stream_filename(self):
|
def test_image_new_from_stream_filename(self):
|
||||||
x = pyvips.Streami.new_from_filename(JPEG_FILE)
|
x = pyvips.Streami.new_from_filename(JPEG_FILE)
|
||||||
y = pyvips.Image.new_from_stream(x, "")
|
y = pyvips.Image.new_from_stream(x, "")
|
||||||
@ -58,7 +58,7 @@ class TestStream:
|
|||||||
|
|
||||||
assert x.filename() == filename
|
assert x.filename() == filename
|
||||||
|
|
||||||
@skip_if_no("jpegload")
|
@skip_if_no("jpegload_stream")
|
||||||
def test_image_write_to_stream_filename(self):
|
def test_image_write_to_stream_filename(self):
|
||||||
filename = temp_filename(self.tempdir, ".jpg")
|
filename = temp_filename(self.tempdir, ".jpg")
|
||||||
x = pyvips.Streamo.new_to_filename(filename)
|
x = pyvips.Streamo.new_to_filename(filename)
|
||||||
@ -75,7 +75,7 @@ class TestStream:
|
|||||||
|
|
||||||
assert x.filename() == None
|
assert x.filename() == None
|
||||||
|
|
||||||
@skip_if_no("jpegload")
|
@skip_if_no("jpegload_stream")
|
||||||
def test_image_new_from_stream_memory(self):
|
def test_image_new_from_stream_memory(self):
|
||||||
data = self.colour.write_to_buffer(".jpg")
|
data = self.colour.write_to_buffer(".jpg")
|
||||||
x = pyvips.Streami.new_from_memory(data)
|
x = pyvips.Streami.new_from_memory(data)
|
||||||
@ -89,7 +89,7 @@ class TestStream:
|
|||||||
|
|
||||||
assert x.filename() == None
|
assert x.filename() == None
|
||||||
|
|
||||||
@skip_if_no("jpegload")
|
@skip_if_no("jpegload_stream")
|
||||||
def test_image_write_to_stream_filename(self):
|
def test_image_write_to_stream_filename(self):
|
||||||
x = pyvips.Streamo.new_to_memory()
|
x = pyvips.Streamo.new_to_memory()
|
||||||
self.colour.write_to_stream(x, ".jpg")
|
self.colour.write_to_stream(x, ".jpg")
|
||||||
|
@ -31,6 +31,7 @@ count_files( const char *dirname )
|
|||||||
int
|
int
|
||||||
main( int argc, char **argv )
|
main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
|
VipsStreami *streami;
|
||||||
VipsImage *image, *x;
|
VipsImage *image, *x;
|
||||||
char fd_dir[256];
|
char fd_dir[256];
|
||||||
int n_files;
|
int n_files;
|
||||||
@ -56,7 +57,9 @@ main( int argc, char **argv )
|
|||||||
/* Opening an image should read the header, then close the fd.
|
/* Opening an image should read the header, then close the fd.
|
||||||
*/
|
*/
|
||||||
printf( "** seq open ..\n" );
|
printf( "** seq open ..\n" );
|
||||||
if( !(image = vips_image_new_from_file( argv[1],
|
if( !(streami = vips_streami_new_from_filename( argv[1] )) )
|
||||||
|
vips_error_exit( NULL );
|
||||||
|
if( !(image = vips_image_new_from_stream( streami, "",
|
||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
NULL )) )
|
NULL )) )
|
||||||
vips_error_exit( NULL );
|
vips_error_exit( NULL );
|
||||||
@ -92,6 +95,7 @@ main( int argc, char **argv )
|
|||||||
*/
|
*/
|
||||||
printf( "** unref ..\n" );
|
printf( "** unref ..\n" );
|
||||||
g_object_unref( image );
|
g_object_unref( image );
|
||||||
|
g_object_unref( streami );
|
||||||
printf( "** shutdown ..\n" );
|
printf( "** shutdown ..\n" );
|
||||||
vips_shutdown();
|
vips_shutdown();
|
||||||
|
|
||||||
|
@ -10,18 +10,22 @@ set -e
|
|||||||
|
|
||||||
. ./variables.sh
|
. ./variables.sh
|
||||||
|
|
||||||
if test_supported jpegload; then
|
if test_supported jpegload_stream; then
|
||||||
./test_descriptors $image
|
./test_descriptors $image
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test_supported pngload; then
|
if test_supported pngload_stream; then
|
||||||
./test_descriptors $test_images/sample.png
|
./test_descriptors $test_images/sample.png
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test_supported tiffload; then
|
if test_supported tiffload_stream; then
|
||||||
./test_descriptors $test_images/sample.tif
|
./test_descriptors $test_images/sample.tif
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test_supported radload; then
|
if test_supported radload_stream; then
|
||||||
./test_descriptors $test_images/sample.hdr
|
./test_descriptors $test_images/sample.hdr
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test_supported svgload_stream; then
|
||||||
|
./test_descriptors $test_images/logo.svg
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user