Commit 51f944854fa00fe6d2da8feb83edb5e793daa582
1 parent
c7da85e3
Ziqi added saveZ, saveXY
Showing
1 changed file
with
7 additions
and
2 deletions
Show diff stats
envi/binary.h
... | ... | @@ -99,11 +99,17 @@ public: |
99 | 99 | return p; |
100 | 100 | } |
101 | 101 | |
102 | - T * saveXY(int x, int y){ | |
102 | + T * saveXY(unsigned x, unsigned y){ | |
103 | 103 | |
104 | 104 | T * px; |
105 | 105 | unsigned int i; |
106 | 106 | |
107 | + if (x<1||x>R[0]||y<1||y>R[1]){ //make sure the sample and line number is right | |
108 | + cout<<"wrong page"; | |
109 | + getchar(); | |
110 | + return NULL; | |
111 | + } | |
112 | + | |
107 | 113 | px=(T *)malloc(R[2]*sizeof(T)); //memory allocation |
108 | 114 | if (px==NULL) |
109 | 115 | cout<<"memory allocation failure"; |
... | ... | @@ -116,7 +122,6 @@ public: |
116 | 122 | { |
117 | 123 | file.read((char *)(px+i), sizeof(T)); |
118 | 124 | file.seekg((R[1]*R[0]-1)*sizeof(T),ios::cur); //go to the next band |
119 | - px[i]; | |
120 | 125 | } |
121 | 126 | |
122 | 127 | return px; | ... | ... |