move rad over to the new thing
This commit is contained in:
parent
6864739351
commit
3e45e2cd6b
@ -16,7 +16,7 @@
|
|||||||
im_vips2jpeg*(), im_tiff2vips(), im_vips2tiff(), im_exr2vips(),
|
im_vips2jpeg*(), im_tiff2vips(), im_vips2tiff(), im_exr2vips(),
|
||||||
im_fits2vips(), im_vips2fits(), im_analyze2vips(), im_raw2vips(),
|
im_fits2vips(), im_vips2fits(), im_analyze2vips(), im_raw2vips(),
|
||||||
im_vips2raw(), im_magick2vips(), im_png2vips(), im_png2*(), im_ppm2vips(),
|
im_vips2raw(), im_magick2vips(), im_png2vips(), im_png2*(), im_ppm2vips(),
|
||||||
im_vips2ppm()
|
im_vips2ppm(), im_mat2vips(), im_rad2vips(), im_vips2rad()
|
||||||
redone as classes
|
redone as classes
|
||||||
- added argument priorites to help control arg ordering
|
- added argument priorites to help control arg ordering
|
||||||
- generate has a 'stop' param to signal successful early termination
|
- generate has a 'stop' param to signal successful early termination
|
||||||
|
4
TODO
4
TODO
@ -1,5 +1,9 @@
|
|||||||
- vips2bufpng() is leaky
|
- vips2bufpng() is leaky
|
||||||
|
|
||||||
|
- test rad read/write
|
||||||
|
|
||||||
|
- rad save should auto pack to CODING RAD
|
||||||
|
|
||||||
- test matio load
|
- test matio load
|
||||||
|
|
||||||
- radiance to go still
|
- radiance to go still
|
||||||
|
@ -772,7 +772,7 @@ vips_LabQ2disp( VipsImage *in, VipsImage **out,
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, disp );
|
va_start( ap, disp );
|
||||||
result = vips_call_split( "im_LabQ2disp", ap, in, out, disp );
|
result = vips_call_split( "LabQ2disp", ap, in, out, disp );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -785,7 +785,20 @@ vips_rad2float( VipsImage *in, VipsImage **out, ... )
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "im_rad2float", ap, in, out );
|
result = vips_call_split( "rad2float", ap, in, out );
|
||||||
|
va_end( ap );
|
||||||
|
|
||||||
|
return( result );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
vips_float2rad( VipsImage *in, VipsImage **out, ... )
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
va_start( ap, out );
|
||||||
|
result = vips_call_split( "float2rad", ap, in, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -798,7 +811,7 @@ vips_LabS2LabQ( VipsImage *in, VipsImage **out, ... )
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "im_LabS2LabQ", ap, in, out );
|
result = vips_call_split( "LabS2LabQ", ap, in, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -811,7 +824,20 @@ vips_LabQ2Lab( VipsImage *in, VipsImage **out, ... )
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "im_LabQ2Lab", ap, in, out );
|
result = vips_call_split( "LabQ2Lab", ap, in, out );
|
||||||
|
va_end( ap );
|
||||||
|
|
||||||
|
return( result );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
vips_Lab2LabQ( VipsImage *in, VipsImage **out, ... )
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
va_start( ap, out );
|
||||||
|
result = vips_call_split( "Lab2LabQ", ap, in, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -824,7 +850,7 @@ vips_LCh2Lab( VipsImage *in, VipsImage **out, ... )
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "im_LCh2Lab", ap, in, out );
|
result = vips_call_split( "LCh2Lab", ap, in, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -837,7 +863,7 @@ vips_Yxy2Lab( VipsImage *in, VipsImage **out, ... )
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "im_Yxy2Lab", ap, in, out );
|
result = vips_call_split( "Yxy2Lab", ap, in, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -850,7 +876,7 @@ vips_UCS2XYZ( VipsImage *in, VipsImage **out, ... )
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "im_UCS2XYZ", ap, in, out );
|
result = vips_call_split( "UCS2XYZ", ap, in, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -863,7 +889,7 @@ vips_Lab2XYZ( VipsImage *in, VipsImage **out, ... )
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, out );
|
va_start( ap, out );
|
||||||
result = vips_call_split( "im_Lab2XYZ", ap, in, out );
|
result = vips_call_split( "Lab2XYZ", ap, in, out );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
@ -877,7 +903,7 @@ vips_XYZ2disp( VipsImage *in, VipsImage **out,
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
va_start( ap, disp );
|
va_start( ap, disp );
|
||||||
result = vips_call_split( "im_XYZ2disp", ap, in, out, disp );
|
result = vips_call_split( "XYZ2disp", ap, in, out, disp );
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
return( result );
|
return( result );
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
noinst_LTLIBRARIES = libforeign.la
|
noinst_LTLIBRARIES = libforeign.la
|
||||||
|
|
||||||
libforeign_la_SOURCES = \
|
libforeign_la_SOURCES = \
|
||||||
|
radiance.h \
|
||||||
|
radiance.c \
|
||||||
|
radload.c \
|
||||||
|
radsave.c \
|
||||||
ppm.h \
|
ppm.h \
|
||||||
ppm.c \
|
ppm.c \
|
||||||
ppmload.c \
|
ppmload.c \
|
||||||
|
@ -348,26 +348,27 @@ vips_foreign_load_print_class( VipsObjectClass *object_class, VipsBuf *buf )
|
|||||||
VIPS_OBJECT_CLASS( vips_foreign_load_parent_class )->
|
VIPS_OBJECT_CLASS( vips_foreign_load_parent_class )->
|
||||||
print_class( object_class, buf );
|
print_class( object_class, buf );
|
||||||
|
|
||||||
if( class->is_a )
|
if( !G_TYPE_IS_ABSTRACT( G_TYPE_FROM_CLASS( class ) ) ) {
|
||||||
vips_buf_appends( buf, ", is_a" );
|
if( class->is_a )
|
||||||
if( class->get_flags )
|
vips_buf_appends( buf, ", is_a" );
|
||||||
vips_buf_appends( buf, ", get_flags" );
|
if( class->get_flags )
|
||||||
if( class->get_flags_filename )
|
vips_buf_appends( buf, ", get_flags" );
|
||||||
vips_buf_appends( buf, ", get_flags_filename" );
|
if( class->get_flags_filename )
|
||||||
if( class->header )
|
vips_buf_appends( buf, ", get_flags_filename" );
|
||||||
vips_buf_appends( buf, ", header" );
|
if( class->header )
|
||||||
if( class->load )
|
vips_buf_appends( buf, ", header" );
|
||||||
vips_buf_appends( buf, ", load" );
|
if( class->load )
|
||||||
|
vips_buf_appends( buf, ", load" );
|
||||||
|
|
||||||
/* Sanity: it's OK to have get_flags() and get_flags_filename() both
|
/* Sanity: it's OK to have get_flags() and
|
||||||
* NULL or both not-NULL.
|
* get_flags_filename() both NULL or both not-NULL.
|
||||||
*/
|
*/
|
||||||
g_assert( (void *) class->get_flags !=
|
g_assert( !class->get_flags == !class->get_flags_filename );
|
||||||
(void *) class->get_flags_filename );
|
|
||||||
|
|
||||||
/* You can omit ->load(), you must not omit ->header().
|
/* You can omit ->load(), you must not omit ->header().
|
||||||
*/
|
*/
|
||||||
g_assert( class->header );
|
g_assert( class->header );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Can this VipsForeign open this file?
|
/* Can this VipsForeign open this file?
|
||||||
@ -800,6 +801,21 @@ vips_foreign_convert_saveable( VipsForeignSave *save )
|
|||||||
*/
|
*/
|
||||||
g_object_ref( in );
|
g_object_ref( in );
|
||||||
|
|
||||||
|
/* Does this class want a coded image we are already in? Nothing to
|
||||||
|
* do.
|
||||||
|
*/
|
||||||
|
if( class->coding != VIPS_CODING_NONE &&
|
||||||
|
class->coding == in->Coding ) {
|
||||||
|
VIPS_UNREF( save->ready );
|
||||||
|
save->ready = in;
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise ... we need to decode and then (possibly) recode at the
|
||||||
|
* end.
|
||||||
|
*/
|
||||||
|
|
||||||
/* If this is an VIPS_CODING_LABQ, we can go straight to RGB.
|
/* If this is an VIPS_CODING_LABQ, we can go straight to RGB.
|
||||||
*/
|
*/
|
||||||
if( in->Coding == VIPS_CODING_LABQ ) {
|
if( in->Coding == VIPS_CODING_LABQ ) {
|
||||||
@ -990,6 +1006,34 @@ vips_foreign_convert_saveable( VipsForeignSave *save )
|
|||||||
in = out;
|
in = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Does this class want a coded image? The format_table[] should have
|
||||||
|
* got the format right for us.
|
||||||
|
*/
|
||||||
|
if( class->coding != VIPS_CODING_NONE ) {
|
||||||
|
if( class->coding == VIPS_CODING_RAD ) {
|
||||||
|
VipsImage *out;
|
||||||
|
|
||||||
|
if( vips_float2rad( in, &out, NULL ) ) {
|
||||||
|
g_object_unref( in );
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
g_object_unref( in );
|
||||||
|
|
||||||
|
in = out;
|
||||||
|
}
|
||||||
|
else if( class->coding == VIPS_CODING_LABQ ) {
|
||||||
|
VipsImage *out;
|
||||||
|
|
||||||
|
if( vips_Lab2LabQ( in, &out, NULL ) ) {
|
||||||
|
g_object_unref( in );
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
g_object_unref( in );
|
||||||
|
|
||||||
|
in = out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VIPS_UNREF( save->ready );
|
VIPS_UNREF( save->ready );
|
||||||
save->ready = in;
|
save->ready = in;
|
||||||
|
|
||||||
@ -1027,6 +1071,8 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class )
|
|||||||
object_class->nickname = "filesave";
|
object_class->nickname = "filesave";
|
||||||
object_class->description = _( "file savers" );
|
object_class->description = _( "file savers" );
|
||||||
|
|
||||||
|
class->coding = VIPS_CODING_NONE;
|
||||||
|
|
||||||
VIPS_ARG_IMAGE( class, "in", 0,
|
VIPS_ARG_IMAGE( class, "in", 0,
|
||||||
_( "Input" ),
|
_( "Input" ),
|
||||||
_( "Image to save" ),
|
_( "Image to save" ),
|
||||||
@ -1194,6 +1240,8 @@ vips_foreign_write_options( VipsImage *in, const char *filename )
|
|||||||
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_save_rad_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_get_type( void );
|
extern GType vips_foreign_load_ppm_get_type( void );
|
||||||
extern GType vips_foreign_save_ppm_get_type( void );
|
extern GType vips_foreign_save_ppm_get_type( void );
|
||||||
@ -1221,6 +1269,8 @@ vips_foreign_operation_init( void )
|
|||||||
extern GType vips_foreign_save_rawfd_get_type( void );
|
extern GType vips_foreign_save_rawfd_get_type( void );
|
||||||
extern GType vips_foreign_load_magick_get_type( void );
|
extern GType vips_foreign_load_magick_get_type( void );
|
||||||
|
|
||||||
|
vips_foreign_load_rad_get_type();
|
||||||
|
vips_foreign_save_rad_get_type();
|
||||||
vips_foreign_load_ppm_get_type();
|
vips_foreign_load_ppm_get_type();
|
||||||
vips_foreign_save_ppm_get_type();
|
vips_foreign_save_ppm_get_type();
|
||||||
vips_foreign_load_csv_get_type();
|
vips_foreign_load_csv_get_type();
|
||||||
|
@ -135,6 +135,8 @@ vips_foreign_load_magick_class_init( VipsForeignLoadMagickClass *class )
|
|||||||
foreign_class->priority = -100;
|
foreign_class->priority = -100;
|
||||||
|
|
||||||
load_class->is_a = ismagick;
|
load_class->is_a = ismagick;
|
||||||
|
load_class->get_flags_filename =
|
||||||
|
vips_foreign_load_magick_get_flags_filename;
|
||||||
load_class->get_flags = vips_foreign_load_magick_get_flags;
|
load_class->get_flags = vips_foreign_load_magick_get_flags;
|
||||||
load_class->header = vips_foreign_load_magick_header;
|
load_class->header = vips_foreign_load_magick_header;
|
||||||
load_class->load = vips_foreign_load_magick_load;
|
load_class->load = vips_foreign_load_magick_load;
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
*
|
*
|
||||||
* 4/8/09
|
* 4/8/09
|
||||||
* - transpose on load, assemble planes into bands (thanks Mikhail)
|
* - transpose on load, assemble planes into bands (thanks Mikhail)
|
||||||
|
* 20/12/11
|
||||||
|
* - reworked as some fns ready for new-style classes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -55,7 +57,6 @@
|
|||||||
#include <vips/intl.h>
|
#include <vips/intl.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
|
@ -71,6 +71,15 @@ typedef VipsForeignLoadClass VipsForeignLoadOpenslideClass;
|
|||||||
G_DEFINE_TYPE( VipsForeignLoadOpenslide, vips_foreign_load_openslide,
|
G_DEFINE_TYPE( VipsForeignLoadOpenslide, vips_foreign_load_openslide,
|
||||||
VIPS_TYPE_FOREIGN_LOAD );
|
VIPS_TYPE_FOREIGN_LOAD );
|
||||||
|
|
||||||
|
static VipsForeignFlags
|
||||||
|
vips_foreign_load_openslide_get_flags_filename( const char *filename )
|
||||||
|
{
|
||||||
|
/* We can't tell from just the filename, we need to know what part of
|
||||||
|
* the file the user wants. But it'll usually be partial.
|
||||||
|
*/
|
||||||
|
return( VIPS_FOREIGN_PARTIAL );
|
||||||
|
}
|
||||||
|
|
||||||
static VipsForeignFlags
|
static VipsForeignFlags
|
||||||
vips_foreign_load_openslide_get_flags( VipsForeignLoad *load )
|
vips_foreign_load_openslide_get_flags( VipsForeignLoad *load )
|
||||||
{
|
{
|
||||||
@ -154,6 +163,8 @@ vips_foreign_load_openslide_class_init( VipsForeignLoadOpenslideClass *class )
|
|||||||
foreign_class->suffs = vips_foreign_openslide_suffs;
|
foreign_class->suffs = vips_foreign_openslide_suffs;
|
||||||
|
|
||||||
load_class->is_a = vips__openslide_isslide;
|
load_class->is_a = vips__openslide_isslide;
|
||||||
|
load_class->get_flags_filename =
|
||||||
|
vips_foreign_load_openslide_get_flags_filename;
|
||||||
load_class->get_flags = vips_foreign_load_openslide_get_flags;
|
load_class->get_flags = vips_foreign_load_openslide_get_flags;
|
||||||
load_class->header = vips_foreign_load_openslide_header;
|
load_class->header = vips_foreign_load_openslide_header;
|
||||||
load_class->load = vips_foreign_load_openslide_load;
|
load_class->load = vips_foreign_load_openslide_load;
|
||||||
|
1143
libvips/foreign/radiance.c
Normal file
1143
libvips/foreign/radiance.c
Normal file
File diff suppressed because it is too large
Load Diff
49
libvips/foreign/radiance.h
Normal file
49
libvips/foreign/radiance.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* common defs for ppm read/write
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (C) 1991-2005 The National Gallery
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VIPS_RADIANCE_H
|
||||||
|
#define VIPS_RADIANCE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /*__cplusplus*/
|
||||||
|
|
||||||
|
int vips__rad_israd( const char *filename );
|
||||||
|
int vips__rad_header( const char *filename, VipsImage *out );
|
||||||
|
int vips__rad_load( const char *filename, VipsImage *out );
|
||||||
|
|
||||||
|
int vips__rad_save( VipsImage *in, const char *filename );
|
||||||
|
|
||||||
|
extern const char *vips__rad_suffs[];
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /*__cplusplus*/
|
||||||
|
|
||||||
|
#endif /*VIPS_RADIANCE_H*/
|
174
libvips/foreign/radload.c
Normal file
174
libvips/foreign/radload.c
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
/* load radlab from a file
|
||||||
|
*
|
||||||
|
* 5/12/11
|
||||||
|
* - from tiffload.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
This file is part of VIPS.
|
||||||
|
|
||||||
|
VIPS is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define DEBUG
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif /*HAVE_CONFIG_H*/
|
||||||
|
#include <vips/intl.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <vips/vips.h>
|
||||||
|
#include <vips/buf.h>
|
||||||
|
#include <vips/internal.h>
|
||||||
|
|
||||||
|
#include "radiance.h"
|
||||||
|
|
||||||
|
typedef struct _VipsForeignLoadRad {
|
||||||
|
VipsForeignLoad parent_object;
|
||||||
|
|
||||||
|
/* Filename for load.
|
||||||
|
*/
|
||||||
|
char *filename;
|
||||||
|
|
||||||
|
} VipsForeignLoadRad;
|
||||||
|
|
||||||
|
typedef VipsForeignLoadClass VipsForeignLoadRadClass;
|
||||||
|
|
||||||
|
G_DEFINE_TYPE( VipsForeignLoadRad, vips_foreign_load_rad,
|
||||||
|
VIPS_TYPE_FOREIGN_LOAD );
|
||||||
|
|
||||||
|
static VipsForeignFlags
|
||||||
|
vips_foreign_load_rad_get_flags_filename( const char *filename )
|
||||||
|
{
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
static VipsForeignFlags
|
||||||
|
vips_foreign_load_rad_get_flags( VipsForeignLoad *load )
|
||||||
|
{
|
||||||
|
VipsForeignLoadRad *rad = (VipsForeignLoadRad *) load;
|
||||||
|
|
||||||
|
return( vips_foreign_load_rad_get_flags_filename( rad->filename ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vips_foreign_load_rad_header( VipsForeignLoad *load )
|
||||||
|
{
|
||||||
|
VipsForeignLoadRad *rad = (VipsForeignLoadRad *) load;
|
||||||
|
|
||||||
|
if( vips__rad_header( rad->filename, load->out ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vips_foreign_load_rad_load( VipsForeignLoad *load )
|
||||||
|
{
|
||||||
|
VipsForeignLoadRad *rad = (VipsForeignLoadRad *) load;
|
||||||
|
|
||||||
|
if( vips__rad_load( rad->filename, load->real ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vips_foreign_load_rad_class_init( VipsForeignLoadRadClass *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->set_property = vips_object_set_property;
|
||||||
|
gobject_class->get_property = vips_object_get_property;
|
||||||
|
|
||||||
|
object_class->nickname = "radload";
|
||||||
|
object_class->description = _( "load a Radiance image from a file" );
|
||||||
|
|
||||||
|
foreign_class->suffs = vips__rad_suffs;
|
||||||
|
|
||||||
|
load_class->is_a = vips__rad_israd;
|
||||||
|
load_class->get_flags_filename =
|
||||||
|
vips_foreign_load_rad_get_flags_filename;
|
||||||
|
load_class->get_flags = vips_foreign_load_rad_get_flags;
|
||||||
|
load_class->header = vips_foreign_load_rad_header;
|
||||||
|
load_class->load = vips_foreign_load_rad_load;
|
||||||
|
|
||||||
|
VIPS_ARG_STRING( class, "filename", 1,
|
||||||
|
_( "Filename" ),
|
||||||
|
_( "Filename to load from" ),
|
||||||
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsForeignLoadRad, filename ),
|
||||||
|
NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vips_foreign_load_rad_init( VipsForeignLoadRad *rad )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vips_radload:
|
||||||
|
* @filename: file to load
|
||||||
|
* @out: output image
|
||||||
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
|
*
|
||||||
|
* Read a Radiance (HDR) file into a VIPS image.
|
||||||
|
*
|
||||||
|
* Radiance files are read as #VIPS_CODING_RAD. They have one byte for each of
|
||||||
|
* red, green and blue, and one byte of shared exponent. Some operations (like
|
||||||
|
* vips_extract_area()) can work directly with images in this format, but
|
||||||
|
* mmany (all the arithmetic operations, for example) will not. Unpack
|
||||||
|
* #VIPS_CODING_RAD images to 3 band float with im_rad2float() if you want to do
|
||||||
|
* arithmetic on them.
|
||||||
|
*
|
||||||
|
* This operation ignores some header fields, like VIEW and DATE. It will not
|
||||||
|
* rotate/flip as the FORMAT string asks.
|
||||||
|
*
|
||||||
|
* Sections of this reader from Greg Ward and Radiance with kind permission.
|
||||||
|
*
|
||||||
|
* See also: vips_image_new_from_file().
|
||||||
|
*
|
||||||
|
* Returns: 0 on success, -1 on error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
vips_radload( const char *filename, VipsImage **out, ... )
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
va_start( ap, out );
|
||||||
|
result = vips_call_split( "radload", ap, filename, out );
|
||||||
|
va_end( ap );
|
||||||
|
|
||||||
|
return( result );
|
||||||
|
}
|
||||||
|
|
155
libvips/foreign/radsave.c
Normal file
155
libvips/foreign/radsave.c
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
/* save to rad
|
||||||
|
*
|
||||||
|
* 2/12/11
|
||||||
|
* - wrap a class around the rad writer
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
This file is part of VIPS.
|
||||||
|
|
||||||
|
VIPS is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define DEBUG_VERBOSE
|
||||||
|
#define DEBUG
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif /*HAVE_CONFIG_H*/
|
||||||
|
#include <vips/intl.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <vips/vips.h>
|
||||||
|
|
||||||
|
#include "radiance.h"
|
||||||
|
|
||||||
|
typedef struct _VipsForeignSaveRad {
|
||||||
|
VipsForeignSave parent_object;
|
||||||
|
|
||||||
|
char *filename;
|
||||||
|
} VipsForeignSaveRad;
|
||||||
|
|
||||||
|
typedef VipsForeignSaveClass VipsForeignSaveRadClass;
|
||||||
|
|
||||||
|
G_DEFINE_TYPE( VipsForeignSaveRad, vips_foreign_save_rad,
|
||||||
|
VIPS_TYPE_FOREIGN_SAVE );
|
||||||
|
|
||||||
|
static int
|
||||||
|
vips_foreign_save_rad_build( VipsObject *object )
|
||||||
|
{
|
||||||
|
VipsForeignSave *save = (VipsForeignSave *) object;
|
||||||
|
VipsForeignSaveRad *rad = (VipsForeignSaveRad *) object;
|
||||||
|
|
||||||
|
if( VIPS_OBJECT_CLASS( vips_foreign_save_rad_parent_class )->
|
||||||
|
build( object ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
if( vips__rad_save( save->ready, rad->filename ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save a bit of typing.
|
||||||
|
*/
|
||||||
|
#define UC VIPS_FORMAT_UCHAR
|
||||||
|
#define C VIPS_FORMAT_CHAR
|
||||||
|
#define US VIPS_FORMAT_USHORT
|
||||||
|
#define S VIPS_FORMAT_SHORT
|
||||||
|
#define UI VIPS_FORMAT_UINT
|
||||||
|
#define I VIPS_FORMAT_INT
|
||||||
|
#define F VIPS_FORMAT_FLOAT
|
||||||
|
#define X VIPS_FORMAT_COMPLEX
|
||||||
|
#define D VIPS_FORMAT_DOUBLE
|
||||||
|
#define DX VIPS_FORMAT_DPCOMPLEX
|
||||||
|
|
||||||
|
static int bandfmt_rad[10] = {
|
||||||
|
/* UC C US S UI I F X D DX */
|
||||||
|
F, F, F, F, F, F, F, F, F, F
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
vips_foreign_save_rad_class_init( VipsForeignSaveRadClass *class )
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||||
|
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||||
|
VipsForeignClass *foreign_class = (VipsForeignClass *) class;
|
||||||
|
VipsForeignSaveClass *save_class = (VipsForeignSaveClass *) class;
|
||||||
|
|
||||||
|
gobject_class->set_property = vips_object_set_property;
|
||||||
|
gobject_class->get_property = vips_object_get_property;
|
||||||
|
|
||||||
|
object_class->nickname = "radsave";
|
||||||
|
object_class->description = _( "save image to Radiance file" );
|
||||||
|
object_class->build = vips_foreign_save_rad_build;
|
||||||
|
|
||||||
|
foreign_class->suffs = vips__rad_suffs;
|
||||||
|
|
||||||
|
save_class->saveable = VIPS_SAVEABLE_RGB;
|
||||||
|
save_class->format_table = bandfmt_rad;
|
||||||
|
save_class->coding = VIPS_CODING_RAD;
|
||||||
|
|
||||||
|
VIPS_ARG_STRING( class, "filename", 1,
|
||||||
|
_( "Filename" ),
|
||||||
|
_( "Filename to save to" ),
|
||||||
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsForeignSaveRad, filename ),
|
||||||
|
NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vips_foreign_save_rad_init( VipsForeignSaveRad *rad )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vips_radsave:
|
||||||
|
* @in: image to save
|
||||||
|
* @filename: file to write to
|
||||||
|
* @...: %NULL-terminated list of optional named arguments
|
||||||
|
*
|
||||||
|
* Write a VIPS image in Radiance (HDR) format.
|
||||||
|
*
|
||||||
|
* Sections of this reader from Greg Ward and Radiance with kind permission.
|
||||||
|
*
|
||||||
|
* See also: vips_image_write_file().
|
||||||
|
*
|
||||||
|
* Returns: 0 on success, -1 on error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
vips_radsave( VipsImage *in, const char *filename, ... )
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
va_start( ap, filename );
|
||||||
|
result = vips_call_split( "radsave", ap, in, filename );
|
||||||
|
va_end( ap );
|
||||||
|
|
||||||
|
return( result );
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -49,10 +49,14 @@ int vips_LabQ2disp( VipsImage *in, VipsImage **out,
|
|||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_rad2float( VipsImage *in, VipsImage **out, ... )
|
int vips_rad2float( VipsImage *in, VipsImage **out, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
|
int vips_float2rad( VipsImage *in, VipsImage **out, ... )
|
||||||
|
__attribute__((sentinel));
|
||||||
int vips_LabS2LabQ( VipsImage *in, VipsImage **out, ... )
|
int vips_LabS2LabQ( VipsImage *in, VipsImage **out, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_LabQ2Lab( VipsImage *in, VipsImage **out, ... )
|
int vips_LabQ2Lab( VipsImage *in, VipsImage **out, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
|
int vips_Lab2LabQ( VipsImage *in, VipsImage **out, ... )
|
||||||
|
__attribute__((sentinel));
|
||||||
int vips_LCh2Lab( VipsImage *in, VipsImage **out, ... )
|
int vips_LCh2Lab( VipsImage *in, VipsImage **out, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_Yxy2Lab( VipsImage *in, VipsImage **out, ... )
|
int vips_Yxy2Lab( VipsImage *in, VipsImage **out, ... )
|
||||||
|
@ -230,6 +230,10 @@ typedef struct _VipsForeignSaveClass {
|
|||||||
/* How this format treats band formats.
|
/* How this format treats band formats.
|
||||||
*/
|
*/
|
||||||
VipsBandFormat *format_table;
|
VipsBandFormat *format_table;
|
||||||
|
|
||||||
|
/* If this format needs a coding, the coding it wants (default NONE).
|
||||||
|
*/
|
||||||
|
VipsCoding coding;
|
||||||
} VipsForeignSaveClass;
|
} VipsForeignSaveClass;
|
||||||
|
|
||||||
GType vips_foreign_save_get_type( void );
|
GType vips_foreign_save_get_type( void );
|
||||||
@ -364,6 +368,11 @@ int vips_ppmsave( VipsImage *in, const char *filename, ... )
|
|||||||
int vips_matload( const char *filename, VipsImage **out, ... )
|
int vips_matload( const char *filename, VipsImage **out, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
|
|
||||||
|
int vips_radload( const char *filename, VipsImage **out, ... )
|
||||||
|
__attribute__((sentinel));
|
||||||
|
int vips_radsave( VipsImage *in, const char *filename, ... )
|
||||||
|
__attribute__((sentinel));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
Loading…
Reference in New Issue
Block a user