Forgot to denote in the check-in msg: The image data are stored horizontally, while SciQL stores 2D arrays vertically. The previous code doesn't reorder the image data according to the SciQL ordering, which causes image to be shifted. This is now fixed.
On Tue, Jul 24, 2012 at 01:51:35PM +0200, Jennie Zhang wrote: > Changeset: c81781356c64 for MonetDB > URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c81781356c64 > Modified Files: > sql/backends/monet5/vaults/geotiff/geotiff.c > Branch: sciql > Log Message: > > applied Holger's fix for the GeoTIFF loadimage code with a bit clean up. > > Note that this code is only tested with GeoTIFF image with BPS=8. Most > probably it does not work if BPS=16, but a sample image is needed to correct > it. > > > diffs (50 lines): > > diff --git a/sql/backends/monet5/vaults/geotiff/geotiff.c > b/sql/backends/monet5/vaults/geotiff/geotiff.c > --- a/sql/backends/monet5/vaults/geotiff/geotiff.c > +++ b/sql/backends/monet5/vaults/geotiff/geotiff.c > @@ -128,10 +128,10 @@ GTIFFloadImage(bat *result, str *fname) > { > TIFF *tif = (TIFF*)0; > int wid = 0, len = 0; > - BUN pixels = BUN_NONE, strsize = BUN_NONE, sz = BUN_NONE; > + BUN pixels = BUN_NONE; > sht photoint, bps; > - tsize_t strcnt, i; > - void *data = NULL; > + tsize_t i, j; > + void *data = NULL, *linebuf = NULL; > BAT *res; > > > @@ -170,19 +170,12 @@ GTIFFloadImage(bat *result, str *fname) > > > /* read data */ > - strsize = TIFFStripSize(tif); > - strcnt = TIFFNumberOfStrips(tif); > + linebuf = GDKmalloc(wid); /* buffer for one line of image */ > data = (void *) Tloc(res, BUNfirst(res)); > - for( i = 0; i < strcnt; i++){ > - sz = TIFFReadEncodedStrip(tif, i, data, strsize); > - if ( sz == strsize ) > - data = (void *)((char *)data + strsize); > - else if (( i < strcnt - 1 ) || /* interm. strip not > full */ > - (( i == strcnt - 1 ) && (pixels * bps/8 != strsize * i > + sz))){ /* last strip not full */ > - XTIFFClose(tif); > - BBPreclaim(res); > - res = NULL; > - return createException(MAL, "geotiff.loadimage", > "Stripsize mismatch"); > + for( i = 0; i < len; i++){ > + if (TIFFReadScanline(tif, linebuf, i, 0) != -1) { > + for (j = 0; j < wid; j++) > + ((unsigned char*)data)[j*len+i] = ((unsigned > char*)linebuf)[j]; > } > } > > @@ -196,6 +189,7 @@ GTIFFloadImage(bat *result, str *fname) > > BBPkeepref(*result = res->batCacheid); > XTIFFClose(tif); > + GDKfree(linebuf); > return MAL_SUCCEED; > } > > _______________________________________________ > Checkin-list mailing list > [email protected] > http://mail.monetdb.org/mailman/listinfo/checkin-list _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
