2013.10.08 10:01 "[Tiff] Problem with reading tiff exported from GDAL in C", by Josef Olah
I'm using libtiff library in my diploma thesis, but I encountered a problem, when I wanted to read image data in C language.
I have tiff image exported from GDAL:
(histogram stretch is needed for good view (e.g. using QGIS))
which is composed of three channels (RGB). Original GDAL data file was composed of 65 channels, but I GDALRasterIO-ed it into RGB.
Now I'd like to read this tiff file using methods from libtiff webpage (http://www.remotesensing.org/libtiff/libtiff.html#tiffrgbaimage),
but when I'm using either the first or the second method (i.e. TIFFReadRGBAImage or TIFFRGBAImageBegin/TIFFRGBAImageGet/TIFFRGBAImageEnd)
I'm still facing the same problem during debugging in VS2012
(Unhandled exception at 0x6FDB01C0 (libtiff3.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0x0105C001.).
Here is part of my C code:
uint32 w, h;
tif_load = TIFFOpen("C:/./BK4_10_rad_Export_line_2.tif", "r");
TIFFGetField(tif_load, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tif_load, TIFFTAG_IMAGELENGTH, &h);
npixels = w * h;
raster = (uint32*) _TIFFmalloc(npixels*sizeof(uint32));
TIFFReadRGBAImage(tif_load, w, h, raster, 0);
//working with raster
I really don't know where is that issue, so I hope someone will help me.
Thank you in advance and sorry for my English.
Best regards, Josef Olah