00001 //: 00002 // \file 00003 // \brief Functions to read an image from a file 00004 // \author Ian Scott 00005 00006 #include "vil3d_load.h" 00007 #include <vil3d/vil3d_file_format.h> 00008 00009 00010 vil3d_image_resource_sptr vil3d_load_image_resource(char const* filename) 00011 { 00012 for (unsigned i=0;i<vil3d_file_format::n_formats();++i) 00013 { 00014 vil3d_image_resource_sptr im = 00015 vil3d_file_format::format(i).make_input_image(filename); 00016 if (im) return im; 00017 } 00018 vcl_cerr << "WARNING vil3d_load unable to load " << filename << 00019 "\n Tried "; 00020 for (unsigned i=0;i<vil3d_file_format::n_formats();++i) 00021 vcl_cerr << vil3d_file_format::format(i).tag() << ' '; 00022 vcl_cerr << vcl_endl; 00023 return 0; 00024 } 00025 00026 00027 //: Convenience function for loading an image into an image view. 00028 vil3d_image_view_base_sptr vil3d_load(const char *file) 00029 { 00030 vil3d_image_resource_sptr data = vil3d_load_image_resource(file); 00031 if (!data) return 0; 00032 return data -> get_view(0, data->ni(), 0, data->nj(), 0, data->nk()); 00033 }
1.5.1