finished iofunc docs

This commit is contained in:
John Cupitt 2009-10-22 12:02:27 +00:00
parent 7689f0bc60
commit 1082e5b0f1
14 changed files with 197 additions and 174 deletions

View File

@ -90,6 +90,11 @@ int im_render_priority( IMAGE *in, IMAGE *out, IMAGE *mask,
void (*notify)( IMAGE *, Rect *, void * ), void *client );
int im_cache( IMAGE *in, IMAGE *out, int width, int height, int max );
/* WIO.
*/
int im_setupout( IMAGE *im );
int im_writeline( int ypos, IMAGE *im, PEL *linebuffer );
#ifdef __cplusplus
}
#endif /*__cplusplus*/

View File

@ -307,6 +307,22 @@ int im_close( VipsImage *im );
void im_invalidate( VipsImage *im );
void im_initdesc( VipsImage *image,
int xsize, int ysize, int bands, int bandbits,
VipsBandFmt bandfmt, VipsCoding coding, VipsType type,
float xres, float yres,
int xo, int yo );
int im_cp_desc( VipsImage *out, VipsImage *in );
int im_cp_descv( VipsImage *out, VipsImage *in1, ... )
__attribute__((sentinel));
int im_cp_desc_array( VipsImage *out, VipsImage *in[] );
VipsImage *im_binfile( const char *name,
int xsize, int ysize, int bands, int offset );
VipsImage *im_image( void *buffer,
int width, int height, int bands, VipsBandFmt bandfmt );
#ifdef __cplusplus
}
#endif /*__cplusplus*/

View File

@ -74,6 +74,21 @@ typedef int (*im__fftproc_fn)( IMAGE *, IMAGE *, IMAGE * );
/* iofuncs
*/
IMAGE *im_init( const char * );
IMAGE *im_openout( const char * );
IMAGE *im_open_vips( const char * );
int im_openin( IMAGE *image );
int im_openinrw( IMAGE *image );
IMAGE *im_setbuf( const char * );
IMAGE *im_partial( const char * );
int im_mapfile( IMAGE * );
int im_mapfilerw( IMAGE * );
int im_remapfilerw( IMAGE *image );
IMAGE *im_open_header( const char * );
int im_unmapfile( IMAGE * );
void im__read_4byte( int msb_first, unsigned char *to, unsigned char **from );
void im__read_2byte( int msb_first, unsigned char *to, unsigned char **from );
void im__write_4byte( unsigned char **to, unsigned char *from );
@ -188,6 +203,7 @@ int im__balance( IMAGE *ref, IMAGE *sec, IMAGE *out,
IMAGE **ref_out, IMAGE **sec_out, int dx, int dy, int balancetype );
void im__black_region( REGION *reg );
#ifdef __cplusplus
}
#endif /*__cplusplus*/

View File

@ -64,38 +64,6 @@ extern "C" {
# endif
#endif /*SWIG*/
/* iofuncs
*/
IMAGE *im_init( const char * );
IMAGE *im_openout( const char * );
IMAGE *im_open_vips( const char * );
int im_openin( IMAGE *image );
int im_openinrw( IMAGE *image );
IMAGE *im_vips_open( const char * );
IMAGE *im_setbuf( const char * );
IMAGE *im_partial( const char * );
IMAGE *im_binfile( const char *, int, int, int, int );
IMAGE *im_image( void *, int, int, int, int );
int im_mapfile( IMAGE * );
int im_mapfilerw( IMAGE * );
int im_remapfilerw( IMAGE *image );
IMAGE *im_open_header( const char * );
int im_cp_desc( IMAGE *, IMAGE * );
int im_cp_descv( IMAGE *out, IMAGE *in1, ... )
__attribute__((sentinel));
int im_cp_desc_array( IMAGE *out, IMAGE *in[] );
int im_setupout( IMAGE * );
int im_writeline( int, IMAGE *, PEL * );
int im_unmapfile( IMAGE * );
void im_initdesc( IMAGE *,
int, int, int, int, int, int, int, float, float,
int, int );
/* morphology
*/
int im_dilate( IMAGE *in, IMAGE *out, INTMASK *m );

View File

@ -10,15 +10,13 @@ libiofuncs_la_SOURCES = \
dispatch_types.c \
error.c \
im_binfile.c \
im_bits_of_fmt.c \
im_close.c \
im_cp_desc.c \
im_demand_hint.c \
im_generate.c \
im_histlin.c \
im_image.c \
im_init.c \
im_initdesc.c \
init.c \
im_iterate.c \
im_mapfile.c \
im_open.c \

View File

@ -1,4 +1,4 @@
/* im_bnfile.c --- load a raw binary file
/* im_binfile.c --- load a raw binary file
*
* Author: N. Dessipris
* Written on: 31/7/91
@ -76,8 +76,8 @@
/**
* im_binfile:
* @name: filename to open
* @xs: image width
* @ys: image height
* @xsize: image width
* @ysize: image height
* @bands: image bands (or bytes per pixel)
* @offset: bytes to skip at start of file
*
@ -92,7 +92,7 @@
* Returns: the new #IMAGE, or NULL on error.
*/
IMAGE *
im_binfile( const char *name, int xs, int ys, int bands, int offset )
im_binfile( const char *name, int xsize, int ysize, int bands, int offset )
{
IMAGE *im;
gint64 psize;
@ -100,7 +100,7 @@ im_binfile( const char *name, int xs, int ys, int bands, int offset )
/* Check parameters.
*/
if( xs <= 0 || ys <= 0 || bands <=0 ) {
if( xsize <= 0 || ysize <= 0 || bands <= 0 ) {
im_error( "im_binfile",
"%s", _( "bad parameters" ) );
return( NULL );
@ -119,7 +119,7 @@ im_binfile( const char *name, int xs, int ys, int bands, int offset )
/* Predict file size.
*/
psize = (gint64) xs * ys * bands + offset;
psize = (gint64) xsize * ysize * bands + offset;
/* Read the real file length and check against what we think
* the size should be.
@ -161,8 +161,8 @@ im_binfile( const char *name, int xs, int ys, int bands, int offset )
/* Set header fields.
*/
im->Xsize = xs;
im->Ysize = ys;
im->Xsize = xsize;
im->Ysize = ysize;
im->Bands = bands;
/* Set others to standard values.

View File

@ -64,7 +64,6 @@
#include <vips/intl.h>
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#include <string.h>
@ -75,8 +74,29 @@
#include <dmalloc.h>
#endif /*WITH_DMALLOC*/
/* in is a NULL-termnated array of input images. Always at least one image
* there.
/**
* im_cp_desc_array:
* @out: image to copy to
* @in: %NULL-terminated array of images to copy from
*
* Copy fields from all the input images to the output image. There must be at
* least one input image. If you are making an image which has no input images
* (for example, im_black() or im_vips2jpeg()), use im_initdesc() instead.
*
* The first input image is used to set the main fields of @out (@XSize, @Coding
* and so on).
*
* Metadata from all the image is merged on to @out, with lower-numbered items
* overriding higher. So for example, if @in[0] and @in[1] both have an item
* called "icc-profile", it's the profile attached to @in[0] that will end up
* on @out.
*
* Image history is completely copied from all @in. @out will have the history
* of all the intput images.
*
* See also: im_cp_descv(), im_cp_desc().
*
* Returns: 0 on success, -1 on error.
*/
int
im_cp_desc_array( IMAGE *out, IMAGE *in[] )
@ -84,7 +104,7 @@ im_cp_desc_array( IMAGE *out, IMAGE *in[] )
int i;
int ni;
assert( in[0] );
g_assert( in[0] );
out->Xsize = in[0]->Xsize;
out->Ysize = in[0]->Ysize;
@ -124,6 +144,19 @@ im_cp_desc_array( IMAGE *out, IMAGE *in[] )
*/
#define MAX_IMAGES (1000)
/**
* im_cp_descv:
* @out: image to copy to
* @in1: first image to copy from
* @Varargs: %NULL-terminated list of images to copy from
*
* Copy fields from all the input images to the output image. A convenience
* function over im_cp_desc_array().
*
* See also: im_cp_desc_array(), im_cp_desc().
*
* Returns: 0 on success, -1 on error.
*/
int
im_cp_descv( IMAGE *out, IMAGE *in1, ... )
{
@ -145,8 +178,20 @@ im_cp_descv( IMAGE *out, IMAGE *in1, ... )
return( im_cp_desc_array( out, in ) );
}
/**
* im_cp_desc:
* @out: image to copy to
* @in: image to copy from
*
* Copy fields from @in to @out. A convenience
* function over im_cp_desc_array().
*
* See also: im_cp_desc_array(), im_cp_descv().
*
* Returns: 0 on success, -1 on error.
*/
int
im_cp_desc( IMAGE *dest, IMAGE *src )
im_cp_desc( IMAGE *out, IMAGE *in )
{
return( im_cp_descv( dest, src, NULL ) );
return( im_cp_descv( out, in, NULL ) );
}

View File

@ -1,12 +1,5 @@
/* @(#) Make a memory area of pixels into a VIPS image ... we don't free() on
* @(#) im_close(), that's up to the caller ... format is BandFmt
* @(#)
* @(#) Usage:
* @(#)
* @(#) IMAGE *
* @(#) im_image( void *buffer, int width, int height, int bands, int format )
* @(#)
* @(#) The function returns NULL on error.
/* im_image.c ... area of memory as an image
*
* Written on: 11/7/00
* Modified on:
* 20/3/01 JC
@ -48,18 +41,35 @@
#include <stdlib.h>
#include <vips/vips.h>
#include <vips/internal.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif /*WITH_DMALLOC*/
/**
* im_image:
* @buffer: start of memory area
* @xsize: image width
* @ysize: image height
* @bands: image bands (or bytes per pixel)
* @bandfmt: image format
*
* This function wraps an #IMAGE around a memory buffer. VIPS does not take
* responsibility for the area of memory, it's up to you to make sure it's
* freed when the image is closed. See for example im_add_close_callback().
*
* See also: im_binfile(), im_raw2vips(), im_open().
*
* Returns: the new #IMAGE, or %NULL on error.
*/
IMAGE *
im_image( void *buffer, int width, int height, int bands, int format )
im_image( void *buffer, int width, int height, int bands, VipsBandFmt bandfmt )
{
IMAGE *im;
if( width <= 0 || height <= 0 || bands <= 0 ||
format < 0 || format > IM_BANDFMT_DPCOMPLEX ) {
bandfmt < 0 || bandfmt > IM_BANDFMT_DPCOMPLEX ) {
im_error( "im_image", "%s", _( "bad parameters" ) );
return( NULL );
}
@ -74,8 +84,8 @@ im_image( void *buffer, int width, int height, int bands, int format )
im->Xsize = width;
im->Ysize = height;
im->Bands = bands;
im->BandFmt = format;
im->Bbits = im_bits_of_fmt( format );
im->BandFmt = bandfmt;
im->Bbits = im_bits_of_fmt( bandfmt );
im->Coding = IM_CODING_NONE;
if( bands == 1 )

View File

@ -1,81 +0,0 @@
/* @(#) Initialises an image descriptor to entered values
* @(#) fd, baseaddr, data and filename are not handled by this function
* @(#) The order of the args is the same as in vips/vips.h
*
* @(#) Right call:
* @(#) void im_initdesc(image, xsize, ysize, bands, bandbits, bandfmt,
coding, type, xres, yres)
* @(#) IMAGE *image;
* @(#) int xsize, ysize, bands, bandbits, bandfmt, coding, type;
* @(#) float xres, yres;
* HANDLESHEADER
* Copyright: Nicos Dessipris, 1991
* Written on: 02/04/1991
* Modified on : 3/6/92 Kirk Martinez
* 23/2/94 JC
* - ANSIfied
* 2/6/07
* - ignore bandbits
*/
/*
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 <vips/vips.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif /*WITH_DMALLOC*/
void
im_initdesc( IMAGE *image,
int xsize, int ysize,
int bands, int bandbits, int bandfmt,
int coding, int 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;
}

View File

@ -42,6 +42,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/internal.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>

View File

@ -51,6 +51,7 @@
#include <string.h>
#include <vips/vips.h>
#include <vips/internal.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>

View File

@ -1,21 +1,5 @@
/* @(#)
* @(#) Function which sets up the output as follows
* @(#) If the output is a buffer, it allocates memory according to image sizes
* @(#) If the output is a file, it write a header
* @(#) to the file pointed by image.fd
* @(#) If the output is a partial image, then `magically' turn this from an
* @(#) im_partial() image into an im_setbuf() image. If im_setupout() is
* @(#) called, we take it as a sign that we are dealing with pre-partial
* @(#) images code.
* @(#) When exiting, image.fd points at the end of the header info.
* @(#) expecting raw image data.
* @(#) No description or history is involved
* @(#) Called by all im_funcs
* @(#)
* @(#) int im_setupout(image)
* @(#) IMAGE *image;
* @(#) Returns either 0 (success) or -1 (fail)
* @(#)
/* get an image ready for im_writeline()
*
* Copyright: Nicos Dessipris
* Written on: 16/01/1990
* Modified on : 04/04/1990, 28/02/1991
@ -89,6 +73,18 @@
#define MODE (O_WRONLY | O_CREAT | O_TRUNC)
#endif /*BINARY_OPEN*/
/**
* im_setupout:
* @im: image to prepare for writing
*
* This call gets the #IMAGE ready for scanline-based writing with
* im_writeline(). You need to have set all the image fields, such as @Xsize
* and @BandFmt, before calling this.
*
* Returns: 0 on success, or -1 on error.
*
* See also: im_writeline(), im_generate(), im_initdesc(), im_cp_desc().
*/
int
im_setupout( IMAGE *im )
{

View File

@ -1,16 +1,4 @@
/* @(#) Functions which writes the yth buffer line to either the output file
* @(#) or the output buffer.
* @(#) It is the responsibility of the user to create a buffer line
* @(#) and write the data to it before calling this function.
* @(#) No checking is carried out for image
* @(#)
* @(#) int im_writeline(ypos, image, linebuffer)
* @(#) int ypos;
* @(#) IMAGE *image;
* @(#) char *linebuffer;
* @(#)
* @(#) Returns 0 on success and -1 on error
* @(#)
/* write a scanline
*
* Copyright: Nicos Dessipris
* Written on: 04/04/1990
@ -77,6 +65,20 @@
#include <dmalloc.h>
#endif /*WITH_DMALLOC*/
/**
* im_writeline:
* @ypos: vertical position of scan-line to write
* @im: image to write to
* @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 -
* 1. @linebuffer must be IM_IMAGE_SIZEOF_LINE() bytes long.
*
* See also: im_setupout(), im_generate().
*
* Returns: 0 on success, or -1 on error.
*/
int
im_writeline( int ypos, IMAGE *im, PEL *linebuffer )
{

View File

@ -184,3 +184,49 @@ im_init( const char *filename )
return( im );
}
/**
* 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;
}