Commit bb5e847b authored by Davis King's avatar Davis King

Made image saving routines work on matrix objects in addition to array2d

objects.
parent 13b8c5f3
......@@ -17,6 +17,8 @@
#include "../dir_nav.h"
#include "../float_details.h"
#include "../vectorstream.h"
#include "../matrix/matrix_exp.h"
#include "../image_transforms/assign_image.h"
namespace dlib
{
......@@ -229,7 +231,7 @@ namespace dlib
template <
typename image_type
>
inline void save_bmp (
inline typename disable_if<is_matrix<image_type> >::type save_bmp (
const image_type& image,
std::ostream& out
)
......@@ -237,6 +239,19 @@ namespace dlib
save_bmp_helper<image_type>::save_bmp(image,out);
}
template <
typename EXP
>
inline void save_bmp (
const matrix_exp<EXP>& image,
std::ostream& out
)
{
array2d<typename EXP::type> temp;
assign_image(temp, image);
save_bmp_helper<array2d<typename EXP::type> >::save_bmp(temp,out);
}
// ----------------------------------------------------------------------------------------
namespace dng_helpers_namespace
......@@ -578,7 +593,7 @@ namespace dlib
template <
typename image_type
>
inline void save_dng (
inline typename disable_if<is_matrix<image_type> >::type save_dng (
const image_type& image,
std::ostream& out
)
......@@ -587,6 +602,20 @@ namespace dlib
save_dng_helper<image_type>::save_dng(image,out);
}
template <
typename EXP
>
inline void save_dng (
const matrix_exp<EXP>& image,
std::ostream& out
)
{
array2d<typename EXP::type> temp;
assign_image(temp, image);
using namespace dng_helpers_namespace;
save_dng_helper<array2d<typename EXP::type> >::save_dng(temp,out);
}
// ----------------------------------------------------------------------------------------
template <typename image_type>
......
......@@ -29,7 +29,8 @@ namespace dlib
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
ensures
- writes the image to the out stream in the Microsoft Windows BMP format.
......@@ -57,7 +58,8 @@ namespace dlib
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
ensures
- opens the file indicated by file_name with an output file stream named fout
......@@ -83,7 +85,8 @@ namespace dlib
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
ensures
- writes the image to the out stream in the dlib dng format.
......@@ -111,7 +114,8 @@ namespace dlib
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
ensures
- opens the file indicated by file_name with an output file stream named fout
......
......@@ -9,6 +9,8 @@
#include <vector>
#include <string>
#include "../pixel.h"
#include "../matrix/matrix_exp.h"
#include "../image_transforms/assign_image.h"
namespace dlib
{
......@@ -38,7 +40,7 @@ namespace dlib
template <
typename image_type
>
void save_png(
typename disable_if<is_matrix<image_type> >::type save_png(
const image_type& img,
const std::string& file_name
)
......@@ -130,6 +132,24 @@ namespace dlib
#endif
}
// ----------------------------------------------------------------------------------------
template <
typename EXP
>
void save_png(
const matrix_exp<EXP>& img,
const std::string& file_name
)
{
array2d<typename EXP::type> temp;
assign_image(temp, img);
save_png(temp, file_name);
}
// ----------------------------------------------------------------------------------------
}
#ifdef NO_MAKEFILE
......
......@@ -19,7 +19,8 @@ namespace dlib
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h or
a dlib::matrix
- pixel_traits<typename image_type::type> is defined
- image.size() != 0
ensures
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment