1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
// Copyright (C) 2010 Davis E. King (davis@dlib.net), Nils Labugt
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_JPEG_IMPORT_ABSTRACT
#ifdef DLIB_JPEG_IMPORT_ABSTRACT
#include "image_loader_abstract.h"
#include "../algs.h"
#include "../pixel.h"
#include "../dir_nav.h"
namespace dlib
{
class jpeg_loader : noncopyable
{
/*!
INITIAL VALUE
Defined by the constructors
WHAT THIS OBJECT REPRESENTS
This object represents a class capable of loading JPEG image files.
Once an instance of it is created to contain a JPEG file from
disk you can obtain the image stored in it via get_image().
!*/
public:
jpeg_loader(
const char* filename
);
/*!
ensures
- loads the JPEG file with the given file name into this object
throws
- std::bad_alloc
- image_load_error
This exception is thrown if there is some error that prevents
us from loading the given JPEG file.
!*/
jpeg_loader(
const std::string& filename
);
/*!
ensures
- loads the JPEG file with the given file name into this object
throws
- std::bad_alloc
- image_load_error
This exception is thrown if there is some error that prevents
us from loading the given JPEG file.
!*/
jpeg_loader(
const dlib::file& f
);
/*!
ensures
- loads the JPEG file with the given file name into this object
throws
- std::bad_alloc
- image_load_error
This exception is thrown if there is some error that prevents
us from loading the given JPEG file.
!*/
~jpeg_loader(
);
/*!
ensures
- all resources associated with *this has been released
!*/
bool is_gray(
) const;
/*!
ensures
- if (this object contains a grayscale image) then
- returns true
- else
- returns false
!*/
bool is_rgb(
) const;
/*!
ensures
- if (this object contains a 3 channel RGB image) then
- returns true
- else
- returns false
!*/
template<
typename image_type
>
void get_image(
image_type& img
) const;
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<typename image_type::type> is defined
ensures
- loads the JPEG image stored in this object into img
!*/
};
// ----------------------------------------------------------------------------------------
template <
typename image_type
>
void load_jpeg (
image_type& image,
const std::string& file_name
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<typename image_type::type> is defined
ensures
- performs: jpeg_loader(file_name).get_image(image);
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_JPEG_IMPORT_ABSTRACT
|