libvips builds
clean build, phew, try tools next
This commit is contained in:
parent
df0eab1f35
commit
bb813a21b5
@ -715,58 +715,3 @@ im_flood_other( IMAGE *test, IMAGE *mark,
|
|||||||
return( im_draw_flood_other( mark, test, x, y, serial, dout ) );
|
return( im_draw_flood_other( mark, test, x, y, serial, dout ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* im_initdesc:
|
|
||||||
* @image: image to init
|
|
||||||
* @xsize: image width
|
|
||||||
* @ysize: image height
|
|
||||||
* @bands: image bands
|
|
||||||
* @bandbits: ignored, just here for compatibility
|
|
||||||
* @bandfmt: band format
|
|
||||||
* @coding: image coding
|
|
||||||
* @type: image type
|
|
||||||
* @xres: horizontal resolution, pixels per millimetre
|
|
||||||
* @yres: vertical resolution, pixels per millimetre
|
|
||||||
* @xo: x offset
|
|
||||||
* @yo: y offset
|
|
||||||
*
|
|
||||||
* A convenience function to set the header fields after creating an image.
|
|
||||||
* Normally you copy the fields from one of your input images with
|
|
||||||
* im_cp_desc() and then make
|
|
||||||
* any adjustments you need, but if you are creating an image from scratch,
|
|
||||||
* for example im_black() or im_jpeg2vips(), you do need to set all the
|
|
||||||
* fields yourself.
|
|
||||||
*
|
|
||||||
* See also: im_cp_desc().
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
im_initdesc( IMAGE *image,
|
|
||||||
int xsize, int ysize, int bands, int bandbits,
|
|
||||||
VipsBandFmt bandfmt, VipsCoding coding, VipsType type,
|
|
||||||
float xres, float yres,
|
|
||||||
int xo, int yo )
|
|
||||||
{
|
|
||||||
image->Xsize = xsize;
|
|
||||||
image->Ysize = ysize;
|
|
||||||
image->Bands = bands;
|
|
||||||
/* bandbits is deprecated ... set to whatever the format requires.
|
|
||||||
*/
|
|
||||||
image->Bbits = im_bits_of_fmt( bandfmt );
|
|
||||||
image->BandFmt = bandfmt;
|
|
||||||
image->Coding = coding;
|
|
||||||
image->Type = type;
|
|
||||||
image->Xres = xres;
|
|
||||||
image->Yres = yres;
|
|
||||||
image->Xoffset = xo;
|
|
||||||
image->Yoffset = yo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Just here for compat.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
im_close( VipsImage *image )
|
|
||||||
{
|
|
||||||
g_object_unref( image );
|
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,6 @@ pkginclude_HEADERS = \
|
|||||||
arithmetic.h \
|
arithmetic.h \
|
||||||
boolean.h \
|
boolean.h \
|
||||||
buf.h \
|
buf.h \
|
||||||
callback.h \
|
|
||||||
check.h \
|
check.h \
|
||||||
colour.h \
|
colour.h \
|
||||||
conversion.h \
|
conversion.h \
|
||||||
@ -45,6 +44,7 @@ pkginclude_HEADERS = \
|
|||||||
util.h \
|
util.h \
|
||||||
version.h \
|
version.h \
|
||||||
vector.h \
|
vector.h \
|
||||||
|
vips7compat.h \
|
||||||
vips.h
|
vips.h
|
||||||
|
|
||||||
vipsc++.h:
|
vipsc++.h:
|
||||||
|
@ -229,8 +229,8 @@ typedef struct _VipsImage {
|
|||||||
/* Upstream/downstream relationships, built from args to
|
/* Upstream/downstream relationships, built from args to
|
||||||
* im_demand_hint().
|
* im_demand_hint().
|
||||||
*
|
*
|
||||||
* We use these to invalidate downstream pixel buffers on
|
* We use these to invalidate downstream pixel buffers.
|
||||||
* im_invalidate(). Use 'serial' to spot circular dependencies.
|
* Use 'serial' to spot circular dependencies.
|
||||||
*
|
*
|
||||||
* See also hint_set below.
|
* See also hint_set below.
|
||||||
*/
|
*/
|
||||||
@ -289,7 +289,7 @@ typedef struct _VipsImageClass {
|
|||||||
*/
|
*/
|
||||||
void (*written)( VipsImage *image );
|
void (*written)( VipsImage *image );
|
||||||
|
|
||||||
/* An image has been modified in some way and downstream caches all
|
/* An image has been modified in some way and caches all
|
||||||
* need dropping.
|
* need dropping.
|
||||||
*/
|
*/
|
||||||
void (*invalidate)( VipsImage *image );
|
void (*invalidate)( VipsImage *image );
|
||||||
@ -298,12 +298,12 @@ typedef struct _VipsImageClass {
|
|||||||
|
|
||||||
GType vips_image_get_type( void );
|
GType vips_image_get_type( void );
|
||||||
|
|
||||||
extern const size_t vips__sizeof_bandfmt[];
|
extern const size_t vips__image_sizeof_bandformat[];
|
||||||
|
|
||||||
/* Pixel address calculation macros.
|
/* Pixel address calculation macros.
|
||||||
*/
|
*/
|
||||||
#define VIPS_IMAGE_SIZEOF_ELEMENT( I ) \
|
#define VIPS_IMAGE_SIZEOF_ELEMENT( I ) \
|
||||||
(vips__sizeof_bandfmt[(I)->BandFmt])
|
(vips__image_sizeof_bandformat[(I)->BandFmt])
|
||||||
#define VIPS_IMAGE_SIZEOF_PEL( I ) \
|
#define VIPS_IMAGE_SIZEOF_PEL( I ) \
|
||||||
(VIPS_IMAGE_SIZEOF_ELEMENT( I ) * (I)->Bands)
|
(VIPS_IMAGE_SIZEOF_ELEMENT( I ) * (I)->Bands)
|
||||||
#define VIPS_IMAGE_SIZEOF_LINE( I ) \
|
#define VIPS_IMAGE_SIZEOF_LINE( I ) \
|
||||||
@ -377,29 +377,15 @@ int vips_image_copy_fieldsv( VipsImage *out, VipsImage *in1, ... )
|
|||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_image_copy_fields( VipsImage *out, VipsImage *in );
|
int vips_image_copy_fields( VipsImage *out, VipsImage *in );
|
||||||
|
|
||||||
|
void vips_image_init_fields( VipsImage *image,
|
||||||
|
int xsize, int ysize, int bands,
|
||||||
#define vips_image_open_local( IM, NAME, MODE ) \
|
|
||||||
((IMAGE *) vips_local( (IM), \
|
|
||||||
(vips_construct_fn) im_open, (im_callback_fn) im_close, \
|
|
||||||
(void *) (NAME), (void *) (MODE), NULL ))
|
|
||||||
|
|
||||||
/* Strange double cast stops bogus warnings from gcc 4.1
|
|
||||||
*/
|
|
||||||
#define vips_image_open_local_array( IM, OUT, N, NAME, MODE ) \
|
|
||||||
(vips_local_array( (IM), (void **)((void*)(OUT)), (N),\
|
|
||||||
(im_construct_fn) im_open, (im_callback_fn) im_close, \
|
|
||||||
(void *) (NAME), (void *) (MODE), NULL ))
|
|
||||||
|
|
||||||
void vips_invalidate( VipsImage *im );
|
|
||||||
|
|
||||||
void vips_initdesc( VipsImage *image,
|
|
||||||
int xsize, int ysize, int bands, int bandbits,
|
|
||||||
VipsBandFormat format, VipsCoding coding,
|
VipsBandFormat format, VipsCoding coding,
|
||||||
VipsInterpretation interpretation,
|
VipsInterpretation interpretation,
|
||||||
float xres, float yres,
|
float xres, float yres,
|
||||||
int xo, int yo );
|
int xo, int yo );
|
||||||
|
|
||||||
|
int vips_image_write_line( VipsImage *image, int ypos, PEL *linebuffer );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
@ -143,6 +143,10 @@ extern "C" {
|
|||||||
#include <vips/deprecated.h>
|
#include <vips/deprecated.h>
|
||||||
#endif /*VIPS_ENABLE_DEPRECATED*/
|
#endif /*VIPS_ENABLE_DEPRECATED*/
|
||||||
|
|
||||||
|
#ifndef VIPS_DISABLE_VIPS7COMPAT
|
||||||
|
#include <vips/vips7compat.h>
|
||||||
|
#endif /*VIPS_DISABLE_VIPS7COMPAT*/
|
||||||
|
|
||||||
const char *vips_get_argv0( void );
|
const char *vips_get_argv0( void );
|
||||||
int vips_init( const char *argv0 );
|
int vips_init( const char *argv0 );
|
||||||
GOptionGroup *vips_get_option_group( void );
|
GOptionGroup *vips_get_option_group( void );
|
||||||
|
215
libvips/include/vips/vips7compat.h
Normal file
215
libvips/include/vips/vips7compat.h
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
/* compat with the vips7 API
|
||||||
|
*
|
||||||
|
* 4/3/11
|
||||||
|
* - hacked up
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VIPS_VIPS7COMPAT_H
|
||||||
|
#define VIPS_VIP7COMPATS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /*__cplusplus*/
|
||||||
|
|
||||||
|
/* Renamed types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define IM_BANDFMT_NOTSET VIPS_FORMAT_NOTSET
|
||||||
|
#define IM_BANDFMT_UCHAR VIPS_FORMAT_UCHAR
|
||||||
|
#define IM_BANDFMT_CHAR VIPS_FORMAT_CHAR
|
||||||
|
#define IM_BANDFMT_USHORT VIPS_FORMAT_USHORT
|
||||||
|
#define IM_BANDFMT_SHORT VIPS_FORMAT_SHORT
|
||||||
|
#define IM_BANDFMT_UINT VIPS_FORMAT_UINT
|
||||||
|
#define IM_BANDFMT_INT VIPS_FORMAT_INT
|
||||||
|
#define IM_BANDFMT_FLOAT VIPS_FORMAT_FLOAT
|
||||||
|
#define IM_BANDFMT_COMPLEX VIPS_FORMAT_COMPLEX
|
||||||
|
#define IM_BANDFMT_DOUBLE VIPS_FORMAT_DOUBLE
|
||||||
|
#define IM_BANDFMT_DPCOMPLEX VIPS_FORMAT_DPCOMPLEX
|
||||||
|
#define IM_BANDFMT_LAST VIPS_FORMAT_LAST
|
||||||
|
#define VipsBandFmt VipsBandFormat
|
||||||
|
|
||||||
|
#define IM_SMALLTILE VIPS_DEMAND_STYLE_SMALLTILE
|
||||||
|
#define IM_FATSTRIP VIPS_DEMAND_STYLE_FATSTRIP
|
||||||
|
#define IM_THINSTRIP VIPS_DEMAND_STYLE_THINSTRIP
|
||||||
|
#define IM_ANY VIPS_DEMAND_STYLE_ANY
|
||||||
|
|
||||||
|
#define IM_CODING_NONE VIPS_CODING_NONE
|
||||||
|
#define IM_CODING_LABQ VIPS_CODING_LABQ
|
||||||
|
#define IM_CODING_RAD VIPS_CODING_RAD
|
||||||
|
|
||||||
|
#define IM_TYPE_MULTIBAND VIPS_INTERPRETATION_MULTIBAND
|
||||||
|
#define IM_TYPE_B_W VIPS_INTERPRETATION_B_W
|
||||||
|
#define IM_TYPE_HISTOGRAM VIPS_INTERPRETATION_HISTOGRAM
|
||||||
|
#define IM_TYPE_FOURIER VIPS_INTERPRETATION_FOURIER
|
||||||
|
#define IM_TYPE_XYZ VIPS_INTERPRETATION_XYZ
|
||||||
|
#define IM_TYPE_LAB VIPS_INTERPRETATION_LAB
|
||||||
|
#define IM_TYPE_CMYK VIPS_INTERPRETATION_CMYK
|
||||||
|
#define IM_TYPE_LABQ VIPS_INTERPRETATION_LABQ
|
||||||
|
#define IM_TYPE_RGB VIPS_INTERPRETATION_RGB
|
||||||
|
#define IM_TYPE_UCS VIPS_INTERPRETATION_UCS
|
||||||
|
#define IM_TYPE_LCH VIPS_INTERPRETATION_LCH
|
||||||
|
#define IM_TYPE_LABS VIPS_INTERPRETATION_LABS
|
||||||
|
#define IM_TYPE_sRGB VIPS_INTERPRETATION_sRGB
|
||||||
|
#define IM_TYPE_YXY VIPS_INTERPRETATION_YXY
|
||||||
|
#define IM_TYPE_RGB16 VIPS_INTERPRETATION_RGB16
|
||||||
|
#define IM_TYPE_GREY16 VIPS_INTERPRETATION_GREY16
|
||||||
|
#define VipsType VipsInterpretation
|
||||||
|
|
||||||
|
#define IMAGE VipsImage
|
||||||
|
#define REGION VipsRegion
|
||||||
|
|
||||||
|
/* Renamed macros.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define IM_MAX VIPS_MAX
|
||||||
|
#define IM_MIN VIPS_MIN
|
||||||
|
#define IM_RAD VIPS_RAD
|
||||||
|
#define IM_DEG VIPS_DEG
|
||||||
|
#define IM_PI VIPS_PI
|
||||||
|
#define IM_RINT VIPS_RINT
|
||||||
|
#define IM_NEW VIPS_NEW
|
||||||
|
#define IM_ARRAY VIPS_ARRAY
|
||||||
|
#define IM_FREE VIPS_FREE
|
||||||
|
#define IM_FREEF VIPS_FREEF
|
||||||
|
#define IM_NUMBER VIPS_NUMBER
|
||||||
|
#define IM_CLIP VIPS_CLIP
|
||||||
|
#define IM_CLIP_UCHAR VIPS_CLIP_UCHAR
|
||||||
|
#define IM_CLIP_CHAR VIPS_CLIP_CHAR
|
||||||
|
#define IM_CLIP_USHORT VIPS_CLIP_USHORT
|
||||||
|
#define IM_CLIP_SHORT VIPS_CLIP_SHORT
|
||||||
|
#define IM_CLIP_NONE VIPS_CLIP_NONE
|
||||||
|
#define IM_UNROLL VIPS_UNROLL
|
||||||
|
#define IM_SWAP VIPS_SWAP
|
||||||
|
|
||||||
|
#define IM_IMAGE_ADDR VIPS_IMAGE_ADDR
|
||||||
|
#define IM_IMAGE_N_ELEMENTS VIPS_IMAGE_N_ELEMENTS
|
||||||
|
#define IM_IMAGE_SIZEOF_ELEMENT VIPS_IMAGE_SIZEOF_ELEMENT
|
||||||
|
#define IM_IMAGE_SIZEOF_PEL VIPS_IMAGE_SIZEOF_PEL
|
||||||
|
#define IM_IMAGE_SIZEOF_LINE VIPS_IMAGE_SIZEOF_LINE
|
||||||
|
|
||||||
|
#define IM_REGION_LSKIP VIPS_REGION_LSKIP
|
||||||
|
#define IM_REGION_ADDR VIPS_REGION_ADDR
|
||||||
|
#define IM_REGION_ADDR_TOPLEFT VIPS_REGION_ADDR_TOPLEFT
|
||||||
|
#define IM_REGION_N_ELEMENTS VIPS_REGION_N_ELEMENTS
|
||||||
|
#define IM_REGION_SIZEOF_LINE VIPS_REGION_SIZEOF_LINE
|
||||||
|
|
||||||
|
/* Renamed externs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define im__sizeof_bandfmt vips__image_sizeof_bandformat
|
||||||
|
|
||||||
|
/* Renamed functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define im_error vips_error
|
||||||
|
#define im_verror vips_verror
|
||||||
|
#define im_verror_system vips_verror_system
|
||||||
|
#define im_error_system vips_error_system
|
||||||
|
#define im_error_buffer vips_error_buffer
|
||||||
|
#define im_error_clear vips_error_clear
|
||||||
|
#define im_warn vips_warn
|
||||||
|
#define im_vwarn vips_vwarn
|
||||||
|
#define im_diag vips_diag
|
||||||
|
#define im_vdiag vips_vdiag
|
||||||
|
|
||||||
|
#define im_get_argv0 vips_get_argv0
|
||||||
|
#define im_version_string vips_version_string
|
||||||
|
#define im_version vips_version
|
||||||
|
|
||||||
|
#define im_cp_desc vips_image_copy_fields
|
||||||
|
#define im_cp_descv vips_image_copy_fieldsv
|
||||||
|
#define im_cp_desc_array vips_image_copy_fields_array
|
||||||
|
#define im_open vips_image_new_from_file
|
||||||
|
#define im_image vips_image_new_from_memory
|
||||||
|
#define im_binfile vips_image_new_from_file_raw
|
||||||
|
#define im__open_temp vips_image_new_disc_temp
|
||||||
|
#define im_invalidate vips_image_invalidate_all
|
||||||
|
|
||||||
|
#define im_initdesc( image, \
|
||||||
|
xsize, ysize, bands, bandbits, bandfmt, coding, \
|
||||||
|
type, xres, yres, xo, yo ) \
|
||||||
|
vips_image_init_fields( image, \
|
||||||
|
xsize, ysize, bands, bandfmt, coding, \
|
||||||
|
type, xres, yres, xo, yo )
|
||||||
|
|
||||||
|
#define im_writeline( Y, IM, P ) vips_image_write_line( IM, Y, P )
|
||||||
|
|
||||||
|
#define im_prepare vips_region_prepare
|
||||||
|
#define im_prepare_to vips_region_prepare_to
|
||||||
|
#define im_region_create vips_region_new
|
||||||
|
#define im_region_free g_object_unref
|
||||||
|
#define im_region_region vips_region_region
|
||||||
|
#define im_region_buffer vips_region_buffer
|
||||||
|
#define im_region_black vips_region_black
|
||||||
|
#define im_region_paint vips_region_paint
|
||||||
|
|
||||||
|
#define im__region_no_ownership vips__region_no_ownership
|
||||||
|
|
||||||
|
/* Compat functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
VipsImage *im_open_local( VipsImage *parent,
|
||||||
|
const char *filename, const char *mode );
|
||||||
|
int im_open_local_array( VipsImage *parent,
|
||||||
|
VipsImage **images, int n, const char *filename, const char *mode );
|
||||||
|
|
||||||
|
/* uncomment this when we remove the im_callback_fn from meta.h
|
||||||
|
typedef int (*im_callback_fn)( void *a, void *b );
|
||||||
|
*/
|
||||||
|
|
||||||
|
int im_add_callback( VipsImage *im,
|
||||||
|
const char *callback, im_callback_fn fn, void *a, void *b );
|
||||||
|
#define im_add_close_callback( IM, FN, A, B ) \
|
||||||
|
im_add_callback( IM, "close", FN, A, B )
|
||||||
|
#define im_add_postclose_callback( IM, FN, A, B ) \
|
||||||
|
im_add_callback( IM, "postclose", FN, A, B )
|
||||||
|
#define im_add_evalstart_callback( IM, FN, A, B ) \
|
||||||
|
im_add_callback( IM, "evalstart", FN, A, B )
|
||||||
|
#define im_add_evalend_callback( IM, FN, A, B ) \
|
||||||
|
im_add_callback( IM, "evalend", FN, A, B )
|
||||||
|
#define im_add_invalidate_callback( IM, FN, A, B ) \
|
||||||
|
im_add_callback( IM, "invalidate", FN, A, B )
|
||||||
|
|
||||||
|
#define im_bits_of_fmt( fmt ) (vips_format_sizeof( fmt ) << 3)
|
||||||
|
|
||||||
|
typedef void *(*im_construct_fn)( void *, void *, void * );
|
||||||
|
void *im_local( VipsImage *im,
|
||||||
|
im_construct_fn cons, im_callback_fn dest, void *a, void *b, void *c );
|
||||||
|
int im_local_array( VipsImage *im, void **out, int n,
|
||||||
|
im_construct_fn cons, im_callback_fn dest, void *a, void *b, void *c );
|
||||||
|
|
||||||
|
int im_close( VipsImage *im );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /*__cplusplus*/
|
||||||
|
|
||||||
|
#endif /*VIPS_VIPS7COMPAT_H*/
|
||||||
|
|
||||||
|
|
@ -22,7 +22,6 @@ libiofuncs_la_SOURCES = \
|
|||||||
sinkdisc.c \
|
sinkdisc.c \
|
||||||
sink.c \
|
sink.c \
|
||||||
im_wrapmany.c \
|
im_wrapmany.c \
|
||||||
im_writeline.c \
|
|
||||||
memory.c \
|
memory.c \
|
||||||
check.c \
|
check.c \
|
||||||
package.c \
|
package.c \
|
||||||
@ -36,6 +35,7 @@ libiofuncs_la_SOURCES = \
|
|||||||
buf.c \
|
buf.c \
|
||||||
window.c \
|
window.c \
|
||||||
vector.c \
|
vector.c \
|
||||||
|
vips7compat.c \
|
||||||
buffer.c
|
buffer.c
|
||||||
|
|
||||||
INCLUDES = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
INCLUDES = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
||||||
|
@ -231,8 +231,18 @@ im_incheck( IMAGE *im )
|
|||||||
#ifdef DEBUG_IO
|
#ifdef DEBUG_IO
|
||||||
printf( "im_incheck: auto-rewind of %s\n", im->filename );
|
printf( "im_incheck: auto-rewind of %s\n", im->filename );
|
||||||
#endif/*DEBUG_IO*/
|
#endif/*DEBUG_IO*/
|
||||||
if( im__close( im ) ||
|
|
||||||
im_openin( im ) ||
|
/* Free any resources the image holds and reset to a base
|
||||||
|
* state.
|
||||||
|
*/
|
||||||
|
g_object_run_dispose( G_OBJECT( im ) );
|
||||||
|
|
||||||
|
/* And reopen .. recurse to get a mmaped image.
|
||||||
|
*/
|
||||||
|
g_object_set( im,
|
||||||
|
"mode", "r",
|
||||||
|
NULL );
|
||||||
|
if( vips_object_build( VIPS_OBJECT( im ) ) ||
|
||||||
im_incheck( im ) ) {
|
im_incheck( im ) ) {
|
||||||
vips_error( "im_incheck",
|
vips_error( "im_incheck",
|
||||||
_( "auto-rewind for %s failed" ),
|
_( "auto-rewind for %s failed" ),
|
||||||
@ -442,8 +452,16 @@ im_pincheck( IMAGE *im )
|
|||||||
#ifdef DEBUG_IO
|
#ifdef DEBUG_IO
|
||||||
printf( "im_pincheck: auto-rewind of %s\n", im->filename );
|
printf( "im_pincheck: auto-rewind of %s\n", im->filename );
|
||||||
#endif/*DEBUG_IO*/
|
#endif/*DEBUG_IO*/
|
||||||
if( im__close( im ) ||
|
|
||||||
im_openin( im ) ) {
|
/* Free any resources the image holds and reset to a base
|
||||||
|
* state.
|
||||||
|
*/
|
||||||
|
g_object_run_dispose( G_OBJECT( im ) );
|
||||||
|
|
||||||
|
g_object_set( im,
|
||||||
|
"mode", "r",
|
||||||
|
NULL );
|
||||||
|
if( vips_object_build( VIPS_OBJECT( im ) ) ) {
|
||||||
vips_error( "im_pincheck",
|
vips_error( "im_pincheck",
|
||||||
_( "auto-rewind for %s failed" ),
|
_( "auto-rewind for %s failed" ),
|
||||||
im->filename );
|
im->filename );
|
||||||
|
@ -1,130 +0,0 @@
|
|||||||
/* write a scanline
|
|
||||||
*
|
|
||||||
* Copyright: Nicos Dessipris
|
|
||||||
* Written on: 04/04/1990
|
|
||||||
* Modified on :
|
|
||||||
* 15/4/93 JC
|
|
||||||
* - support for partial images
|
|
||||||
* 13/12/93 JC
|
|
||||||
* - now triggers eval callbacks for the output image.
|
|
||||||
* 26/3/02 JC
|
|
||||||
* - better error messages
|
|
||||||
* 31/10/03 JC
|
|
||||||
* - stop early on kill
|
|
||||||
* 7/11/07
|
|
||||||
* - add eval start/stop
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif /*HAVE_CONFIG_H*/
|
|
||||||
#include <vips/intl.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif /*HAVE_UNISTD_H*/
|
|
||||||
#include <errno.h>
|
|
||||||
#ifdef HAVE_IO_H
|
|
||||||
#include <io.h>
|
|
||||||
#endif /*HAVE_IO_H*/
|
|
||||||
|
|
||||||
#include <vips/vips.h>
|
|
||||||
#include <vips/internal.h>
|
|
||||||
#include <vips/debug.h>
|
|
||||||
|
|
||||||
#ifdef WITH_DMALLOC
|
|
||||||
#include <dmalloc.h>
|
|
||||||
#endif /*WITH_DMALLOC*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* im_writeline:
|
|
||||||
* @image: image to write to
|
|
||||||
* @ypos: vertical position of scan-line to write
|
|
||||||
* @linebuffer: scanline of pixels
|
|
||||||
*
|
|
||||||
* Write a line of pixels to an image. This function must be called repeatedly
|
|
||||||
* with @ypos increasing from 0 to @YSize -
|
|
||||||
* @linebuffer must be IM_IMAGE_SIZEOF_LINE() bytes long.
|
|
||||||
*
|
|
||||||
* See also: im_setupout(), im_generate().
|
|
||||||
*
|
|
||||||
* Returns: 0 on success, or -1 on error.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
vips_image_write_line( VipsImage *image, int ypos, PEL *linebuffer )
|
|
||||||
{
|
|
||||||
int linesize = VIPS_IMAGE_SIZEOF_LINE( image );
|
|
||||||
|
|
||||||
/* Is this the start of eval?
|
|
||||||
*/
|
|
||||||
if( ypos == 0 )
|
|
||||||
vips_image_preeval( image );
|
|
||||||
|
|
||||||
/* Possible cases for output: FILE or SETBUF.
|
|
||||||
*/
|
|
||||||
switch( image->dtype ) {
|
|
||||||
case VIPS_IMAGE_SETBUF:
|
|
||||||
case VIPS_IMAGE_SETBUF_FOREIGN:
|
|
||||||
memcpy( VIPS_IMAGE_ADDR( image, 0, ypos ),
|
|
||||||
linebuffer, linesize );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VIPS_IMAGE_OPENOUT:
|
|
||||||
/* Don't use ypos for this.
|
|
||||||
*/
|
|
||||||
if( im__write( image->fd, linebuffer, linesize ) )
|
|
||||||
return( -1 );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
vips_error( "im_writeline",
|
|
||||||
_( "unable to output to a %s image" ),
|
|
||||||
VIPS_ENUM_STRING( VIPS_TYPE_DEMAND_STYLE,
|
|
||||||
image->dtype ) );
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Trigger evaluation callbacks for this image.
|
|
||||||
*/
|
|
||||||
vips_image_eval( image, image->Xsize, 1 );
|
|
||||||
if( im__test_kill( image ) )
|
|
||||||
return( -1 );
|
|
||||||
|
|
||||||
/* Is this the end of eval?
|
|
||||||
*/
|
|
||||||
if( ypos == image->Ysize - 1 ) {
|
|
||||||
vips_image_posteval( image );
|
|
||||||
vips_image_written( image );
|
|
||||||
}
|
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
@ -1688,7 +1688,7 @@ vips_image_ispartial( VipsImage *image )
|
|||||||
/* This is used by (eg.) IM_IMAGE_SIZEOF_ELEMENT() to calculate object
|
/* This is used by (eg.) IM_IMAGE_SIZEOF_ELEMENT() to calculate object
|
||||||
* size.
|
* size.
|
||||||
*/
|
*/
|
||||||
const size_t vips_image__sizeof_bandformat[] = {
|
const size_t vips__image_sizeof_bandformat[] = {
|
||||||
sizeof( unsigned char ), /* VIPS_FORMAT_UCHAR */
|
sizeof( unsigned char ), /* VIPS_FORMAT_UCHAR */
|
||||||
sizeof( signed char ), /* VIPS_FORMAT_CHAR */
|
sizeof( signed char ), /* VIPS_FORMAT_CHAR */
|
||||||
sizeof( unsigned short ), /* VIPS_FORMAT_USHORT */
|
sizeof( unsigned short ), /* VIPS_FORMAT_USHORT */
|
||||||
@ -1709,7 +1709,7 @@ vips_format_sizeof( VipsBandFormat format )
|
|||||||
return( (format < 0 || format > VIPS_FORMAT_DPCOMPLEX) ?
|
return( (format < 0 || format > VIPS_FORMAT_DPCOMPLEX) ?
|
||||||
vips_error( "vips_format_sizeof",
|
vips_error( "vips_format_sizeof",
|
||||||
_( "unknown band format %d" ), format ), -1 :
|
_( "unknown band format %d" ), format ), -1 :
|
||||||
vips_image__sizeof_bandformat[format] );
|
vips__image_sizeof_bandformat[format] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1833,5 +1833,126 @@ vips_image_copy_fields( IMAGE *out, IMAGE *in )
|
|||||||
return( vips_image_copy_fieldsv( out, in, NULL ) );
|
return( vips_image_copy_fieldsv( out, in, NULL ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
vips_image_new_array( VipsImage *parent, VipsImage **images, int n )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; i < n; i++ )
|
||||||
|
if( !(images[i] = vips_image_new( "p" )) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vips_image_init_fields:
|
||||||
|
* @image: image to init
|
||||||
|
* @xsize: image width
|
||||||
|
* @ysize: image height
|
||||||
|
* @bands: image bands
|
||||||
|
* @bandfmt: band format
|
||||||
|
* @coding: image coding
|
||||||
|
* @type: image type
|
||||||
|
* @xres: horizontal resolution, pixels per millimetre
|
||||||
|
* @yres: vertical resolution, pixels per millimetre
|
||||||
|
* @xo: x offset
|
||||||
|
* @yo: y offset
|
||||||
|
*
|
||||||
|
* A convenience function to set the header fields after creating an image.
|
||||||
|
* Normally you copy the fields from one of your input images with
|
||||||
|
* vips_image_copy_fields() and then make
|
||||||
|
* any adjustments you need, but if you are creating an image from scratch,
|
||||||
|
* for example im_black() or im_jpeg2vips(), you do need to set all the
|
||||||
|
* fields yourself.
|
||||||
|
*
|
||||||
|
* See also: vips_image_copy_fields().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
vips_image_init_fields( VipsImage *image,
|
||||||
|
int xsize, int ysize, int bands,
|
||||||
|
VipsBandFormat format, VipsCoding coding,
|
||||||
|
VipsInterpretation interpretation,
|
||||||
|
float xres, float yres,
|
||||||
|
int xo, int yo )
|
||||||
|
{
|
||||||
|
g_object_set( image,
|
||||||
|
"width", xsize,
|
||||||
|
"height", ysize,
|
||||||
|
"bands", bands,
|
||||||
|
"format", format,
|
||||||
|
NULL );
|
||||||
|
|
||||||
|
image->Coding = coding;
|
||||||
|
image->Type = interpretation;
|
||||||
|
image->Xres = xres;
|
||||||
|
image->Yres = yres;
|
||||||
|
image->Xoffset = xo;
|
||||||
|
image->Yoffset = yo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vips_image_write_line:
|
||||||
|
* @image: image to write to
|
||||||
|
* @ypos: vertical position of scan-line to write
|
||||||
|
* @linebuffer: scanline of pixels
|
||||||
|
*
|
||||||
|
* Write a line of pixels to an image. This function must be called repeatedly
|
||||||
|
* with @ypos increasing from 0 to @YSize -
|
||||||
|
* @linebuffer must be IM_IMAGE_SIZEOF_LINE() bytes long.
|
||||||
|
*
|
||||||
|
* See also: im_setupout(), im_generate().
|
||||||
|
*
|
||||||
|
* Returns: 0 on success, or -1 on error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
vips_image_write_line( VipsImage *image, int ypos, PEL *linebuffer )
|
||||||
|
{
|
||||||
|
int linesize = VIPS_IMAGE_SIZEOF_LINE( image );
|
||||||
|
|
||||||
|
/* Is this the start of eval?
|
||||||
|
*/
|
||||||
|
if( ypos == 0 )
|
||||||
|
vips_image_preeval( image );
|
||||||
|
|
||||||
|
/* Possible cases for output: FILE or SETBUF.
|
||||||
|
*/
|
||||||
|
switch( image->dtype ) {
|
||||||
|
case VIPS_IMAGE_SETBUF:
|
||||||
|
case VIPS_IMAGE_SETBUF_FOREIGN:
|
||||||
|
memcpy( VIPS_IMAGE_ADDR( image, 0, ypos ),
|
||||||
|
linebuffer, linesize );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIPS_IMAGE_OPENOUT:
|
||||||
|
/* Don't use ypos for this.
|
||||||
|
*/
|
||||||
|
if( im__write( image->fd, linebuffer, linesize ) )
|
||||||
|
return( -1 );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
vips_error( "im_writeline",
|
||||||
|
_( "unable to output to a %s image" ),
|
||||||
|
VIPS_ENUM_STRING( VIPS_TYPE_DEMAND_STYLE,
|
||||||
|
image->dtype ) );
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Trigger evaluation callbacks for this image.
|
||||||
|
*/
|
||||||
|
vips_image_eval( image, image->Xsize, 1 );
|
||||||
|
if( im__test_kill( image ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
/* Is this the end of eval?
|
||||||
|
*/
|
||||||
|
if( ypos == image->Ysize - 1 ) {
|
||||||
|
vips_image_posteval( image );
|
||||||
|
vips_image_written( image );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1533,3 +1533,4 @@ im__temp_name( const char *format )
|
|||||||
|
|
||||||
return( name );
|
return( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
160
libvips/iofuncs/vips7compat.c
Normal file
160
libvips/iofuncs/vips7compat.c
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
/* compat stuff for vips7
|
||||||
|
*
|
||||||
|
* 4/3/11
|
||||||
|
* - hacked up
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
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 VIPS_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/internal.h>
|
||||||
|
#include <vips/debug.h>
|
||||||
|
|
||||||
|
#ifdef WITH_DMALLOC
|
||||||
|
#include <dmalloc.h>
|
||||||
|
#endif /*WITH_DMALLOC*/
|
||||||
|
|
||||||
|
/* Just for compatibility. New code should use vips_object_local() directly.
|
||||||
|
*/
|
||||||
|
VipsImage *
|
||||||
|
im_open_local( VipsImage *parent,
|
||||||
|
const char *filename, const char *mode )
|
||||||
|
{
|
||||||
|
VipsImage *image;
|
||||||
|
|
||||||
|
if( !(image = vips_image_new_from_file( filename, mode )) )
|
||||||
|
return( NULL );
|
||||||
|
vips_object_local( parent, image );
|
||||||
|
|
||||||
|
return( image );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Just for compatibility. New code should use vips_image_new_array().
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
im_open_local_array( VipsImage *parent,
|
||||||
|
VipsImage **images, int n,
|
||||||
|
const char *filename, const char *mode )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; i < n; i++ )
|
||||||
|
if( !(images[i] = im_open_local( parent, filename, mode )) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
im_callback_fn fn;
|
||||||
|
void *a;
|
||||||
|
void *b;
|
||||||
|
} Callback;
|
||||||
|
|
||||||
|
static void
|
||||||
|
im_add_callback_cb( VipsImage *im, Callback *callback )
|
||||||
|
{
|
||||||
|
callback->fn( callback->a, callback->b );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
im_add_callback( VipsImage *im,
|
||||||
|
const char *name, im_callback_fn fn, void *a, void *b )
|
||||||
|
{
|
||||||
|
Callback *callback;
|
||||||
|
|
||||||
|
if( !(callback = VIPS_NEW( im, Callback )) )
|
||||||
|
return( -1 );
|
||||||
|
callback->fn = fn;
|
||||||
|
callback->a = a;
|
||||||
|
callback->b = b;
|
||||||
|
g_signal_connect( im, name,
|
||||||
|
G_CALLBACK( im_add_callback_cb ), callback );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make something local to an image descriptor ... pass in a constructor
|
||||||
|
* and a destructor, plus three args.
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
im_local( IMAGE *im,
|
||||||
|
im_construct_fn cons, im_callback_fn dest, void *a, void *b, void *c )
|
||||||
|
{
|
||||||
|
void *obj;
|
||||||
|
|
||||||
|
if( !im ) {
|
||||||
|
im_error( "im_local", "%s", _( "NULL image descriptor" ) );
|
||||||
|
return( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !(obj = cons( a, b, c )) )
|
||||||
|
return( NULL );
|
||||||
|
if( im_add_close_callback( im, (im_callback_fn) dest, obj, a ) ) {
|
||||||
|
dest( obj, a );
|
||||||
|
return( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( obj );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make an array of things local to a descriptor ... eg. make 6 local temp
|
||||||
|
* images.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
im_local_array( IMAGE *im, void **out, int n,
|
||||||
|
im_construct_fn cons, im_callback_fn dest, void *a, void *b, void *c )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for( i = 0; i < n; i++ )
|
||||||
|
if( !(out[i] = im_local( im, cons, dest, a, b, c )) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
im_close( VipsImage *im )
|
||||||
|
{
|
||||||
|
g_object_unref( im );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user