Commit c512fb944de14b88ed7a2228ba843aa16f2152a2

Authored by David Mayerich
1 parent 23dbe234

fixed file series loading error in stim::gl_texture

Showing 2 changed files with 17 additions and 7 deletions   Show diff stats
stim/gl/gl_texture.h
... ... @@ -192,6 +192,12 @@ class gl_texture : public virtual image_stack<T, F>
192 192 }
193 193 CHECK_OPENGL_ERROR
194 194 }
  195 + void guess_parameters(){
  196 + setTextureType(); //set the texture type: 1D, 2D, 3D
  197 + format = guess_format(); //guess the texture format based on the number of image channels
  198 + cpu_type = guess_cpu_type(); //guess the CPU type based on the template
  199 + gpu_type = guess_gpu_type(); //guess the GPU type based on the format and template
  200 + }
195 201  
196 202 public:
197 203  
... ... @@ -253,16 +259,20 @@ class gl_texture : public virtual image_stack<T, F>
253 259 vec<float> getDims(){
254 260 vec<float> dims(grid<T, 4, F>::S[1], grid<T, 4, F>::S[2], grid<T, 4, F>::S[3]);
255 261 return dims;
256   - }
  262 + }
  263 +
  264 + /// Loads a series of files specified by a list of strings
  265 + /// @param file_list is the vector of file names as strings
  266 + void load_images(std::vector<std::string> file_list){
  267 + image_stack<T, F>::load_images(file_list); //load the images
  268 + guess_parameters();
  269 + }
257 270  
258 271 ///@param file_mask specifies the file(s) to be loaded
259 272 /// Sets the path and calls the loader on that path.
260   - void load(std::string file_mask){
  273 + void load_images(std::string file_mask){
261 274 image_stack<T>::load_images(file_mask); //load images
262   - setTextureType(); //set the texture type: 1D, 2D, 3D
263   - format = guess_format(); //guess the texture format based on the number of image channels
264   - cpu_type = guess_cpu_type(); //guess the CPU type based on the template
265   - gpu_type = guess_gpu_type(); //guess the GPU type based on the format and template
  275 + guess_parameters();
266 276 }
267 277  
268 278 /// Returns the GLuint id of the texture created by/associated with the
... ...
stim/grids/image_stack.h
... ... @@ -80,7 +80,7 @@ public:
80 80 R[2] = I.height();
81 81 R[3] = string_list.size(); //set the stack z-resolution based on the number of images
82 82  
83   - ptr = (T*)malloc(sizeof(T) * samples()); //allocate storage space
  83 + ptr = (T*)malloc(bytes()); //allocate storage space
84 84  
85 85 //load and copy each image into the grid
86 86 for(unsigned int i = 0; i<R[3]; i++){ //for each image in the list
... ...