Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
d3a73bdb
Commit
d3a73bdb
authored
May 27, 2011
by
Davis King
Browse files
Added the load_image() function which just looks at a file's extension and
then calls the appropriate image loading function.
parent
beee293d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
0 deletions
+91
-0
dlib/image_io.h
dlib/image_io.h
+1
-0
dlib/image_loader/load_image.h
dlib/image_loader/load_image.h
+47
-0
dlib/image_loader/load_image_abstract.h
dlib/image_loader/load_image_abstract.h
+43
-0
No files found.
dlib/image_io.h
View file @
d3a73bdb
...
...
@@ -6,6 +6,7 @@
#include "image_loader/image_loader.h"
#include "image_loader/png_loader.h"
#include "image_loader/jpeg_loader.h"
#include "image_loader/load_image.h"
#include "image_saver/image_saver.h"
#include "image_saver/save_png.h"
...
...
dlib/image_loader/load_image.h
0 → 100644
View file @
d3a73bdb
// Copyright (C) 2011 Davis E. King (davis@dlib.net), Nils Labugt
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_LOAd_IMAGE_H__
#define DLIB_LOAd_IMAGE_H__
#include "load_image_abstract.h"
#include "../string.h"
#include "png_loader.h"
#include "jpeg_loader.h"
#include "image_loader.h"
namespace
dlib
{
template
<
typename
image_type
>
void
load_image
(
image_type
&
image
,
const
std
::
string
&
file_name
)
{
const
std
::
string
extension
=
tolower
(
right_substr
(
file_name
,
"."
));
if
(
extension
==
"bmp"
)
load_bmp
(
image
,
file_name
);
#ifdef DLIB_PNG_SUPPORT
else
if
(
extension
==
"png"
)
load_png
(
image
,
file_name
);
#endif
#ifdef DLIB_JPEG_SUPPORT
else
if
(
extension
==
"jpeg"
||
extension
==
"jpg"
)
load_jpeg
(
image
,
file_name
);
#endif
else
if
(
extension
==
"dng"
)
load_dng
(
image
,
file_name
);
else
{
if
(
extension
==
"jpeg"
||
extension
==
"jpg"
)
throw
image_load_error
(
"DLIB_JPEG_SUPPORT not #defined: Unable to load image in file "
+
file_name
);
else
if
(
extension
==
"png"
)
throw
image_load_error
(
"DLIB_PNG_SUPPORT not #defined: Unable to load image in file "
+
file_name
);
else
throw
image_load_error
(
"Unknown file extension: Unable to load image in file "
+
file_name
);
}
}
}
#endif // DLIB_LOAd_IMAGE_H__
dlib/image_loader/load_image_abstract.h
0 → 100644
View file @
d3a73bdb
// Copyright (C) 2011 Davis E. King (davis@dlib.net), Nils Labugt
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_LOAd_IMAGE_ABSTRACT_
#ifdef DLIB_LOAd_IMAGE_ABSTRACT_
#include "load_image_abstract.h"
#include "../string.h"
namespace
dlib
{
template
<
typename
image_type
>
void
load_image
(
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
- let EXT == the extension of the file given by file_name converted
to lower case (i.e. the part of the file after the '.')
- if (EXT == "png") then
- performs: load_png(image, file_name);
- else if (EXT == "jpg" || EXT == "jpeg") then
- performs: load_jpeg(image, file_name);
- else if (EXT == "bmp") then
- performs: load_bmp(image, file_name);
- else if (EXT == "dng") then
- performs: load_dng(image, file_name);
- else
- throws image_load_error
throws
- image_load_error
This exception is thrown if there is some error that prevents
us from loading the given image file.
!*/
}
#endif // DLIB_LOAd_IMAGE_ABSTRACT_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment