This commit is contained in:
John Cupitt 2009-11-06 14:35:43 +00:00
parent 7bae8738e0
commit 174fdd782a
4 changed files with 29 additions and 25 deletions

7
TODO
View File

@ -1,11 +1,10 @@
- import ~/summer-demo/summer.tif fails with "unable to read embedded
profile", is this a bug? better err msg would be good
trying to catch errors now, but is it working? not sure
WONTFIX for 7.20 WONTFIX for 7.20
================ ================
- some of deprecated.h repeats stuff we do better in image.h, eg. addr()
should just call IM_REGION_ADDR()
- load 500 jpegs, group, shrink, save - load 500 jpegs, group, shrink, save
VM use is huge, ouch, could we use a bit less? VM use is huge, ouch, could we use a bit less?

View File

@ -121,10 +121,10 @@ extern "C" {
* lsize() sizeof scan line * lsize() sizeof scan line
* niele() number of elements in scan line * niele() number of elements in scan line
*/ */
#define esize(I) ((I)->Bbits >> 3) #define esize(I) IM_IMAGE_SIZEOF_ELEMENT(I)
#define psize(I) (esize(I)*(I)->Bands) #define psize(I) IM_IMAGE_SIZEOF_PEL(I)
#define lsize(I) (psize(I)*(I)->Xsize) #define lsize(I) IM_IMAGE_SIZEOF_LINE(I)
#define niele(I) ((I)->Bands*(I)->Xsize) #define niele(I) IM_IMAGE_N_ELEMENTS(I)
/* Macros on REGIONs. /* Macros on REGIONs.
* lskip() add to move down line * lskip() add to move down line

View File

@ -239,17 +239,18 @@ typedef struct _VipsImage {
gboolean hint_set; gboolean hint_set;
} VipsImage; } VipsImage;
extern const size_t im__sizeof_bandfmt[];
/* Pixel address calculation macros. /* Pixel address calculation macros.
*/ */
#define IM_IMAGE_SIZEOF_ELEMENT(I) \ #define IM_IMAGE_SIZEOF_ELEMENT(I) \
((size_t)((I)->Bbits >> 3)) (im__sizeof_bandfmt[(I)->BandFmt])
#define IM_IMAGE_SIZEOF_PEL(I) \ #define IM_IMAGE_SIZEOF_PEL(I) \
((size_t)(IM_IMAGE_SIZEOF_ELEMENT(I) * (I)->Bands)) (IM_IMAGE_SIZEOF_ELEMENT(I) * (I)->Bands)
#define IM_IMAGE_SIZEOF_LINE(I) \ #define IM_IMAGE_SIZEOF_LINE(I) \
((size_t)(IM_IMAGE_SIZEOF_PEL(I) * (I)->Xsize)) (IM_IMAGE_SIZEOF_PEL(I) * (I)->Xsize)
#define IM_IMAGE_N_ELEMENTS(I) \ #define IM_IMAGE_N_ELEMENTS(I) \
((size_t)((I)->Bands * (I)->Xsize)) ((I)->Bands * (I)->Xsize)
/* If DEBUG is defined, add bounds checking. /* If DEBUG is defined, add bounds checking.
*/ */

View File

@ -56,6 +56,7 @@
#include <assert.h> #include <assert.h>
#include <vips/vips.h> #include <vips/vips.h>
#include <vips/internal.h>
#ifdef WITH_DMALLOC #ifdef WITH_DMALLOC
#include <dmalloc.h> #include <dmalloc.h>
@ -1515,17 +1516,20 @@ im__open_temp( void )
return( disc ); return( disc );
} }
static const int bits[] = { /* This gets indexed by (eg.) IM_IMAGE_SIZEOF_ELEMENT() to calculate object
IM_BBITS_BYTE, * size.
IM_BBITS_BYTE, */
IM_BBITS_SHORT, const size_t im__sizeof_bandfmt[] = {
IM_BBITS_SHORT, IM_BBITS_BYTE >> 3,
IM_BBITS_INT, IM_BBITS_BYTE >> 3,
IM_BBITS_INT, IM_BBITS_SHORT >> 3,
IM_BBITS_FLOAT, IM_BBITS_SHORT >> 3,
IM_BBITS_COMPLEX, IM_BBITS_INT >> 3,
IM_BBITS_DOUBLE, IM_BBITS_INT >> 3,
IM_BBITS_DPCOMPLEX IM_BBITS_FLOAT >> 3,
IM_BBITS_COMPLEX >> 3,
IM_BBITS_DOUBLE >> 3,
IM_BBITS_DPCOMPLEX >> 3
}; };
/* Return number of pel bits for band format, or -1 on error. /* Return number of pel bits for band format, or -1 on error.
@ -1537,6 +1541,6 @@ im_bits_of_fmt( VipsBandFmt fmt )
im_error( "im_bits_of_fmt", im_error( "im_bits_of_fmt",
_( "unsupported band format: %d" ), fmt ), _( "unsupported band format: %d" ), fmt ),
-1 : -1 :
bits[fmt] ); im__sizeof_bandfmt[fmt] << 3 );
} }