17 # include <vcl_msvc_warnings.h> 19 #include <vxl_config.h> 33 if (!os || !os->
ok()) {
34 std::cerr << __FILE__
": Invalid stream for \"" << filename <<
"\"\n";
41 std::cerr << __FILE__
": (vil_save) Cannot save to type [" << file_format <<
"]\n";
60 case VIL_PIXEL_FORMAT_UINT_64:
62 case VIL_PIXEL_FORMAT_INT_64:
75 return out->put_view(im, 0, 0);
82 char const *file_format =
"pnm";
85 char const *
dot = std::strrchr(filename,
'.');
88 std::cerr << __FILE__
": assuming pnm format for \'" << filename <<
"\'\n";
92 std::string ext_lower_case(
dot);
93 for (
char & i : ext_lower_case)
94 i = (char)std::tolower(i);
97 #define macro(ext, fmt) else if ( ext_lower_case == "." #ext ) file_format = #fmt 116 std::cerr << __FILE__
": assuming pnm format for \'" << filename <<
"\'\n";
130 char const* file_format)
133 if (!os || !os->
ok()) {
134 std::cerr << __FILE__
": Invalid stream for \"" << filename <<
"\"\n";
139 ir->pixel_format(), file_format);
141 std::cerr << __FILE__
": (vil_save) Cannot save to type [" << file_format <<
"]\n";
155 #if defined(_WIN32) && VXL_USE_WIN_WCHAR_T 166 if (!os || !os->
ok()) {
167 std::wcerr << __FILE__
": Invalid stream for \"" << filename <<
"\"\n";
174 std::wcerr << __FILE__
": (vil_save) Cannot save to type [" << file_format <<
"]\n";
193 case VIL_PIXEL_FORMAT_UINT_64:
195 case VIL_PIXEL_FORMAT_INT_64:
208 return out->put_view(im, 0, 0);
215 wchar_t const *file_format = L
"pnm";
218 wchar_t const *
dot = wcsrchr(filename, L
'.');
221 std::wcerr << __FILE__
": assuming pnm format for \'" << filename <<
"\'\n";
222 file_format = L
"pnm";
225 std::wstring ext_lower_case(dot);
226 for(
unsigned int i=0; i<ext_lower_case.size(); ++i)
227 ext_lower_case[i] = towlower(ext_lower_case[i]);
230 #define macro(ext, fmt) else if ( ext_lower_case == L"." L#ext ) file_format = L#fmt 248 std::wcerr << __FILE__
": assuming pnm format for \'" << filename <<
"\'\n";
262 wchar_t const* file_format)
265 if (!os || !os->
ok()) {
266 std::wcerr << __FILE__
": Invalid stream for \"" << filename <<
"\"\n";
271 ir->pixel_format(), file_format);
273 std::wcerr << __FILE__
": (vil_save) Cannot save to type [" << file_format <<
"]\n";
285 #endif //defined(_WIN32) && VXL_USE_WIN_WCHAR_T bool vil_save_image_resource(const vil_image_resource_sptr &ir, char const *filename, char const *file_format)
Send vil_image_resource to disk.
An abstract base class of smart pointers to actual image data in memory.
Concrete view of image data of type T held in memory.
vil_image_resource_sptr vil_new_image_resource(unsigned ni, unsigned nj, unsigned nplanes, vil_pixel_format format)
Make a new image of given format.
char const * vil_save_guess_file_format(char const *filename)
Given a filename, guess the file format tag.
unsigned ni() const
Width.
Stream interface for VIL image loaders.
unsigned nj() const
Height.
virtual enum vil_pixel_format pixel_format() const =0
Return a description of the concrete data pixel type.
double dot(const double *v1, const double *v2, unsigned n)
Various image copying functions.
A base class reference-counting view of some image data.
virtual bool ok() const =0
Return false if the stream is broken.
unsigned nplanes() const
Number of planes.
make a vil_stream from a filename, an URL, etc.
bool vil_save(const vil_image_view_base &, char const *filename)
Send a vil_image_view to disk, deducing format from filename.
Representation of a generic image source or destination.
bool vil_copy_deep(const vil_image_resource_sptr &src, vil_image_resource_sptr &dest)
Copy src to dest.
vil_stream * vil_open(char const *what, char const *how="r")
make a vil_stream from a filename, an URL, etc.