- Timestamp:
- 05/16/08 16:17:25 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.5/gdal/frmts/aaigrid/aaigriddataset.cpp
r13865 r14477 767 767 /* Loop over image, copying image data. */ 768 768 /* -------------------------------------------------------------------- */ 769 double *padfScanline; 769 int *panScanline = NULL; 770 double *padfScanline = NULL; 771 int bReadAsInt; 770 772 int iLine, iPixel; 771 773 CPLErr eErr = CE_None; 772 774 775 bReadAsInt = ( poBand->GetRasterDataType() == GDT_Byte 776 || poBand->GetRasterDataType() == GDT_Int16 777 || poBand->GetRasterDataType() == GDT_UInt16 778 || poBand->GetRasterDataType() == GDT_Int32 ); 779 773 780 // Write scanlines to output file 774 padfScanline = (double *) CPLMalloc( nXSize * 775 GDALGetDataTypeSize(GDT_CFloat64) / 8 ); 781 if (bReadAsInt) 782 panScanline = (int *) CPLMalloc( nXSize * 783 GDALGetDataTypeSize(GDT_Int32) / 8 ); 784 else 785 padfScanline = (double *) CPLMalloc( nXSize * 786 GDALGetDataTypeSize(GDT_Float64) / 8 ); 787 776 788 for( iLine = 0; eErr == CE_None && iLine < nYSize; iLine++ ) 777 789 { 778 790 eErr = poBand->RasterIO( GF_Read, 0, iLine, nXSize, 1, 779 padfScanline, nXSize, 1, GDT_CFloat64, 780 sizeof(double), sizeof(double) * nXSize ); 781 782 if( poBand->GetRasterDataType() == GDT_Byte 783 || poBand->GetRasterDataType() == GDT_Int16 784 || poBand->GetRasterDataType() == GDT_UInt16 785 || poBand->GetRasterDataType() == GDT_Int32 ) 791 (bReadAsInt) ? (void*)panScanline : (void*)padfScanline, 792 nXSize, 1, (bReadAsInt) ? GDT_Int32 : GDT_Float64, 793 0, 0 ); 794 795 if( bReadAsInt ) 786 796 { 787 797 for ( iPixel = 0; iPixel < nXSize; iPixel++ ) 788 798 { 789 sprintf( szHeader, " %d", (int) padfScanline[iPixel] );799 sprintf( szHeader, " %d", panScanline[iPixel] ); 790 800 if( VSIFWriteL( szHeader, strlen(szHeader), 1, fpImage ) != 1 ) 791 801 { … … 822 832 } 823 833 834 CPLFree( panScanline ); 824 835 CPLFree( padfScanline ); 825 836 VSIFCloseL( fpImage );
