rework pngload
To match the new radload pattern.
This commit is contained in:
parent
548aa30414
commit
561f410f0a
@ -480,6 +480,7 @@ static void *
|
|||||||
vips_foreign_find_load_sub( VipsForeignLoadClass *load_class,
|
vips_foreign_find_load_sub( VipsForeignLoadClass *load_class,
|
||||||
const char *filename )
|
const char *filename )
|
||||||
{
|
{
|
||||||
|
VipsObjectClass *object_class = VIPS_OBJECT_CLASS( load_class );
|
||||||
VipsForeignClass *class = VIPS_FOREIGN_CLASS( load_class );
|
VipsForeignClass *class = VIPS_FOREIGN_CLASS( load_class );
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -487,7 +488,9 @@ vips_foreign_find_load_sub( VipsForeignLoadClass *load_class,
|
|||||||
VIPS_OBJECT_CLASS( class )->nickname );
|
VIPS_OBJECT_CLASS( class )->nickname );
|
||||||
#endif /*DEBUG*/
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
if( load_class->is_a ) {
|
if( load_class->is_a &&
|
||||||
|
!vips_ispostfix( object_class->nickname, "_buffer" ) &&
|
||||||
|
!vips_ispostfix( object_class->nickname, "_stream" ) ) {
|
||||||
if( load_class->is_a( filename ) )
|
if( load_class->is_a( filename ) )
|
||||||
return( load_class );
|
return( load_class );
|
||||||
|
|
||||||
@ -1756,10 +1759,10 @@ vips_foreign_find_save_sub( VipsForeignSaveClass *save_class,
|
|||||||
* it's not one of those.
|
* it's not one of those.
|
||||||
*/
|
*/
|
||||||
if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) &&
|
if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) &&
|
||||||
class->suffs &&
|
|
||||||
vips_filename_suffix_match( filename, class->suffs ) &&
|
|
||||||
!vips_ispostfix( object_class->nickname, "_buffer" ) &&
|
!vips_ispostfix( object_class->nickname, "_buffer" ) &&
|
||||||
!vips_ispostfix( object_class->nickname, "_stream" ) )
|
!vips_ispostfix( object_class->nickname, "_stream" ) &&
|
||||||
|
class->suffs &&
|
||||||
|
vips_filename_suffix_match( filename, class->suffs ) )
|
||||||
return( save_class );
|
return( save_class );
|
||||||
|
|
||||||
return( NULL );
|
return( NULL );
|
||||||
@ -2001,31 +2004,41 @@ vips_foreign_find_save_buffer( const char *name )
|
|||||||
void
|
void
|
||||||
vips_foreign_operation_init( void )
|
vips_foreign_operation_init( void )
|
||||||
{
|
{
|
||||||
extern GType vips_foreign_load_rad_get_type( void );
|
extern GType vips_foreign_load_rad_file_get_type( void );
|
||||||
extern GType vips_foreign_load_rad_buffer_get_type( void );
|
extern GType vips_foreign_load_rad_buffer_get_type( void );
|
||||||
extern GType vips_foreign_load_rad_stream_get_type( void );
|
extern GType vips_foreign_load_rad_stream_get_type( void );
|
||||||
extern GType vips_foreign_save_rad_file_get_type( void );
|
extern GType vips_foreign_save_rad_file_get_type( void );
|
||||||
extern GType vips_foreign_save_rad_buffer_get_type( void );
|
extern GType vips_foreign_save_rad_buffer_get_type( void );
|
||||||
extern GType vips_foreign_save_rad_stream_get_type( void );
|
extern GType vips_foreign_save_rad_stream_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_mat_get_type( void );
|
extern GType vips_foreign_load_mat_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_ppm_file_get_type( void );
|
extern GType vips_foreign_load_ppm_file_get_type( void );
|
||||||
extern GType vips_foreign_save_ppm_file_get_type( void );
|
extern GType vips_foreign_save_ppm_file_get_type( void );
|
||||||
extern GType vips_foreign_load_png_get_type( void );
|
|
||||||
|
extern GType vips_foreign_load_png_file_get_type( void );
|
||||||
extern GType vips_foreign_load_png_buffer_get_type( void );
|
extern GType vips_foreign_load_png_buffer_get_type( void );
|
||||||
extern GType vips_foreign_load_png_stream_get_type( void );
|
extern GType vips_foreign_load_png_stream_get_type( void );
|
||||||
extern GType vips_foreign_save_png_file_get_type( void );
|
extern GType vips_foreign_save_png_file_get_type( void );
|
||||||
extern GType vips_foreign_save_png_buffer_get_type( void );
|
extern GType vips_foreign_save_png_buffer_get_type( void );
|
||||||
extern GType vips_foreign_save_png_stream_get_type( void );
|
extern GType vips_foreign_save_png_stream_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_csv_get_type( void );
|
extern GType vips_foreign_load_csv_get_type( void );
|
||||||
extern GType vips_foreign_save_csv_get_type( void );
|
extern GType vips_foreign_save_csv_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_matrix_get_type( void );
|
extern GType vips_foreign_load_matrix_get_type( void );
|
||||||
extern GType vips_foreign_save_matrix_get_type( void );
|
extern GType vips_foreign_save_matrix_get_type( void );
|
||||||
extern GType vips_foreign_print_matrix_get_type( void );
|
extern GType vips_foreign_print_matrix_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_fits_get_type( void );
|
extern GType vips_foreign_load_fits_get_type( void );
|
||||||
extern GType vips_foreign_save_fits_get_type( void );
|
extern GType vips_foreign_save_fits_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_analyze_get_type( void );
|
extern GType vips_foreign_load_analyze_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_openexr_get_type( void );
|
extern GType vips_foreign_load_openexr_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_openslide_get_type( void );
|
extern GType vips_foreign_load_openslide_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_jpeg_file_get_type( void );
|
extern GType vips_foreign_load_jpeg_file_get_type( void );
|
||||||
extern GType vips_foreign_load_jpeg_buffer_get_type( void );
|
extern GType vips_foreign_load_jpeg_buffer_get_type( void );
|
||||||
extern GType vips_foreign_load_jpeg_stream_get_type( void );
|
extern GType vips_foreign_load_jpeg_stream_get_type( void );
|
||||||
@ -2033,45 +2046,56 @@ vips_foreign_operation_init( void )
|
|||||||
extern GType vips_foreign_save_jpeg_buffer_get_type( void );
|
extern GType vips_foreign_save_jpeg_buffer_get_type( void );
|
||||||
extern GType vips_foreign_save_jpeg_stream_get_type( void );
|
extern GType vips_foreign_save_jpeg_stream_get_type( void );
|
||||||
extern GType vips_foreign_save_jpeg_mime_get_type( void );
|
extern GType vips_foreign_save_jpeg_mime_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_tiff_file_get_type( void );
|
extern GType vips_foreign_load_tiff_file_get_type( void );
|
||||||
extern GType vips_foreign_load_tiff_buffer_get_type( void );
|
extern GType vips_foreign_load_tiff_buffer_get_type( void );
|
||||||
extern GType vips_foreign_load_tiff_stream_get_type( void );
|
extern GType vips_foreign_load_tiff_stream_get_type( void );
|
||||||
extern GType vips_foreign_save_tiff_file_get_type( void );
|
extern GType vips_foreign_save_tiff_file_get_type( void );
|
||||||
extern GType vips_foreign_save_tiff_buffer_get_type( void );
|
extern GType vips_foreign_save_tiff_buffer_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_vips_get_type( void );
|
extern GType vips_foreign_load_vips_get_type( void );
|
||||||
extern GType vips_foreign_save_vips_get_type( void );
|
extern GType vips_foreign_save_vips_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_raw_get_type( void );
|
extern GType vips_foreign_load_raw_get_type( void );
|
||||||
extern GType vips_foreign_save_raw_get_type( void );
|
extern GType vips_foreign_save_raw_get_type( void );
|
||||||
extern GType vips_foreign_save_raw_fd_get_type( void );
|
extern GType vips_foreign_save_raw_fd_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_magick_file_get_type( void );
|
extern GType vips_foreign_load_magick_file_get_type( void );
|
||||||
extern GType vips_foreign_load_magick_buffer_get_type( void );
|
extern GType vips_foreign_load_magick_buffer_get_type( void );
|
||||||
extern GType vips_foreign_load_magick7_file_get_type( void );
|
extern GType vips_foreign_load_magick7_file_get_type( void );
|
||||||
extern GType vips_foreign_load_magick7_buffer_get_type( void );
|
extern GType vips_foreign_load_magick7_buffer_get_type( void );
|
||||||
extern GType vips_foreign_save_magick_file_get_type( void );
|
extern GType vips_foreign_save_magick_file_get_type( void );
|
||||||
extern GType vips_foreign_save_magick_buffer_get_type( void );
|
extern GType vips_foreign_save_magick_buffer_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_save_dz_file_get_type( void );
|
extern GType vips_foreign_save_dz_file_get_type( void );
|
||||||
extern GType vips_foreign_save_dz_buffer_get_type( void );
|
extern GType vips_foreign_save_dz_buffer_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_webp_file_get_type( void );
|
extern GType vips_foreign_load_webp_file_get_type( void );
|
||||||
extern GType vips_foreign_load_webp_buffer_get_type( void );
|
extern GType vips_foreign_load_webp_buffer_get_type( void );
|
||||||
extern GType vips_foreign_load_webp_stream_get_type( void );
|
extern GType vips_foreign_load_webp_stream_get_type( void );
|
||||||
extern GType vips_foreign_save_webp_file_get_type( void );
|
extern GType vips_foreign_save_webp_file_get_type( void );
|
||||||
extern GType vips_foreign_save_webp_buffer_get_type( void );
|
extern GType vips_foreign_save_webp_buffer_get_type( void );
|
||||||
extern GType vips_foreign_save_webp_stream_get_type( void );
|
extern GType vips_foreign_save_webp_stream_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_pdf_get_type( void );
|
extern GType vips_foreign_load_pdf_get_type( void );
|
||||||
extern GType vips_foreign_load_pdf_file_get_type( void );
|
extern GType vips_foreign_load_pdf_file_get_type( void );
|
||||||
extern GType vips_foreign_load_pdf_buffer_get_type( void );
|
extern GType vips_foreign_load_pdf_buffer_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_svg_get_type( void );
|
extern GType vips_foreign_load_svg_get_type( void );
|
||||||
extern GType vips_foreign_load_svg_file_get_type( void );
|
extern GType vips_foreign_load_svg_file_get_type( void );
|
||||||
extern GType vips_foreign_load_svg_buffer_get_type( void );
|
extern GType vips_foreign_load_svg_buffer_get_type( void );
|
||||||
extern GType vips_foreign_load_svg_stream_get_type( void );
|
extern GType vips_foreign_load_svg_stream_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_heif_get_type( void );
|
extern GType vips_foreign_load_heif_get_type( void );
|
||||||
extern GType vips_foreign_load_heif_file_get_type( void );
|
extern GType vips_foreign_load_heif_file_get_type( void );
|
||||||
extern GType vips_foreign_load_heif_buffer_get_type( void );
|
extern GType vips_foreign_load_heif_buffer_get_type( void );
|
||||||
extern GType vips_foreign_save_heif_get_type( void );
|
extern GType vips_foreign_save_heif_get_type( void );
|
||||||
extern GType vips_foreign_save_heif_file_get_type( void );
|
extern GType vips_foreign_save_heif_file_get_type( void );
|
||||||
extern GType vips_foreign_save_heif_buffer_get_type( void );
|
extern GType vips_foreign_save_heif_buffer_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_nifti_get_type( void );
|
extern GType vips_foreign_load_nifti_get_type( void );
|
||||||
extern GType vips_foreign_save_nifti_get_type( void );
|
extern GType vips_foreign_save_nifti_get_type( void );
|
||||||
|
|
||||||
extern GType vips_foreign_load_gif_get_type( void );
|
extern GType vips_foreign_load_gif_get_type( void );
|
||||||
extern GType vips_foreign_load_gif_file_get_type( void );
|
extern GType vips_foreign_load_gif_file_get_type( void );
|
||||||
extern GType vips_foreign_load_gif_buffer_get_type( void );
|
extern GType vips_foreign_load_gif_buffer_get_type( void );
|
||||||
@ -2097,7 +2121,7 @@ vips_foreign_operation_init( void )
|
|||||||
#endif /*HAVE_PPM*/
|
#endif /*HAVE_PPM*/
|
||||||
|
|
||||||
#ifdef HAVE_RADIANCE
|
#ifdef HAVE_RADIANCE
|
||||||
vips_foreign_load_rad_get_type();
|
vips_foreign_load_rad_file_get_type();
|
||||||
vips_foreign_load_rad_buffer_get_type();
|
vips_foreign_load_rad_buffer_get_type();
|
||||||
vips_foreign_load_rad_stream_get_type();
|
vips_foreign_load_rad_stream_get_type();
|
||||||
vips_foreign_save_rad_file_get_type();
|
vips_foreign_save_rad_file_get_type();
|
||||||
@ -2136,7 +2160,7 @@ vips_foreign_operation_init( void )
|
|||||||
#endif /*HAVE_GSF*/
|
#endif /*HAVE_GSF*/
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
#ifdef HAVE_PNG
|
||||||
vips_foreign_load_png_get_type();
|
vips_foreign_load_png_file_get_type();
|
||||||
vips_foreign_load_png_buffer_get_type();
|
vips_foreign_load_png_buffer_get_type();
|
||||||
vips_foreign_load_png_stream_get_type();
|
vips_foreign_load_png_stream_get_type();
|
||||||
vips_foreign_save_png_file_get_type();
|
vips_foreign_save_png_file_get_type();
|
||||||
|
@ -117,6 +117,7 @@ vips_foreign_load_jpeg_class_init( VipsForeignLoadJpegClass *class )
|
|||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||||
|
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||||
VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class;
|
VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class;
|
||||||
|
|
||||||
gobject_class->set_property = vips_object_set_property;
|
gobject_class->set_property = vips_object_set_property;
|
||||||
@ -126,6 +127,10 @@ vips_foreign_load_jpeg_class_init( VipsForeignLoadJpegClass *class )
|
|||||||
object_class->description = _( "load jpeg" );
|
object_class->description = _( "load jpeg" );
|
||||||
object_class->build = vips_foreign_load_jpeg_build;
|
object_class->build = vips_foreign_load_jpeg_build;
|
||||||
|
|
||||||
|
/* We are fast at is_a(), so high priority.
|
||||||
|
*/
|
||||||
|
foreign_class->priority = 50;
|
||||||
|
|
||||||
load_class->get_flags = vips_foreign_load_jpeg_get_flags;
|
load_class->get_flags = vips_foreign_load_jpeg_get_flags;
|
||||||
|
|
||||||
VIPS_ARG_INT( class, "shrink", 20,
|
VIPS_ARG_INT( class, "shrink", 20,
|
||||||
@ -190,7 +195,7 @@ vips_foreign_load_jpeg_stream_load( VipsForeignLoad *load )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_jpeg_stream_is_a( VipsStreami *streami )
|
vips_foreign_load_jpeg_stream_is_a_stream( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
return( vips__isjpeg_stream( streami ) );
|
return( vips__isjpeg_stream( streami ) );
|
||||||
}
|
}
|
||||||
@ -209,7 +214,7 @@ vips_foreign_load_jpeg_stream_class_init(
|
|||||||
object_class->nickname = "jpegload_stream";
|
object_class->nickname = "jpegload_stream";
|
||||||
object_class->description = _( "load image from jpeg stream" );
|
object_class->description = _( "load image from jpeg stream" );
|
||||||
|
|
||||||
load_class->is_a_stream = vips_foreign_load_jpeg_stream_is_a;
|
load_class->is_a_stream = vips_foreign_load_jpeg_stream_is_a_stream;
|
||||||
load_class->header = vips_foreign_load_jpeg_stream_header;
|
load_class->header = vips_foreign_load_jpeg_stream_header;
|
||||||
load_class->load = vips_foreign_load_jpeg_stream_load;
|
load_class->load = vips_foreign_load_jpeg_stream_load;
|
||||||
|
|
||||||
@ -309,10 +314,6 @@ vips_foreign_load_jpeg_file_class_init( VipsForeignLoadJpegFileClass *class )
|
|||||||
|
|
||||||
foreign_class->suffs = vips__jpeg_suffs;
|
foreign_class->suffs = vips__jpeg_suffs;
|
||||||
|
|
||||||
/* We are fast at is_a(), so high priority.
|
|
||||||
*/
|
|
||||||
foreign_class->priority = 50;
|
|
||||||
|
|
||||||
load_class->is_a = vips_foreign_load_jpeg_file_is_a;
|
load_class->is_a = vips_foreign_load_jpeg_file_is_a;
|
||||||
load_class->header = vips_foreign_load_jpeg_file_header;
|
load_class->header = vips_foreign_load_jpeg_file_header;
|
||||||
load_class->load = vips_foreign_load_jpeg_file_load;
|
load_class->load = vips_foreign_load_jpeg_file_load;
|
||||||
|
@ -52,29 +52,38 @@
|
|||||||
|
|
||||||
#ifdef HAVE_PNG
|
#ifdef HAVE_PNG
|
||||||
|
|
||||||
typedef struct _VipsForeignLoadPngStream {
|
typedef struct _VipsForeignLoadPng {
|
||||||
VipsForeignLoad parent_object;
|
VipsForeignLoad parent_object;
|
||||||
|
|
||||||
/* Load from a stream.
|
/* Set by subclasses.
|
||||||
*/
|
*/
|
||||||
VipsStreami *streami;
|
VipsStreami *streami;
|
||||||
|
|
||||||
} VipsForeignLoadPngStream;
|
} VipsForeignLoadPng;
|
||||||
|
|
||||||
typedef VipsForeignLoadClass VipsForeignLoadPngStreamClass;
|
typedef VipsForeignLoadClass VipsForeignLoadPngClass;
|
||||||
|
|
||||||
G_DEFINE_TYPE( VipsForeignLoadPngStream, vips_foreign_load_png_stream,
|
G_DEFINE_TYPE( VipsForeignLoadPng, vips_foreign_load_png,
|
||||||
VIPS_TYPE_FOREIGN_LOAD );
|
VIPS_TYPE_FOREIGN_LOAD );
|
||||||
|
|
||||||
static VipsForeignFlags
|
static void
|
||||||
vips_foreign_load_png_stream_get_flags( VipsForeignLoad *load )
|
vips_foreign_load_png_dispose( GObject *gobject )
|
||||||
{
|
{
|
||||||
VipsForeignLoadPngStream *stream = (VipsForeignLoadPngStream *) load;
|
VipsForeignLoadPng *png = (VipsForeignLoadPng *) gobject;
|
||||||
|
|
||||||
|
VIPS_UNREF( png->streami );
|
||||||
|
|
||||||
|
G_OBJECT_CLASS( vips_foreign_load_png_parent_class )->
|
||||||
|
dispose( gobject );
|
||||||
|
}
|
||||||
|
|
||||||
|
static VipsForeignFlags
|
||||||
|
vips_foreign_load_png_get_flags_stream( VipsStreami *streami )
|
||||||
|
{
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if( vips__png_isinterlaced_stream( stream->streami ) )
|
if( vips__png_isinterlaced_stream( streami ) )
|
||||||
flags |= VIPS_FOREIGN_PARTIAL;
|
flags |= VIPS_FOREIGN_PARTIAL;
|
||||||
else
|
else
|
||||||
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
||||||
@ -82,28 +91,118 @@ vips_foreign_load_png_stream_get_flags( VipsForeignLoad *load )
|
|||||||
return( flags );
|
return( flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static VipsForeignFlags
|
||||||
vips_foreign_load_png_stream_header( VipsForeignLoad *load )
|
vips_foreign_load_png_get_flags( VipsForeignLoad *load )
|
||||||
{
|
{
|
||||||
VipsForeignLoadPngStream *stream = (VipsForeignLoadPngStream *) load;
|
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
||||||
|
|
||||||
if( vips__png_header_stream( stream->streami, load->out ) )
|
return( vips_foreign_load_png_get_flags_stream( png->streami ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static VipsForeignFlags
|
||||||
|
vips_foreign_load_png_get_flags_filename( const char *filename )
|
||||||
|
{
|
||||||
|
VipsStreami *streami;
|
||||||
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
|
if( !(streami = vips_streami_new_from_file( filename )) )
|
||||||
|
return( 0 );
|
||||||
|
flags = vips_foreign_load_png_get_flags_stream( streami );
|
||||||
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
|
return( flags );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vips_foreign_load_png_header( VipsForeignLoad *load )
|
||||||
|
{
|
||||||
|
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
||||||
|
|
||||||
|
if( vips__png_header_stream( png->streami, load->out ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vips_foreign_load_png_stream_load( VipsForeignLoad *load )
|
vips_foreign_load_png_load( VipsForeignLoad *load )
|
||||||
{
|
{
|
||||||
VipsForeignLoadPngStream *stream = (VipsForeignLoadPngStream *) load;
|
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
||||||
|
|
||||||
if( vips__png_read_stream( stream->streami, load->real, load->fail ) )
|
if( vips__png_read_stream( png->streami, load->real, load->fail ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vips_foreign_load_png_class_init( VipsForeignLoadPngClass *class )
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||||
|
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||||
|
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||||
|
VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class;
|
||||||
|
|
||||||
|
gobject_class->dispose = vips_foreign_load_png_dispose;
|
||||||
|
|
||||||
|
object_class->nickname = "pngload_base";
|
||||||
|
object_class->description = _( "load png base class" );
|
||||||
|
|
||||||
|
/* We are fast at is_a(), so high priority.
|
||||||
|
*/
|
||||||
|
foreign_class->priority = 200;
|
||||||
|
|
||||||
|
load_class->get_flags_filename =
|
||||||
|
vips_foreign_load_png_get_flags_filename;
|
||||||
|
load_class->get_flags = vips_foreign_load_png_get_flags;
|
||||||
|
load_class->header = vips_foreign_load_png_header;
|
||||||
|
load_class->load = vips_foreign_load_png_load;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vips_foreign_load_png_init( VipsForeignLoadPng *png )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct _VipsForeignLoadPngStream {
|
||||||
|
VipsForeignLoadPng parent_object;
|
||||||
|
|
||||||
|
/* Load from a stream.
|
||||||
|
*/
|
||||||
|
VipsStreami *streami;
|
||||||
|
|
||||||
|
} VipsForeignLoadPngStream;
|
||||||
|
|
||||||
|
typedef VipsForeignLoadPngClass VipsForeignLoadPngStreamClass;
|
||||||
|
|
||||||
|
G_DEFINE_TYPE( VipsForeignLoadPngStream, vips_foreign_load_png_stream,
|
||||||
|
vips_foreign_load_png_get_type() );
|
||||||
|
|
||||||
|
static int
|
||||||
|
vips_foreign_load_png_stream_build( VipsObject *object )
|
||||||
|
{
|
||||||
|
VipsForeignLoadPng *png = (VipsForeignLoadPng *) object;
|
||||||
|
VipsForeignLoadPngStream *stream = (VipsForeignLoadPngStream *) object;
|
||||||
|
|
||||||
|
if( stream->streami ) {
|
||||||
|
png->streami = stream->streami;
|
||||||
|
g_object_ref( png->streami );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( VIPS_OBJECT_CLASS( vips_foreign_load_png_stream_parent_class )->
|
||||||
|
build( object ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
vips_foreign_load_png_stream_is_a_stream( VipsStreami *streami )
|
||||||
|
{
|
||||||
|
return( vips__png_ispng_stream( streami ) );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_foreign_load_png_stream_class_init( VipsForeignLoadPngStreamClass *class )
|
vips_foreign_load_png_stream_class_init( VipsForeignLoadPngStreamClass *class )
|
||||||
{
|
{
|
||||||
@ -116,11 +215,9 @@ vips_foreign_load_png_stream_class_init( VipsForeignLoadPngStreamClass *class )
|
|||||||
|
|
||||||
object_class->nickname = "pngload_stream";
|
object_class->nickname = "pngload_stream";
|
||||||
object_class->description = _( "load png from stream" );
|
object_class->description = _( "load png from stream" );
|
||||||
|
object_class->build = vips_foreign_load_png_stream_build;
|
||||||
|
|
||||||
load_class->is_a_stream = vips__png_ispng_stream;
|
load_class->is_a_stream = vips_foreign_load_png_stream_is_a_stream;
|
||||||
load_class->get_flags = vips_foreign_load_png_stream_get_flags;
|
|
||||||
load_class->header = vips_foreign_load_png_stream_header;
|
|
||||||
load_class->load = vips_foreign_load_png_stream_load;
|
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "streami", 1,
|
VIPS_ARG_OBJECT( class, "streami", 1,
|
||||||
_( "Streami" ),
|
_( "Streami" ),
|
||||||
@ -136,100 +233,53 @@ vips_foreign_load_png_stream_init( VipsForeignLoadPngStream *stream )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _VipsForeignLoadPng {
|
typedef struct _VipsForeignLoadPngFile {
|
||||||
VipsForeignLoad parent_object;
|
VipsForeignLoadPng parent_object;
|
||||||
|
|
||||||
/* Filename for load.
|
/* Filename for load.
|
||||||
*/
|
*/
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
} VipsForeignLoadPng;
|
} VipsForeignLoadPngFile;
|
||||||
|
|
||||||
typedef VipsForeignLoadClass VipsForeignLoadPngClass;
|
typedef VipsForeignLoadPngClass VipsForeignLoadPngFileClass;
|
||||||
|
|
||||||
G_DEFINE_TYPE( VipsForeignLoadPng, vips_foreign_load_png,
|
G_DEFINE_TYPE( VipsForeignLoadPngFile, vips_foreign_load_png_file,
|
||||||
VIPS_TYPE_FOREIGN_LOAD );
|
vips_foreign_load_png_get_type() );
|
||||||
|
|
||||||
|
static int
|
||||||
|
vips_foreign_load_png_file_build( VipsObject *object )
|
||||||
|
{
|
||||||
|
VipsForeignLoadPng *png = (VipsForeignLoadPng *) object;
|
||||||
|
VipsForeignLoadPngFile *file = (VipsForeignLoadPngFile *) object;
|
||||||
|
|
||||||
|
if( file->filename &&
|
||||||
|
!(png->streami = vips_streami_new_from_file( file->filename )) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
if( VIPS_OBJECT_CLASS( vips_foreign_load_png_file_parent_class )->
|
||||||
|
build( object ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_png_is_a( const char *filename )
|
vips_foreign_load_png_file_is_a( const char *filename )
|
||||||
{
|
{
|
||||||
VipsStreami *streami;
|
VipsStreami *streami;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
if( !(streami = vips_streami_new_from_file( filename )) )
|
if( !(streami = vips_streami_new_from_file( filename )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__png_ispng_stream( streami );
|
result = vips_foreign_load_png_stream_is_a_stream( streami );
|
||||||
VIPS_UNREF( streami );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
static VipsForeignFlags
|
|
||||||
vips_foreign_load_png_get_flags_filename( const char *filename )
|
|
||||||
{
|
|
||||||
VipsStreami *streami;
|
|
||||||
VipsForeignFlags flags;
|
|
||||||
|
|
||||||
if( !(streami = vips_streami_new_from_file( filename )) )
|
|
||||||
return( 0 );
|
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
if( vips__png_isinterlaced_stream( streami ) )
|
|
||||||
flags |= VIPS_FOREIGN_PARTIAL;
|
|
||||||
else
|
|
||||||
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
|
||||||
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
|
|
||||||
return( flags );
|
|
||||||
}
|
|
||||||
|
|
||||||
static VipsForeignFlags
|
|
||||||
vips_foreign_load_png_get_flags( VipsForeignLoad *load )
|
|
||||||
{
|
|
||||||
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
|
||||||
|
|
||||||
return( vips_foreign_load_png_get_flags_filename( png->filename ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
vips_foreign_load_png_header( VipsForeignLoad *load )
|
|
||||||
{
|
|
||||||
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
|
||||||
|
|
||||||
VipsStreami *streami;
|
|
||||||
|
|
||||||
if( !(streami = vips_streami_new_from_file( png->filename )) )
|
|
||||||
return( -1 );
|
|
||||||
if( vips__png_header_stream( streami, load->out ) ) {
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
vips_foreign_load_png_load( VipsForeignLoad *load )
|
|
||||||
{
|
|
||||||
VipsForeignLoadPng *png = (VipsForeignLoadPng *) load;
|
|
||||||
|
|
||||||
VipsStreami *streami;
|
|
||||||
|
|
||||||
if( !(streami = vips_streami_new_from_file( png->filename )) )
|
|
||||||
return( -1 );
|
|
||||||
if( vips__png_read_stream( streami, load->real, load->fail ) ) {
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_foreign_load_png_class_init( VipsForeignLoadPngClass *class )
|
vips_foreign_load_png_file_class_init( VipsForeignLoadPngFileClass *class )
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||||
@ -241,35 +291,27 @@ vips_foreign_load_png_class_init( VipsForeignLoadPngClass *class )
|
|||||||
|
|
||||||
object_class->nickname = "pngload";
|
object_class->nickname = "pngload";
|
||||||
object_class->description = _( "load png from file" );
|
object_class->description = _( "load png from file" );
|
||||||
|
object_class->build = vips_foreign_load_png_file_build;
|
||||||
|
|
||||||
foreign_class->suffs = vips__png_suffs;
|
foreign_class->suffs = vips__png_suffs;
|
||||||
|
|
||||||
/* We are fast at is_a(), so high priority.
|
load_class->is_a = vips_foreign_load_png_file_is_a;
|
||||||
*/
|
|
||||||
foreign_class->priority = 200;
|
|
||||||
|
|
||||||
load_class->is_a = vips_foreign_load_png_is_a;
|
|
||||||
load_class->get_flags_filename =
|
|
||||||
vips_foreign_load_png_get_flags_filename;
|
|
||||||
load_class->get_flags = vips_foreign_load_png_get_flags;
|
|
||||||
load_class->header = vips_foreign_load_png_header;
|
|
||||||
load_class->load = vips_foreign_load_png_load;
|
|
||||||
|
|
||||||
VIPS_ARG_STRING( class, "filename", 1,
|
VIPS_ARG_STRING( class, "filename", 1,
|
||||||
_( "Filename" ),
|
_( "Filename" ),
|
||||||
_( "Filename to load from" ),
|
_( "Filename to load from" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignLoadPng, filename ),
|
G_STRUCT_OFFSET( VipsForeignLoadPngFile, filename ),
|
||||||
NULL );
|
NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_foreign_load_png_init( VipsForeignLoadPng *png )
|
vips_foreign_load_png_file_init( VipsForeignLoadPngFile *file )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _VipsForeignLoadPngBuffer {
|
typedef struct _VipsForeignLoadPngBuffer {
|
||||||
VipsForeignLoad parent_object;
|
VipsForeignLoadPng parent_object;
|
||||||
|
|
||||||
/* Load from a buffer.
|
/* Load from a buffer.
|
||||||
*/
|
*/
|
||||||
@ -277,10 +319,28 @@ typedef struct _VipsForeignLoadPngBuffer {
|
|||||||
|
|
||||||
} VipsForeignLoadPngBuffer;
|
} VipsForeignLoadPngBuffer;
|
||||||
|
|
||||||
typedef VipsForeignLoadClass VipsForeignLoadPngBufferClass;
|
typedef VipsForeignLoadPngClass VipsForeignLoadPngBufferClass;
|
||||||
|
|
||||||
G_DEFINE_TYPE( VipsForeignLoadPngBuffer, vips_foreign_load_png_buffer,
|
G_DEFINE_TYPE( VipsForeignLoadPngBuffer, vips_foreign_load_png_buffer,
|
||||||
VIPS_TYPE_FOREIGN_LOAD );
|
vips_foreign_load_png_get_type() );
|
||||||
|
|
||||||
|
static int
|
||||||
|
vips_foreign_load_png_buffer_build( VipsObject *object )
|
||||||
|
{
|
||||||
|
VipsForeignLoadPng *png = (VipsForeignLoadPng *) object;
|
||||||
|
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) object;
|
||||||
|
|
||||||
|
if( buffer->buf &&
|
||||||
|
!(png->streami = vips_streami_new_from_memory(
|
||||||
|
buffer->buf->data, buffer->buf->length )) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
if( VIPS_OBJECT_CLASS( vips_foreign_load_png_buffer_parent_class )->
|
||||||
|
build( object ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
vips_foreign_load_png_buffer_is_a_buffer( const void *buf, size_t len )
|
vips_foreign_load_png_buffer_is_a_buffer( const void *buf, size_t len )
|
||||||
@ -290,73 +350,12 @@ vips_foreign_load_png_buffer_is_a_buffer( const void *buf, size_t len )
|
|||||||
|
|
||||||
if( !(streami = vips_streami_new_from_memory( buf, len )) )
|
if( !(streami = vips_streami_new_from_memory( buf, len )) )
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
result = vips__png_ispng_stream( streami );
|
result = vips_foreign_load_png_stream_is_a_stream( streami );
|
||||||
VIPS_UNREF( streami );
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
static VipsForeignFlags
|
|
||||||
vips_foreign_load_png_buffer_get_flags( VipsForeignLoad *load )
|
|
||||||
{
|
|
||||||
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load;
|
|
||||||
|
|
||||||
VipsStreami *streami;
|
|
||||||
VipsForeignFlags flags;
|
|
||||||
|
|
||||||
if( !(streami = vips_streami_new_from_memory( buffer->buf->data,
|
|
||||||
buffer->buf->length )) )
|
|
||||||
return( 0 );
|
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
if( vips__png_isinterlaced_stream( streami ) )
|
|
||||||
flags |= VIPS_FOREIGN_PARTIAL;
|
|
||||||
else
|
|
||||||
flags |= VIPS_FOREIGN_SEQUENTIAL;
|
|
||||||
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
|
|
||||||
return( flags );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
vips_foreign_load_png_buffer_header( VipsForeignLoad *load )
|
|
||||||
{
|
|
||||||
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load;
|
|
||||||
|
|
||||||
VipsStreami *streami;
|
|
||||||
|
|
||||||
if( !(streami = vips_streami_new_from_memory( buffer->buf->data,
|
|
||||||
buffer->buf->length )) )
|
|
||||||
return( -1 );
|
|
||||||
if( vips__png_header_stream( streami, load->out ) ) {
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
vips_foreign_load_png_buffer_load( VipsForeignLoad *load )
|
|
||||||
{
|
|
||||||
VipsForeignLoadPngBuffer *buffer = (VipsForeignLoadPngBuffer *) load;
|
|
||||||
|
|
||||||
VipsStreami *streami;
|
|
||||||
|
|
||||||
if( !(streami = vips_streami_new_from_memory( buffer->buf->data,
|
|
||||||
buffer->buf->length )) )
|
|
||||||
return( -1 );
|
|
||||||
if( vips__png_read_stream( streami, load->real, load->fail ) ) {
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_foreign_load_png_buffer_class_init( VipsForeignLoadPngBufferClass *class )
|
vips_foreign_load_png_buffer_class_init( VipsForeignLoadPngBufferClass *class )
|
||||||
{
|
{
|
||||||
@ -369,11 +368,9 @@ vips_foreign_load_png_buffer_class_init( VipsForeignLoadPngBufferClass *class )
|
|||||||
|
|
||||||
object_class->nickname = "pngload_buffer";
|
object_class->nickname = "pngload_buffer";
|
||||||
object_class->description = _( "load png from buffer" );
|
object_class->description = _( "load png from buffer" );
|
||||||
|
object_class->build = vips_foreign_load_png_buffer_build;
|
||||||
|
|
||||||
load_class->is_a_buffer = vips_foreign_load_png_buffer_is_a_buffer;
|
load_class->is_a_buffer = vips_foreign_load_png_buffer_is_a_buffer;
|
||||||
load_class->get_flags = vips_foreign_load_png_buffer_get_flags;
|
|
||||||
load_class->header = vips_foreign_load_png_buffer_header;
|
|
||||||
load_class->load = vips_foreign_load_png_buffer_load;
|
|
||||||
|
|
||||||
VIPS_ARG_BOXED( class, "buffer", 1,
|
VIPS_ARG_BOXED( class, "buffer", 1,
|
||||||
_( "Buffer" ),
|
_( "Buffer" ),
|
||||||
|
@ -77,40 +77,6 @@ vips_foreign_load_rad_dispose( GObject *gobject )
|
|||||||
dispose( gobject );
|
dispose( gobject );
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
vips_foreign_load_rad_is_a_stream( VipsStreami *streami )
|
|
||||||
{
|
|
||||||
return( vips__rad_israd( streami ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
vips_foreign_load_rad_is_a( const char *filename )
|
|
||||||
{
|
|
||||||
VipsStreami *streami;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
if( !(streami = vips_streami_new_from_file( filename )) )
|
|
||||||
return( -1 );
|
|
||||||
result = vips_foreign_load_rad_is_a_stream( streami );
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
|
|
||||||
return( result );
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
vips_foreign_load_rad_is_a_buffer( const void *buf, size_t len )
|
|
||||||
{
|
|
||||||
VipsStreami *streami;
|
|
||||||
gboolean result;
|
|
||||||
|
|
||||||
if( !(streami = vips_streami_new_from_memory( buf, len )) )
|
|
||||||
return( FALSE );
|
|
||||||
result = vips_foreign_load_rad_is_a_stream( streami );
|
|
||||||
VIPS_UNREF( streami );
|
|
||||||
|
|
||||||
return( result );
|
|
||||||
}
|
|
||||||
|
|
||||||
static VipsForeignFlags
|
static VipsForeignFlags
|
||||||
vips_foreign_load_rad_get_flags( VipsForeignLoad *load )
|
vips_foreign_load_rad_get_flags( VipsForeignLoad *load )
|
||||||
{
|
{
|
||||||
@ -158,15 +124,10 @@ vips_foreign_load_rad_class_init( VipsForeignLoadRadClass *class )
|
|||||||
object_class->nickname = "radload_base";
|
object_class->nickname = "radload_base";
|
||||||
object_class->description = _( "load rad base class" );
|
object_class->description = _( "load rad base class" );
|
||||||
|
|
||||||
foreign_class->suffs = vips__rad_suffs;
|
|
||||||
|
|
||||||
/* is_a() is not that quick ... lower the priority.
|
/* is_a() is not that quick ... lower the priority.
|
||||||
*/
|
*/
|
||||||
foreign_class->priority = -50;
|
foreign_class->priority = -50;
|
||||||
|
|
||||||
load_class->is_a = vips_foreign_load_rad_is_a;
|
|
||||||
load_class->is_a_buffer = vips_foreign_load_rad_is_a_buffer;
|
|
||||||
load_class->is_a_stream = vips_foreign_load_rad_is_a_stream;
|
|
||||||
load_class->get_flags_filename =
|
load_class->get_flags_filename =
|
||||||
vips_foreign_load_rad_get_flags_filename;
|
vips_foreign_load_rad_get_flags_filename;
|
||||||
load_class->get_flags = vips_foreign_load_rad_get_flags;
|
load_class->get_flags = vips_foreign_load_rad_get_flags;
|
||||||
@ -202,7 +163,7 @@ vips_foreign_load_rad_stream_build( VipsObject *object )
|
|||||||
|
|
||||||
if( stream->streami ) {
|
if( stream->streami ) {
|
||||||
rad->streami = stream->streami;
|
rad->streami = stream->streami;
|
||||||
g_object_ref( stream->streami );
|
g_object_ref( rad->streami );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_foreign_load_rad_stream_parent_class )->
|
if( VIPS_OBJECT_CLASS( vips_foreign_load_rad_stream_parent_class )->
|
||||||
@ -212,11 +173,18 @@ vips_foreign_load_rad_stream_build( VipsObject *object )
|
|||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
vips_foreign_load_rad_stream_is_a_stream( VipsStreami *streami )
|
||||||
|
{
|
||||||
|
return( vips__rad_israd( streami ) );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_foreign_load_rad_stream_class_init( VipsForeignLoadRadStreamClass *class )
|
vips_foreign_load_rad_stream_class_init( VipsForeignLoadRadStreamClass *class )
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||||
|
VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class;
|
||||||
|
|
||||||
gobject_class->set_property = vips_object_set_property;
|
gobject_class->set_property = vips_object_set_property;
|
||||||
gobject_class->get_property = vips_object_get_property;
|
gobject_class->get_property = vips_object_get_property;
|
||||||
@ -225,6 +193,8 @@ vips_foreign_load_rad_stream_class_init( VipsForeignLoadRadStreamClass *class )
|
|||||||
object_class->description = _( "load rad from stream" );
|
object_class->description = _( "load rad from stream" );
|
||||||
object_class->build = vips_foreign_load_rad_stream_build;
|
object_class->build = vips_foreign_load_rad_stream_build;
|
||||||
|
|
||||||
|
load_class->is_a_stream = vips_foreign_load_rad_stream_is_a_stream;
|
||||||
|
|
||||||
VIPS_ARG_OBJECT( class, "streami", 1,
|
VIPS_ARG_OBJECT( class, "streami", 1,
|
||||||
_( "Streami" ),
|
_( "Streami" ),
|
||||||
_( "Stream to load from" ),
|
_( "Stream to load from" ),
|
||||||
@ -270,11 +240,27 @@ vips_foreign_load_rad_file_build( VipsObject *object )
|
|||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vips_foreign_load_rad_file_is_a( const char *filename )
|
||||||
|
{
|
||||||
|
VipsStreami *streami;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if( !(streami = vips_streami_new_from_file( filename )) )
|
||||||
|
return( -1 );
|
||||||
|
result = vips_foreign_load_rad_stream_is_a_stream( streami );
|
||||||
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
|
return( result );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_foreign_load_rad_file_class_init( VipsForeignLoadRadFileClass *class )
|
vips_foreign_load_rad_file_class_init( VipsForeignLoadRadFileClass *class )
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||||
|
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||||
|
VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class;
|
||||||
|
|
||||||
gobject_class->set_property = vips_object_set_property;
|
gobject_class->set_property = vips_object_set_property;
|
||||||
gobject_class->get_property = vips_object_get_property;
|
gobject_class->get_property = vips_object_get_property;
|
||||||
@ -283,6 +269,10 @@ vips_foreign_load_rad_file_class_init( VipsForeignLoadRadFileClass *class )
|
|||||||
object_class->description = _( "load a Radiance image from a file" );
|
object_class->description = _( "load a Radiance image from a file" );
|
||||||
object_class->build = vips_foreign_load_rad_file_build;
|
object_class->build = vips_foreign_load_rad_file_build;
|
||||||
|
|
||||||
|
foreign_class->suffs = vips__rad_suffs;
|
||||||
|
|
||||||
|
load_class->is_a = vips_foreign_load_rad_file_is_a;
|
||||||
|
|
||||||
VIPS_ARG_STRING( class, "filename", 1,
|
VIPS_ARG_STRING( class, "filename", 1,
|
||||||
_( "Filename" ),
|
_( "Filename" ),
|
||||||
_( "Filename to load from" ),
|
_( "Filename to load from" ),
|
||||||
@ -328,11 +318,26 @@ vips_foreign_load_rad_buffer_build( VipsObject *object )
|
|||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
vips_foreign_load_rad_buffer_is_a_buffer( const void *buf, size_t len )
|
||||||
|
{
|
||||||
|
VipsStreami *streami;
|
||||||
|
gboolean result;
|
||||||
|
|
||||||
|
if( !(streami = vips_streami_new_from_memory( buf, len )) )
|
||||||
|
return( FALSE );
|
||||||
|
result = vips_foreign_load_rad_stream_is_a_stream( streami );
|
||||||
|
VIPS_UNREF( streami );
|
||||||
|
|
||||||
|
return( result );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vips_foreign_load_rad_buffer_class_init( VipsForeignLoadRadBufferClass *class )
|
vips_foreign_load_rad_buffer_class_init( VipsForeignLoadRadBufferClass *class )
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||||
|
VipsForeignLoadClass *load_class = (VipsForeignLoadClass *) class;
|
||||||
|
|
||||||
gobject_class->set_property = vips_object_set_property;
|
gobject_class->set_property = vips_object_set_property;
|
||||||
gobject_class->get_property = vips_object_get_property;
|
gobject_class->get_property = vips_object_get_property;
|
||||||
@ -341,6 +346,8 @@ vips_foreign_load_rad_buffer_class_init( VipsForeignLoadRadBufferClass *class )
|
|||||||
object_class->description = _( "load rad from buffer" );
|
object_class->description = _( "load rad from buffer" );
|
||||||
object_class->build = vips_foreign_load_rad_buffer_build;
|
object_class->build = vips_foreign_load_rad_buffer_build;
|
||||||
|
|
||||||
|
load_class->is_a_buffer = vips_foreign_load_rad_buffer_is_a_buffer;
|
||||||
|
|
||||||
VIPS_ARG_BOXED( class, "buffer", 1,
|
VIPS_ARG_BOXED( class, "buffer", 1,
|
||||||
_( "Buffer" ),
|
_( "Buffer" ),
|
||||||
_( "Buffer to load from" ),
|
_( "Buffer to load from" ),
|
||||||
|
@ -767,7 +767,7 @@ G_DEFINE_TYPE( VipsForeignLoadSvgStream, vips_foreign_load_svg_stream,
|
|||||||
vips_foreign_load_svg_get_type() );
|
vips_foreign_load_svg_get_type() );
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
vips_foreign_load_svg_stream_is_a( VipsStreami *streami )
|
vips_foreign_load_svg_stream_is_a_stream( VipsStreami *streami )
|
||||||
{
|
{
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
size_t bytes_read;
|
size_t bytes_read;
|
||||||
@ -832,7 +832,7 @@ vips_foreign_load_svg_stream_class_init( VipsForeignLoadSvgStreamClass *class )
|
|||||||
object_class->nickname = "svgload_stream";
|
object_class->nickname = "svgload_stream";
|
||||||
object_class->description = _( "load svg from stream" );
|
object_class->description = _( "load svg from stream" );
|
||||||
|
|
||||||
load_class->is_a_stream = vips_foreign_load_svg_stream_is_a;
|
load_class->is_a_stream = vips_foreign_load_svg_stream_is_a_stream;
|
||||||
load_class->header = vips_foreign_load_svg_stream_header;
|
load_class->header = vips_foreign_load_svg_stream_header;
|
||||||
load_class->load = vips_foreign_load_svg_stream_load;
|
load_class->load = vips_foreign_load_svg_stream_load;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user