diff --git a/Code/IO/otbGDALImageIO.cxx b/Code/IO/otbGDALImageIO.cxx index 61fdb3a48ce518b8ad0713f218ae64242c9bf4d7..7cbcc7bd51f9157a49cfdc79885894c2d96426b6 100644 --- a/Code/IO/otbGDALImageIO.cxx +++ b/Code/IO/otbGDALImageIO.cxx @@ -211,7 +211,7 @@ void GDALImageIO::PrintSelf(std::ostream& os, itk::Indent indent) const Superclass::PrintSelf(os, indent); os << indent << "Compression Level : " << m_CompressionLevel << "\n"; os << indent << "IsComplex (otb side) : " << m_IsComplex << "\n"; - os << indent << "Byte per pixel : " << m_NbOctetPixel << "\n"; + os << indent << "Byte per pixel : " << m_BytePerPixel << "\n"; } // Read a 3D image (or event more bands)... not implemented yet @@ -237,7 +237,7 @@ void GDALImageIO::Read(void* buffer) std::streamoff lNbPixels = (static_cast<std::streamoff>(lNbColumns)) * (static_cast<std::streamoff>(lNbLines)); - std::streamoff lBufferSize = static_cast<std::streamoff>(m_NbOctetPixel) * lNbPixels; + std::streamoff lBufferSize = static_cast<std::streamoff>(m_BytePerPixel) * lNbPixels; if (GDALDataTypeIsComplex(m_PxType) && !m_IsComplex) { lBufferSize *= 2; @@ -269,18 +269,18 @@ void GDALImageIO::Read(void* buffer) itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName ); } cpt = 0; - for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_NbOctetPixel)) + for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_BytePerPixel)) { - memcpy((void*) (&(p[cpt])), (const void*) (&(value[i])), (size_t) (m_NbOctetPixel)); - cpt += static_cast<std::streamoff>(m_NbOctetPixel); + memcpy((void*) (&(p[cpt])), (const void*) (&(value[i])), (size_t) (m_BytePerPixel)); + cpt += static_cast<std::streamoff>(m_BytePerPixel); } } else if (GDALDataTypeIsComplex(m_PxType) && !m_IsComplex) { // Mise a jour du step - step = step * static_cast<std::streamoff>(m_NbOctetPixel); + step = step * static_cast<std::streamoff>(m_BytePerPixel); - for (unsigned int nbComponents = 0; nbComponents < dataset->GetRasterCount(); ++nbComponents) + for (int nbComponents = 0; nbComponents < dataset->GetRasterCount(); ++nbComponents) { lCrGdal = dataset->GetRasterBand(nbComponents+1)->RasterIO(GF_Read, lFirstColumn, @@ -298,11 +298,15 @@ void GDALImageIO::Read(void* buffer) itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName.c_str() << "."); } // Recopie dans le buffer - cpt = static_cast<std::streamoff>(nbComponents) * static_cast<std::streamoff>(m_NbOctetPixel); - for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_NbOctetPixel)) + cpt = static_cast<std::streamoff>(nbComponents) * static_cast<std::streamoff>(m_BytePerPixel); + for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_BytePerPixel)) { - memcpy((void*) (&(p[cpt])), (const void*) (&(value[i])), (size_t) (m_NbOctetPixel)); //Real part - memcpy((void*) (&(p[cpt+m_NbOctetPixel])), (const void*) (&(value[i+m_NbOctetPixel])), (size_t) (m_NbOctetPixel)); //Imaginary part + memcpy((void*) (&(p[cpt])), + (const void*) (&(value[i])), + (size_t) (m_BytePerPixel)); //Real part + memcpy((void*) (&(p[cpt+m_BytePerPixel])), + (const void*) (&(value[i+m_BytePerPixel])), + (size_t) (m_BytePerPixel)); //Imaginary part cpt += step; } } @@ -310,7 +314,7 @@ void GDALImageIO::Read(void* buffer) } else if (m_IsIndexed) { - step = step * static_cast<std::streamoff>(m_NbOctetPixel); + step = step * static_cast<std::streamoff>(m_BytePerPixel); lCrGdal = dataset->GetRasterBand(1)->RasterIO(GF_Read, lFirstColumn, @@ -330,7 +334,7 @@ void GDALImageIO::Read(void* buffer) // Recopie dans le buffer cpt = 0; GDALColorTable* colorTable = dataset->GetRasterBand(1)->GetColorTable(); - for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_NbOctetPixel)) + for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_BytePerPixel)) { GDALColorEntry color; colorTable->GetColorEntryAsRGB(value[i], &color); @@ -344,9 +348,9 @@ void GDALImageIO::Read(void* buffer) else { // Mise a jour du step - step = step * static_cast<std::streamoff>(m_NbOctetPixel); + step = step * static_cast<std::streamoff>(m_BytePerPixel); - for (unsigned int nbComponents = 0; nbComponents < dataset->GetRasterCount(); ++nbComponents) + for (int nbComponents = 0; nbComponents < dataset->GetRasterCount(); ++nbComponents) { lCrGdal = dataset->GetRasterBand(nbComponents+1)->RasterIO(GF_Read, lFirstColumn, @@ -364,10 +368,10 @@ void GDALImageIO::Read(void* buffer) itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName.c_str() << "."); } // Recopie dans le buffer - cpt = static_cast<std::streamoff>(nbComponents) * static_cast<std::streamoff>(m_NbOctetPixel); - for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_NbOctetPixel)) + cpt = static_cast<std::streamoff>(nbComponents) * static_cast<std::streamoff>(m_BytePerPixel); + for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff>(m_BytePerPixel)) { - memcpy((void*) (&(p[cpt])), (const void*) (&(value[i])), (size_t) (m_NbOctetPixel)); + memcpy((void*) (&(p[cpt])), (const void*) (&(value[i])), (size_t) (m_BytePerPixel)); cpt += step; } } @@ -483,43 +487,43 @@ void GDALImageIO::InternalReadImageInformation() if (this->GetComponentType() == CHAR) { - m_NbOctetPixel = 1; + m_BytePerPixel = 1; } else if (this->GetComponentType() == UCHAR) { - m_NbOctetPixel = 1; + m_BytePerPixel = 1; } else if (this->GetComponentType() == USHORT) { - m_NbOctetPixel = 2; + m_BytePerPixel = 2; } else if (this->GetComponentType() == SHORT) { - m_NbOctetPixel = 2; + m_BytePerPixel = 2; } else if (this->GetComponentType() == INT) { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; } else if (this->GetComponentType() == UINT) { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; } else if (this->GetComponentType() == FLOAT) { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; } else if (this->GetComponentType() == DOUBLE) { - m_NbOctetPixel = 8; + m_BytePerPixel = 8; } else if (this->GetComponentType() == CFLOAT) { - m_NbOctetPixel = sizeof(std::complex<float>); + m_BytePerPixel = sizeof(std::complex<float>); } else if (this->GetComponentType() == CDOUBLE) { - m_NbOctetPixel = sizeof(std::complex<double>); + m_BytePerPixel = sizeof(std::complex<double>); } else { @@ -535,11 +539,10 @@ void GDALImageIO::InternalReadImageInformation() && (m_PxType != GDT_CFloat32) && (m_PxType != GDT_CFloat64)) { - m_NbOctetPixel = m_NbOctetPixel * 2; + m_BytePerPixel = m_BytePerPixel * 2; this->SetNumberOfComponents(2); this->SetPixelType(COMPLEX); // Is this necessary ? - //if(m_NbBands !=1) itkExceptionMacro(<<"GDALImageIO::InternalReadImageInformation() Can read only one band image "); } else { @@ -559,7 +562,7 @@ void GDALImageIO::InternalReadImageInformation() // we are reading a complex data set into an image where the pixel // type is not complex: we have to double the number of component // for that to work - m_NbOctetPixel = m_NbOctetPixel / 2; + m_BytePerPixel = m_BytePerPixel / 2; this->SetNumberOfComponents(m_NbBands*2); this->SetPixelType(VECTOR); } @@ -697,7 +700,8 @@ void GDALImageIO::InternalReadImageInformation() if (projRef.empty()) { projRef = - "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]"; + "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]]," + "PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]"; itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, projRef); } @@ -911,7 +915,7 @@ void GDALImageIO::Write(const void* buffer) } std::streamoff lNbPixels = static_cast<std::streamoff> (lNbColumns) * static_cast<std::streamoff> (lNbLines); - std::streamoff lBufferSize = static_cast<std::streamoff> (m_NbOctetPixel) * lNbPixels; + std::streamoff lBufferSize = static_cast<std::streamoff> (m_BytePerPixel) * lNbPixels; otbMsgDevMacro(<< " BufferSize allocated : " << lBufferSize); itk::VariableLengthVector<unsigned char> value(lBufferSize); @@ -920,24 +924,33 @@ void GDALImageIO::Write(const void* buffer) { // Update Step std::streamoff step = static_cast<std::streamoff> (m_NbBands); - step = step * static_cast<std::streamoff> (m_NbOctetPixel); + step = step * static_cast<std::streamoff> (m_BytePerPixel); CPLErr lCrGdal; std::streamoff cpt(0); for (int nbComponents = 0; nbComponents < m_NbBands; ++nbComponents) { - cpt = static_cast<std::streamoff> (nbComponents) * static_cast<std::streamoff> (m_NbOctetPixel); + cpt = static_cast<std::streamoff> (nbComponents) * static_cast<std::streamoff> (m_BytePerPixel); - for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff> (m_NbOctetPixel)) + for (std::streamoff i = 0; i < lBufferSize; i = i + static_cast<std::streamoff> (m_BytePerPixel)) { - memcpy((void*) (&(value[i])), (const void*) (&(p[cpt])), (size_t) (m_NbOctetPixel)); + memcpy((void*) (&(value[i])), (const void*) (&(p[cpt])), (size_t) (m_BytePerPixel)); cpt += step; } GDALRasterBand *poBand = m_Dataset->GetDataSet()->GetRasterBand(nbComponents+1); - lCrGdal = poBand->RasterIO(GF_Write, lFirstColumn, lFirstLine, lNbColumns, lNbLines, const_cast<unsigned char*>(value.GetDataPointer()), - lNbColumns, lNbLines, m_PxType, 0, 0); + lCrGdal = poBand->RasterIO(GF_Write, + lFirstColumn, + lFirstLine, + lNbColumns, + lNbLines, + const_cast<unsigned char*>(value.GetDataPointer()), + lNbColumns, + lNbLines, + m_PxType, + 0, + 0); if (lCrGdal == CE_Failure) { itkExceptionMacro(<< "Error while writing image (GDAL format) " << m_FileName.c_str() << "."); @@ -999,28 +1012,28 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) if (this->GetComponentType() == SHORT) { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; m_PxType = GDT_CInt16; } else if (this->GetComponentType() == INT) { - m_NbOctetPixel = 8; + m_BytePerPixel = 8; m_PxType = GDT_CInt32; } else if (this->GetComponentType() == DOUBLE) { - m_NbOctetPixel = 16; + m_BytePerPixel = 16; m_PxType = GDT_CFloat64; } else if (this->GetComponentType() == FLOAT) { - m_NbOctetPixel = 8; + m_BytePerPixel = 8; m_PxType = GDT_CFloat32; } else { this->SetComponentType(FLOAT); - m_NbOctetPixel = 8; + m_BytePerPixel = 8; m_PxType = GDT_CFloat32; } } @@ -1028,47 +1041,47 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) { if (this->GetComponentType() == CHAR) { - m_NbOctetPixel = 1; + m_BytePerPixel = 1; m_PxType = GDT_Byte; } else if (this->GetComponentType() == UCHAR) { - m_NbOctetPixel = 1; + m_BytePerPixel = 1; m_PxType = GDT_Byte; } else if (this->GetComponentType() == USHORT) { - m_NbOctetPixel = 2; + m_BytePerPixel = 2; m_PxType = GDT_UInt16; } else if (this->GetComponentType() == SHORT) { - m_NbOctetPixel = 2; + m_BytePerPixel = 2; m_PxType = GDT_Int16; } else if (this->GetComponentType() == INT) { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; m_PxType = GDT_Int32; } else if (this->GetComponentType() == UINT) { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; m_PxType = GDT_UInt32; } else if (this->GetComponentType() == FLOAT) { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; m_PxType = GDT_Float32; } else if (this->GetComponentType() == DOUBLE) { - m_NbOctetPixel = 8; + m_BytePerPixel = 8; m_PxType = GDT_Float64; } else { - m_NbOctetPixel = 1; + m_BytePerPixel = 1; m_PxType = GDT_Byte; } } @@ -1105,9 +1118,9 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) << "LINES=" << m_Dimensions[1] << "," << "BANDS=" << m_NbBands << "," << "DATATYPE=" << GDALGetDataTypeName(m_PxType) << "," - << "PIXELOFFSET=" << m_NbOctetPixel * m_NbBands << "," - << "LINEOFFSET=" << m_NbOctetPixel * m_NbBands * m_Dimensions[0] << "," - << "BANDOFFSET=" << m_NbOctetPixel; + << "PIXELOFFSET=" << m_BytePerPixel * m_NbBands << "," + << "LINEOFFSET=" << m_BytePerPixel * m_NbBands * m_Dimensions[0] << "," + << "BANDOFFSET=" << m_BytePerPixel; m_Dataset = GDALDriverManagerWrapper::GetInstance().Open(stream.str()); } diff --git a/Code/IO/otbGDALImageIO.h b/Code/IO/otbGDALImageIO.h index 123a1f7d8ee95c8d77cbb5c7d104cbfa5f751900..5d5d8e9c009d6c83e0e1937b1baa7c5b47698f89 100644 --- a/Code/IO/otbGDALImageIO.h +++ b/Code/IO/otbGDALImageIO.h @@ -153,7 +153,7 @@ private: GDALDataType m_PxType; /** Nombre d'octets par pixel */ - int m_NbOctetPixel; + int m_BytePerPixel; bool GDALInfoReportCorner(const char * corner_name, double x, double y, double& dfGeoX, double& dfGeoY); diff --git a/Code/IO/otbJPEG2000ImageIO.cxx b/Code/IO/otbJPEG2000ImageIO.cxx index d87f9a4e393fc2b8103796bdd2b2547dbb052b01..89aab8ab81c3191ff0b028029eda4ae187f44c31 100644 --- a/Code/IO/otbJPEG2000ImageIO.cxx +++ b/Code/IO/otbJPEG2000ImageIO.cxx @@ -64,7 +64,7 @@ JPEG2000ImageIO::JPEG2000ImageIO() m_Origin[0] = 0.0; m_Origin[1] = 0.0; - m_NbOctetPixel = 1; + m_BytePerPixel = 1; } JPEG2000ImageIO::~JPEG2000ImageIO() @@ -296,17 +296,17 @@ void JPEG2000ImageIO::Read(void* buffer) std::streamsize tile_component_size = data_size / nb_comps; std::streamoff buffer_skip = - std::max(0, tile_y0 - buffer_y0) * buffer_size_x * nb_comps * m_NbOctetPixel; - std::streamoff tile_skip = std::max(0, buffer_y0 - tile_y0) * (tile_x1 - tile_x0) * m_NbOctetPixel; - std::streamoff tile_offset_begin = std::max(0, buffer_x0 - tile_x0) * m_NbOctetPixel; - std::streamoff buffer_offset_begin = std::max(0, tile_x0 - buffer_x0) * nb_comps * m_NbOctetPixel; + std::max(0, tile_y0 - buffer_y0) * buffer_size_x * nb_comps * m_BytePerPixel; + std::streamoff tile_skip = std::max(0, buffer_y0 - tile_y0) * (tile_x1 - tile_x0) * m_BytePerPixel; + std::streamoff tile_offset_begin = std::max(0, buffer_x0 - tile_x0) * m_BytePerPixel; + std::streamoff buffer_offset_begin = std::max(0, tile_x0 - buffer_x0) * nb_comps * m_BytePerPixel; std::streamsize line_size = (std::min(tile_x1, buffer_x0 + buffer_size_x - 1) - std::max(tile_x0, buffer_x0) + 1); std::streamsize nb_lines = std::min(tile_y1, buffer_y0 + buffer_size_y - 1) - std::max(tile_y0, buffer_y0) + 1; - std::streamsize buffer_line_size = buffer_size_x * nb_comps * m_NbOctetPixel; - std::streamsize tile_line_size = (tile_x1 - tile_x0) * m_NbOctetPixel; - std::streampos buffer_step = nb_comps * m_NbOctetPixel; + std::streamsize buffer_line_size = buffer_size_x * nb_comps * m_BytePerPixel; + std::streamsize tile_line_size = (tile_x1 - tile_x0) * m_BytePerPixel; + std::streampos buffer_step = nb_comps * m_BytePerPixel; otbMsgDevMacro(<< "buffer_skip: " << buffer_skip); otbMsgDevMacro(<< "tile_skip: " << tile_skip); @@ -324,15 +324,15 @@ void JPEG2000ImageIO::Read(void* buffer) { for (int line = 0; line < nb_lines; ++line) { - buffer_pos = buffer_skip + comp * m_NbOctetPixel + line * buffer_line_size + buffer_offset_begin; + buffer_pos = buffer_skip + comp * m_BytePerPixel + line * buffer_line_size + buffer_offset_begin; tile_pos = comp * tile_component_size + tile_skip + line * tile_line_size + tile_offset_begin; for (int cols = 0; cols < line_size; ++cols) { - for (unsigned int octet = 0; octet < m_NbOctetPixel; ++octet) + for (unsigned int octet = 0; octet < m_BytePerPixel; ++octet) { charstarbuffer[buffer_pos + cols * buffer_step + - octet] = tile_data[tile_pos + cols * m_NbOctetPixel + octet]; + octet] = tile_data[tile_pos + cols * m_BytePerPixel + octet]; } } } @@ -432,7 +432,7 @@ void JPEG2000ImageIO::ReadImageInformation() if (precision <= 8) { - m_NbOctetPixel = 1; + m_BytePerPixel = 1; if (isSigned) { SetComponentType(CHAR); @@ -444,7 +444,7 @@ void JPEG2000ImageIO::ReadImageInformation() } else if (precision <= 16) { - m_NbOctetPixel = 2; + m_BytePerPixel = 2; if (isSigned) { SetComponentType(SHORT); @@ -456,7 +456,7 @@ void JPEG2000ImageIO::ReadImageInformation() } else { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; if (isSigned) { SetComponentType(INT); @@ -483,7 +483,7 @@ void JPEG2000ImageIO::ReadImageInformation() otbMsgDebugMacro(<< "Number of tiles: " << nb_tiles_x << " " << nb_tiles_y); otbMsgDebugMacro(<< "Precision: " << precision); otbMsgDebugMacro(<< "Signed: " << isSigned); - otbMsgDebugMacro(<< "Number of octet per value: " << m_NbOctetPixel); + otbMsgDebugMacro(<< "Number of octet per value: " << m_BytePerPixel); otbMsgDebugMacro(<< "=========================="); otbMsgDebugMacro(<< "Driver to read: JPEG2000"); @@ -532,47 +532,47 @@ void JPEG2000ImageIO::Write(const void* /*buffer*/) // if ( this->GetComponentType() == CHAR ) // { -// m_NbOctetPixel = 1; +// m_BytePerPixel = 1; // m_PxType = GDT_Byte; // } // else if ( this->GetComponentType() == UCHAR ) // { -// m_NbOctetPixel = 1; +// m_BytePerPixel = 1; // m_PxType = GDT_Byte; // } // else if ( this->GetComponentType() == USHORT ) // { -// m_NbOctetPixel = 2; +// m_BytePerPixel = 2; // m_PxType = GDT_UInt16; // } // else if ( this->GetComponentType() == SHORT ) // { -// m_NbOctetPixel = 2; +// m_BytePerPixel = 2; // m_PxType = GDT_Int16; // } // else if ( this->GetComponentType() == INT ) // { -// m_NbOctetPixel = 4; +// m_BytePerPixel = 4; // m_PxType = GDT_Int32; // } // else if ( this->GetComponentType() == UINT ) // { -// m_NbOctetPixel = 4; +// m_BytePerPixel = 4; // m_PxType = GDT_UInt32; // } // else if ( this->GetComponentType() == FLOAT ) // { -// m_NbOctetPixel = 4; +// m_BytePerPixel = 4; // m_PxType = GDT_Float32; // } // else if ( this->GetComponentType() == DOUBLE ) // { -// m_NbOctetPixel = 8; +// m_BytePerPixel = 8; // m_PxType = GDT_Float64; // } // else // { -// m_NbOctetPixel = 1; +// m_BytePerPixel = 1; // m_PxType = GDT_Byte; // } @@ -654,7 +654,7 @@ void JPEG2000ImageIO::Write(const void* /*buffer*/) // l_current_param_ptr->dy = 1; // l_current_param_ptr->h = m_Dimensions[1]; // l_current_param_ptr->sgnd = 0; -// l_current_param_ptr->prec = 8*m_NbOctetPixel; +// l_current_param_ptr->prec = 8*m_BytePerPixel; // l_current_param_ptr->w = m_Dimensions[0]; // l_current_param_ptr->x0 = 0; // l_current_param_ptr->y0 = 0; @@ -713,7 +713,7 @@ void JPEG2000ImageIO::Write(const void* /*buffer*/) // std::streamsize buffer_size_x = this->GetIORegion().GetSize()[0]; // std::streamsize buffer_size_y = this->GetIORegion().GetSize()[1]; -// std::streamsize buffer_size = this->GetIORegion().GetNumberOfPixels()*m_NbOctetPixel*m_nbBands; +// std::streamsize buffer_size = this->GetIORegion().GetNumberOfPixels()*m_BytePerPixel*m_nbBands; // unsigned int nb_tile_x = (unsigned int)vcl_ceil((double)m_Dimensions[0]/(double)m_Parameters.cp_tdx); // unsigned int nb_tile_y = (unsigned int)vcl_ceil((double)m_Dimensions[1]/(double)m_Parameters.cp_tdy); @@ -722,7 +722,7 @@ void JPEG2000ImageIO::Write(const void* /*buffer*/) // OPJ_BYTE * desinterleaved_data = new OPJ_BYTE[buffer_size]; -// std::streamoff step = m_NbBands*m_NbOctetPixel; +// std::streamoff step = m_NbBands*m_BytePerPixel; // std::streamsize component_size = new diff --git a/Code/IO/otbJPEG2000ImageIO.h b/Code/IO/otbJPEG2000ImageIO.h index 01920f4015ef0cefbeca718d1e2e464f0a06bb37..816411b627ba773c67a88d6518bbb071290d2e55 100644 --- a/Code/IO/otbJPEG2000ImageIO.h +++ b/Code/IO/otbJPEG2000ImageIO.h @@ -120,7 +120,7 @@ private: /** Openjpeg stream */ opj_stream_t * m_OpenJpegStream; /** pixel nb of octets */ - unsigned int m_NbOctetPixel; + unsigned int m_BytePerPixel; }; diff --git a/Code/IO/otbMSTARImageIO.cxx b/Code/IO/otbMSTARImageIO.cxx index 3b8ab06bef362c05ce4a55079528feedfc8574c4..5d43da3a868c31911eb0f569d2f3e353c8bac95a 100644 --- a/Code/IO/otbMSTARImageIO.cxx +++ b/Code/IO/otbMSTARImageIO.cxx @@ -58,7 +58,7 @@ MSTARImageIO::MSTARImageIO() m_Origin[0] = 0.0; m_Origin[1] = 0.0; - m_NbOctetPixel = 0; + m_BytePerPixel = 0; MSTARfp = NULL; /* Input FILE ptr to MSTAR image file */ HDRfp = NULL; /* Output FILE ptr to MSTAR header file */ @@ -313,14 +313,14 @@ void MSTARImageIO::Read(void* buffer) otbMsgDevMacro(<< " Scene type "); } - unsigned long step = this->GetNumberOfComponents() * (unsigned long) (m_NbOctetPixel); + unsigned long step = this->GetNumberOfComponents() * (unsigned long) (m_BytePerPixel); float * p = static_cast<float *>(buffer); int lNbLines = this->GetIORegion().GetSize()[1]; int lNbColumns = this->GetIORegion().GetSize()[0]; unsigned long lNbPixels = (unsigned long) (lNbColumns * lNbLines); - unsigned long lTailleBuffer = (unsigned long) (m_NbOctetPixel) * lNbPixels; + unsigned long lTailleBuffer = (unsigned long) (m_BytePerPixel) * lNbPixels; unsigned char* value = new unsigned char[lTailleBuffer]; @@ -467,10 +467,10 @@ void MSTARImageIO::Read(void* buffer) // Recopie dans le buffer unsigned long cpt(0); - cpt = (unsigned long) (nbComponents) * (unsigned long) (m_NbOctetPixel); - for (unsigned long i = 0; i < lTailleBuffer; i = i + m_NbOctetPixel) + cpt = (unsigned long) (nbComponents) * (unsigned long) (m_BytePerPixel); + for (unsigned long i = 0; i < lTailleBuffer; i = i + m_BytePerPixel) { - memcpy((void*) (&(p[cpt])), (const void*) (&(FSCENEdata[i])), (size_t) (m_NbOctetPixel)); + memcpy((void*) (&(p[cpt])), (const void*) (&(FSCENEdata[i])), (size_t) (m_BytePerPixel)); cpt += step; } @@ -508,10 +508,10 @@ void MSTARImageIO::Read(void* buffer) // Recopie dans le buffer unsigned long cpt(0); - cpt = (unsigned long) (nbComponents) * (unsigned long) (m_NbOctetPixel); - for (unsigned long i = 0; i < lTailleBuffer; i = i + m_NbOctetPixel) + cpt = (unsigned long) (nbComponents) * (unsigned long) (m_BytePerPixel); + for (unsigned long i = 0; i < lTailleBuffer; i = i + m_BytePerPixel) { - memcpy((void*) (&(p[cpt])), (const void*) (&(CHIPdata[i])), (size_t) (m_NbOctetPixel)); + memcpy((void*) (&(p[cpt])), (const void*) (&(CHIPdata[i])), (size_t) (m_BytePerPixel)); cpt += step; } @@ -540,7 +540,7 @@ void MSTARImageIO::ReadImageInformation() { int NbLignes; /* Nombre de lignes de l'image */ int NbColonnes; /* Nombre de colonnes de l'image */ - int NbOctetPixel = sizeof(float); /* Nombre octets/pixel l'image */ + int BytePerPixel = sizeof(float); /* Nombre octets/pixel l'image */ MSTARname = m_FileName.c_str(); MSTARfp = fopen(MSTARname, "rb"); @@ -624,7 +624,7 @@ void MSTARImageIO::ReadImageInformation() this->SetNumberOfDimensions(2); m_Dimensions[0] = NbColonnes; m_Dimensions[1] = NbLignes; - m_NbOctetPixel = NbOctetPixel; + m_BytePerPixel = BytePerPixel; otbMsgDebugMacro(<< "Image size cree : " << m_Dimensions[0] << "," << m_Dimensions[1]); m_PixelType = VECTOR; diff --git a/Code/IO/otbMSTARImageIO.h b/Code/IO/otbMSTARImageIO.h index a1a69bc4449766903365744cfb8be7fcffdd8b55..6f9a23de50e21bdc613e90a325a742b8d018965f 100644 --- a/Code/IO/otbMSTARImageIO.h +++ b/Code/IO/otbMSTARImageIO.h @@ -133,7 +133,7 @@ private: unsigned char bigushortbuf[2]; /* BigEndian ushort buffer...*/ unsigned short littleushortval; /* LittleEndian ushort value.*/ - int m_NbOctetPixel; + int m_BytePerPixel; }; } // end namespace otb diff --git a/Code/IO/otbONERAImageIO.cxx b/Code/IO/otbONERAImageIO.cxx index 7d3131b7f0eb6b925e26925831c0458dece5c665..c6cc9fae6f90f1fc381de8c3f280a85cf0ad1156 100644 --- a/Code/IO/otbONERAImageIO.cxx +++ b/Code/IO/otbONERAImageIO.cxx @@ -40,7 +40,7 @@ ONERAImageIO::ONERAImageIO() this->SetNumberOfDimensions(2); m_PixelType = COMPLEX; m_ComponentType = FLOAT; - m_NbOctetPixel = 4; + m_BytePerPixel = 4; // Set default spacing to one m_Spacing[0] = 1.0; @@ -188,10 +188,10 @@ void ONERAImageIO::Read(void* buffer) itkExceptionMacro(<< "Cannot read requested file"); } - std::streamoff numberOfBytesPerLines = static_cast<std::streamoff>(2 * m_width * m_NbOctetPixel); + std::streamoff numberOfBytesPerLines = static_cast<std::streamoff>(2 * m_width * m_BytePerPixel); std::streamoff headerLength = ONERA_HEADER_LENGTH + numberOfBytesPerLines; std::streamoff offset; - std::streamsize numberOfBytesToBeRead = 2 * m_NbOctetPixel * lNbColumns; + std::streamsize numberOfBytesToBeRead = 2 * m_BytePerPixel * lNbColumns; std::streamsize numberOfBytesRead; char* value = new char[numberOfBytesToBeRead]; @@ -200,7 +200,7 @@ void ONERAImageIO::Read(void* buffer) for (int LineNo = lFirstLine; LineNo < lFirstLine + lNbLines; LineNo++) { offset = headerLength + numberOfBytesPerLines * static_cast<std::streamoff>(LineNo); - offset += static_cast<std::streamoff>(m_NbOctetPixel * lFirstColumn); + offset += static_cast<std::streamoff>(m_BytePerPixel * lFirstColumn); m_Datafile.seekg(offset, std::ios::beg); m_Datafile.read(static_cast<char *>(value), numberOfBytesToBeRead); numberOfBytesRead = m_Datafile.gcount(); @@ -322,7 +322,7 @@ void ONERAImageIO::InternalReadImageInformation() this->SetNumberOfComponents(2); this->SetPixelType(COMPLEX); m_ComponentType = FLOAT; - m_NbOctetPixel = 4; + m_BytePerPixel = 4; } else { @@ -385,7 +385,7 @@ void ONERAImageIO::InternalReadImageInformation() otbMsgDebugMacro(<< " ComponentType : " << this->GetComponentTypeAsString(this->GetComponentType())); otbMsgDebugMacro(<< " ComponentSize : " << this->GetComponentSize()); otbMsgDebugMacro(<< " NumberOfComponents : " << this->GetNumberOfComponents()); - otbMsgDebugMacro(<< " NbOctetPixel : " << m_NbOctetPixel); + otbMsgDebugMacro(<< " BytePerPixel : " << m_BytePerPixel); otbMsgDebugMacro(<< " Host byte order : " << this->GetByteOrderAsString(m_ByteOrder)); otbMsgDebugMacro(<< " File byte order : " << this->GetByteOrderAsString(m_FileByteOrder)); @@ -498,10 +498,10 @@ void ONERAImageIO::Write(const void* buffer) lFirstColumn = 0; } - std::streamsize numberOfBytesPerLines = step * lNbColumns * m_NbOctetPixel; + std::streamsize numberOfBytesPerLines = step * lNbColumns * m_BytePerPixel; std::streamoff headerLength = ONERA_HEADER_LENGTH + numberOfBytesPerLines; std::streamoff offset; - unsigned long numberOfBytesRegion = step * m_NbOctetPixel * lNbColumns * lNbLines; + unsigned long numberOfBytesRegion = step * m_BytePerPixel * lNbColumns * lNbLines; char *tempmemory = new char[numberOfBytesRegion]; memcpy(tempmemory, buffer, numberOfBytesRegion); @@ -511,7 +511,7 @@ void ONERAImageIO::Write(const void* buffer) char* value = tempmemory + numberOfBytesPerLines * (LineNo - lFirstLine); offset = headerLength + static_cast<std::streamoff>(numberOfBytesPerLines) * static_cast<std::streamoff>(LineNo); - offset += static_cast<std::streamoff>(m_NbOctetPixel * lFirstColumn); + offset += static_cast<std::streamoff>(m_BytePerPixel * lFirstColumn); m_Datafile.seekp(offset, std::ios::beg); m_Datafile.write(static_cast<char *>(value), numberOfBytesPerLines); } @@ -589,7 +589,7 @@ void ONERAImageIO::WriteImageInformation() otbMsgDebugMacro(<< " Size : " << m_Dimensions[0] << "," << m_Dimensions[1]); otbMsgDebugMacro(<< " ComponentType : " << this->GetComponentType()); otbMsgDebugMacro(<< " NumberOfComponents : " << this->GetNumberOfComponents()); - otbMsgDebugMacro(<< " NbOctetPixel : " << m_NbOctetPixel); + otbMsgDebugMacro(<< " BytePerPixel : " << m_BytePerPixel); otbMsgDebugMacro(<< " Host byte order : " << this->GetByteOrderAsString(m_ByteOrder)); } diff --git a/Code/IO/otbONERAImageIO.h b/Code/IO/otbONERAImageIO.h index 6117699cd36266fe7143c6053e9509f00cbcf0e6..3ed455447053670dea82e6a2a7dcc3a8d9a5a240 100644 --- a/Code/IO/otbONERAImageIO.h +++ b/Code/IO/otbONERAImageIO.h @@ -154,7 +154,7 @@ private: } /** Nombre d'octets par pixel */ - int m_NbOctetPixel; + int m_BytePerPixel; bool m_FlagWriteImageInformation; /** File byte order */ itk::ImageIOBase::ByteOrder m_FileByteOrder; diff --git a/Code/IO/otbRADImageIO.cxx b/Code/IO/otbRADImageIO.cxx index a9fbc936e7a506fecc6c724d884d3ef3a6d60fb0..cd7184e33cda56a8affcebc9bc48e20342e08d12 100644 --- a/Code/IO/otbRADImageIO.cxx +++ b/Code/IO/otbRADImageIO.cxx @@ -39,7 +39,7 @@ RADImageIO::RADImageIO() // By default the type to CI2 m_TypeRAD = "CR4"; - m_NbOctetPixel = 8; + m_BytePerPixel = 8; m_NbOfChannels = 1; this->SetNumberOfComponents(2); m_PixelType = COMPLEX; @@ -150,8 +150,8 @@ void RADImageIO::Read(void* buffer) std::streamoff headerLength(0); std::streamoff offset; - std::streamoff numberOfBytesPerLines = static_cast<std::streamoff>(m_NbOctetPixel * m_Dimensions[0]); - std::streamsize numberOfBytesToBeRead = m_NbOctetPixel * lNbColumns; + std::streamoff numberOfBytesPerLines = static_cast<std::streamoff>(m_BytePerPixel * m_Dimensions[0]); + std::streamsize numberOfBytesToBeRead = m_BytePerPixel * lNbColumns; std::streamsize numberOfBytesRead; unsigned long cpt = 0; @@ -174,12 +174,12 @@ void RADImageIO::Read(void* buffer) for (unsigned int numChannel = 0; numChannel < m_NbOfChannels; ++numChannel) { - cpt = (unsigned long) (numChannel) * (unsigned long) (m_NbOctetPixel); + cpt = (unsigned long) (numChannel) * (unsigned long) (m_BytePerPixel); //Read region of the channel for (int LineNo = lFirstLine; LineNo < lFirstLine + lNbLines; LineNo++) { offset = headerLength + numberOfBytesPerLines * static_cast<std::streamoff>(LineNo); - offset += static_cast<std::streamoff>(m_NbOctetPixel * lFirstColumn); + offset += static_cast<std::streamoff>(m_BytePerPixel * lFirstColumn); m_ChannelsFile[numChannel].seekg(offset, std::ios::beg); //Read a line m_ChannelsFile[numChannel].read(static_cast<char *>(value), numberOfBytesToBeRead); @@ -194,9 +194,9 @@ void RADImageIO::Read(void* buffer) { itkExceptionMacro(<< "RADImageIO::Read() Can Read the specified Region"); // read failed } - for (std::streamsize i = 0; i < numberOfBytesToBeRead; i = i + static_cast<std::streamsize>(m_NbOctetPixel)) + for (std::streamsize i = 0; i < numberOfBytesToBeRead; i = i + static_cast<std::streamsize>(m_BytePerPixel)) { - memcpy((void*) (&(p[cpt])), (const void*) (&(value[i])), (size_t) (m_NbOctetPixel)); + memcpy((void*) (&(p[cpt])), (const void*) (&(value[i])), (size_t) (m_BytePerPixel)); cpt += step; } } @@ -327,67 +327,67 @@ bool RADImageIO::InternalReadHeaderInformation(const std::string& file_name, std { m_PixelType = SCALAR; SetComponentType(UCHAR); - m_NbOctetPixel = 1; + m_BytePerPixel = 1; } if (lStrCodePix == "PHA") { m_PixelType = SCALAR; SetComponentType(CHAR); - m_NbOctetPixel = 1; + m_BytePerPixel = 1; } if (lStrCodePix == "I2") { m_PixelType = SCALAR; SetComponentType(SHORT); - m_NbOctetPixel = 2; + m_BytePerPixel = 2; } if (lStrCodePix == "I4") { m_PixelType = SCALAR; SetComponentType(INT); - m_NbOctetPixel = 4; + m_BytePerPixel = 4; } if (lStrCodePix == "R4") { m_PixelType = SCALAR; SetComponentType(FLOAT); - m_NbOctetPixel = 4; + m_BytePerPixel = 4; } else if (lStrCodePix == "CI2") { m_PixelType = COMPLEX; SetComponentType(SHORT); - m_NbOctetPixel = 4; + m_BytePerPixel = 4; } else if (lStrCodePix == "CR4") { m_PixelType = COMPLEX; SetComponentType(FLOAT); - m_NbOctetPixel = 8; + m_BytePerPixel = 8; } else if (lStrCodePix == "COCT") { m_PixelType = COMPLEX; SetComponentType(UCHAR); - m_NbOctetPixel = 2; + m_BytePerPixel = 2; } /* else if(lStrCodePix == "C3B") { m_PixelType = COMPLEX; SetComponentType(FLOAT); - m_NbOctetPixel=2; + m_BytePerPixel=2; } else if(lStrCodePix == "C5B") { m_PixelType = COMPLEX; SetComponentType(FLOAT); - m_NbOctetPixel=2; + m_BytePerPixel=2; } else if(lStrCodePix == "C7B") { m_PixelType = COMPLEX; SetComponentType(FLOAT); - m_NbOctetPixel=2; + m_BytePerPixel=2; } */ @@ -395,13 +395,13 @@ bool RADImageIO::InternalReadHeaderInformation(const std::string& file_name, std { m_PixelType = COMPLEX; SetComponentType(INT); - m_NbOctetPixel = 8; + m_BytePerPixel = 8; } else if (lStrCodePix == "CR8") { m_PixelType = COMPLEX; SetComponentType(DOUBLE); - m_NbOctetPixel = 16; + m_BytePerPixel = 16; } else { @@ -533,14 +533,14 @@ void RADImageIO::Write(const void* buffer) otbMsgDevMacro(<< " GetComponentSize : " << this->GetComponentSize()); std::streamoff headerLength(0); - std::streamoff numberOfBytesPerLines = static_cast<std::streamoff>(m_NbOctetPixel * m_Dimensions[0]); - std::streamsize numberOfBytesToBeWrite = static_cast<std::streamsize>(m_NbOctetPixel * lNbColumns); + std::streamoff numberOfBytesPerLines = static_cast<std::streamoff>(m_BytePerPixel * m_Dimensions[0]); + std::streamsize numberOfBytesToBeWrite = static_cast<std::streamsize>(m_BytePerPixel * lNbColumns); std::streamoff offset = 0; unsigned long cpt = 0; // Update the step variable - step = m_NbOctetPixel; + step = m_BytePerPixel; const char * p = static_cast<const char *>(buffer); @@ -553,18 +553,18 @@ void RADImageIO::Write(const void* buffer) for (unsigned int numChannel = 0; numChannel < m_NbOfChannels; ++numChannel) { - cpt = (unsigned long) (numChannel) * (unsigned long) (m_NbOctetPixel); + cpt = (unsigned long) (numChannel) * (unsigned long) (m_BytePerPixel); //Read region of the channel for (unsigned int LineNo = lFirstLine; LineNo < lFirstLine + lNbLines; LineNo++) { - for (std::streamsize i = 0; i < numberOfBytesToBeWrite; i = i + static_cast<std::streamsize>(m_NbOctetPixel)) + for (std::streamsize i = 0; i < numberOfBytesToBeWrite; i = i + static_cast<std::streamsize>(m_BytePerPixel)) { - memcpy((void*) (&(value[i])), (const void*) (&(p[cpt])), (size_t) (m_NbOctetPixel)); + memcpy((void*) (&(value[i])), (const void*) (&(p[cpt])), (size_t) (m_BytePerPixel)); cpt += step; } offset = headerLength + numberOfBytesPerLines * static_cast<std::streamoff>(LineNo); - offset += static_cast<std::streamoff>(m_NbOctetPixel * lFirstColumn); + offset += static_cast<std::streamoff>(m_BytePerPixel * lFirstColumn); m_ChannelsFile[numChannel].seekp(offset, std::ios::beg); //Write a line m_ChannelsFile[numChannel].write(static_cast<char *>(value), numberOfBytesToBeWrite); @@ -623,31 +623,31 @@ void RADImageIO::WriteImageInformation() { if (lStringComponentType == "UCHAR") { - m_NbOctetPixel = 1; + m_BytePerPixel = 1; m_TypeRAD = "OCT"; lExtension = ".oct"; } else if (lStringComponentType == "CHAR") { - m_NbOctetPixel = 1; + m_BytePerPixel = 1; m_TypeRAD = "PHA"; lExtension = ".pha"; } else if (lStringComponentType == "SHORT") { - m_NbOctetPixel = 2; + m_BytePerPixel = 2; m_TypeRAD = "I2"; lExtension = ".i2"; } else if (lStringComponentType == "INT") { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; m_TypeRAD = "I4"; lExtension = ".i4"; } else if (lStringComponentType == "FLOAT") { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; m_TypeRAD = "R4"; lExtension = ".r4"; @@ -658,47 +658,47 @@ void RADImageIO::WriteImageInformation() if (lStringComponentType == "SHORT") { - m_NbOctetPixel = 4; + m_BytePerPixel = 4; m_TypeRAD = "CI2"; lExtension = ".ci2"; } else if (lStringComponentType == "FLOAT") { - m_NbOctetPixel = 8; + m_BytePerPixel = 8; m_TypeRAD = "CR4"; lExtension = ".cr4"; } if (lStringComponentType == "CHAR") { - m_NbOctetPixel = 2; + m_BytePerPixel = 2; m_TypeRAD = "COCT"; lExtension = ".coct"; } /* if( this->GetComponentType()=="FLOAT") { - m_NbOctetPixel=2; + m_BytePerPixel=2; m_TypeRAD = "C3B" } if( this->GetComponentType()==FLOAT) { - m_NbOctetPixel=2; + m_BytePerPixel=2; m_TypeRAD = "C5B" } if( this->GetComponentType()==FLOAT) { - m_NbOctetPixel=2; + m_BytePerPixel=2; m_TypeRAD = "C7B" } */ else if (lStringComponentType == "INT") { - m_NbOctetPixel = 8; + m_BytePerPixel = 8; m_TypeRAD = "CI4"; lExtension = ".ci4"; } else if (lStringComponentType == "DOUBLE") { - m_NbOctetPixel = 16; + m_BytePerPixel = 16; m_TypeRAD = "CR8"; lExtension = ".cr8"; } @@ -749,7 +749,7 @@ void RADImageIO::WriteImageInformation() this->SetNumberOfDimensions(2); this->SetNumberOfComponents(2 * m_NbOfChannels); - unsigned long numberOfBytesPerLines = m_NbOctetPixel * m_Dimensions[0]; + unsigned long numberOfBytesPerLines = m_BytePerPixel * m_Dimensions[0]; char* value = new char[numberOfBytesPerLines]; for (unsigned int channels = 0; channels < m_ChannelsFileName.size(); ++channels) diff --git a/Code/IO/otbRADImageIO.h b/Code/IO/otbRADImageIO.h index 45120347f15bed65ebe3b6c2b9adfecee7df10c1..7712784e88f352c65d62a723661138a765ab9f70 100644 --- a/Code/IO/otbRADImageIO.h +++ b/Code/IO/otbRADImageIO.h @@ -155,7 +155,7 @@ private: std::vector<std::string> m_ChannelsFileName; std::fstream * m_ChannelsFile; unsigned int m_NbOfChannels; - int m_NbOctetPixel; + int m_BytePerPixel; }; diff --git a/Code/Testing/otbTestHelper.cxx b/Code/Testing/otbTestHelper.cxx index a9cf30c07e76980b60cd9182eee9f0ccb05e3162..1073d8ae5b961d41203cf4a6ee551494d86b3ad6 100644 --- a/Code/Testing/otbTestHelper.cxx +++ b/Code/Testing/otbTestHelper.cxx @@ -912,7 +912,7 @@ int TestHelper::RegressionTestOgrFile(const char *testOgrFilename, const char *b // If no verbose and an diff was found, exit checking. The full checking will be executed in verbose mode if ((!m_ReportErrors) && (nbdiff != 0)) return (1); } //if(nbdiff == 0) - + } /* -------------------------------------------------------------------- */ @@ -1468,8 +1468,6 @@ void TestHelper::ogrReportOnLayer(OGRLayer * ref_poLayer, /* -------------------------------------------------------------------- */ printf("\n"); - otbCheckStringValue("Layer name", ref_poDefn->GetName(), test_poDefn->GetName(), nbdiff, m_ReportErrors); - otbCheckStringValue("Geometry", OGRGeometryTypeToName(ref_poDefn->GetGeomType()), OGRGeometryTypeToName(test_poDefn->GetGeomType()), nbdiff, m_ReportErrors);