Skip to content

Commit 728fc56

Browse files
committed
MMVII: refactor Read Generic Image
1 parent b712d4d commit 728fc56

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

MMVII/src/ImagesBase/BaseImage.cpp

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,34 @@ template <const int Dim> cDataGenUnTypedIm<Dim>::cDataGenUnTypedIm
2121
}
2222

2323

24-
template <class Type> cDataGenUnTypedIm<2> * Tpl_ReadIm2DGen(const std::string &aName,const cBox2di & aBox)
24+
template <class Type> cDataGenUnTypedIm<2> * Tpl_ReadIm2DGen(const cDataFileIm2D &aDFI,const cBox2di & aBox)
2525
{
26-
27-
cDataFileIm2D aDFI = cDataFileIm2D::Create(aName,eForceGray::Yes);
2826
cDataIm2D<Type> * aDIm = new cDataIm2D<Type>(cPt2di(0,0),aBox.Sz());
2927
aDIm->Read(aDFI,aBox.P0());
30-
3128
return aDIm;
3229
}
3330

3431
cDataGenUnTypedIm<2> * ReadIm2DGen(const std::string &aName,cBox2di aBox)
3532
{
36-
cGdalApi::InitGDAL();
37-
eTyNums aType;
38-
cPt2di aSz;
39-
int aNbChannel;
40-
cGdalApi::GetFileInfo(aName, aType, aSz, aNbChannel);
33+
cDataFileIm2D aDFI = cDataFileIm2D::Create(aName,eForceGray::Yes);
4134

4235
if (aBox.IsEmpty())
43-
aBox = cBox2di(cPt2di(0,0),aSz);
44-
45-
switch (aType) {
46-
case eTyNums::eTN_U_INT1 : return Tpl_ReadIm2DGen<tU_INT1>(aName,aBox);
47-
case eTyNums::eTN_U_INT2 : return Tpl_ReadIm2DGen<tU_INT2>(aName,aBox);
48-
case eTyNums::eTN_INT1 : return Tpl_ReadIm2DGen<tINT1>(aName,aBox);
49-
case eTyNums::eTN_INT2 : return Tpl_ReadIm2DGen<tINT2>(aName,aBox);
50-
case eTyNums::eTN_INT4 : return Tpl_ReadIm2DGen<tINT4>(aName,aBox);
51-
52-
53-
case eTyNums::eTN_REAL4 : return Tpl_ReadIm2DGen<tREAL4>(aName,aBox);
54-
55-
56-
36+
aBox = cBox2di(cPt2di(0,0),aDFI.Sz());
37+
38+
switch (aDFI.Type()) {
39+
case eTyNums::eTN_U_INT1 : return Tpl_ReadIm2DGen<tU_INT1>(aDFI,aBox);
40+
case eTyNums::eTN_U_INT2 : return Tpl_ReadIm2DGen<tU_INT2>(aDFI,aBox);
41+
case eTyNums::eTN_INT1 : return Tpl_ReadIm2DGen<tINT1>(aDFI,aBox);
42+
case eTyNums::eTN_INT2 : return Tpl_ReadIm2DGen<tINT2>(aDFI,aBox);
43+
case eTyNums::eTN_INT4 : return Tpl_ReadIm2DGen<tINT4>(aDFI,aBox);
44+
case eTyNums::eTN_REAL4 : return Tpl_ReadIm2DGen<tREAL4>(aDFI,aBox);
5745
default :
5846
MMVII_INTERNAL_ERROR("Unhandled type in ReadIm2DGen");
5947
return nullptr;
6048
}
6149

6250
MMVII_INTERNAL_ERROR("Unhandled type in ReadIm2DGen");
6351
return nullptr;
64-
/*
65-
cDataIm2D<Type>::Read(const cDataFileIm2D & aFile,const cPt2di & aP0,double aDyn,const cPixBox<2>& aR2);
66-
cGdalApi::ReadWrite(cGdalApi::IoMode::Read, *this, aFile, aP0, aDyn, aR2);
67-
*/
6852
}
6953

7054
cDataGenUnTypedIm<2> * ReadIm2DGen(const std::string &aName)

0 commit comments

Comments
 (0)