Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.io.image
Commits
3899a9f4
Commit
3899a9f4
authored
May 23, 2016
by
Manuel Günther
Browse files
Updated versioning and added config.h
parent
1d3ec770
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/io/image/include/bob.io.image/config.h
0 → 100644
View file @
3899a9f4
/**
* @author Manuel Gunther <siebenkopf@googlemail.com>
* @date Mon May 23 09:58:35 MDT 2016
*
* @brief General directives for all modules in bob.io.image
*/
#ifndef BOB_IO_IMAGE_CONFIG_H
#define BOB_IO_IMAGE_CONFIG_H
/* Macros that define versions and important names */
#define BOB_IO_IMAGE_API_VERSION 0x0200
#ifdef BOB_IMPORT_VERSION
/***************************************
* Here we define some functions that should be used to build version dictionaries in the version.cpp file
* There will be a compiler warning, when these functions are not used, so use them!
***************************************/
#include
<Python.h>
#include
<boost/preprocessor/stringize.hpp>
#ifdef HAVE_LIBJPEG
#include
<jpeglib.h>
#endif
#ifdef HAVE_LIBPNG
#define PNG_SKIP_SETJMP_CHECK
// #define requires because of the problematic pngconf.h.
// Look at the thread here:
// https://bugs.launchpad.net/ubuntu/+source/libpng/+bug/218409
#include
<png.h>
#endif
#ifdef HAVE_GIFLIB
#include
<gif_lib.h>
#endif
#ifdef HAVE_LIBTIFF
#include
<tiffio.h>
#endif
/**
* LibJPEG version
*/
#ifdef HAVE_LIBJPEG
static
PyObject
*
libjpeg_version
()
{
boost
::
format
f
(
"%d (compiled with %d bits depth)"
);
f
%
LIBJPEG_VERSION
%
BITS_IN_JSAMPLE
;
return
Py_BuildValue
(
"s"
,
f
.
str
().
c_str
());
}
#endif
/**
* Libpng version
*/
#ifdef HAVE_LIBPNG
static
PyObject
*
libpng_version
()
{
return
Py_BuildValue
(
"s"
,
PNG_LIBPNG_VER_STRING
);
}
#endif
/**
* Libtiff version
*/
#ifdef HAVE_LIBTIFF
static
PyObject
*
libtiff_version
()
{
static
const
std
::
string
beg_str
(
"LIBTIFF, Version "
);
static
const
size_t
beg_len
=
beg_str
.
size
();
std
::
string
vtiff
(
TIFFGetVersion
());
// Remove first part if it starts with "LIBTIFF, Version "
if
(
vtiff
.
compare
(
0
,
beg_len
,
beg_str
)
==
0
)
vtiff
=
vtiff
.
substr
(
beg_len
);
// Remove multiple (copyright) lines if any
size_t
end_line
=
vtiff
.
find
(
"
\n
"
);
if
(
end_line
!=
std
::
string
::
npos
)
vtiff
=
vtiff
.
substr
(
0
,
end_line
);
return
Py_BuildValue
(
"s"
,
vtiff
.
c_str
());
}
#endif
/**
* Version of giflib support
*/
#ifdef HAVE_GIFLIB
static
PyObject
*
giflib_version
()
{
#ifdef GIF_LIB_VERSION
return
Py_BuildValue
(
"s"
,
GIF_LIB_VERSION
);
#else
boost
::
format
f
(
"%s.%s.%s"
);
f
%
BOOST_PP_STRINGIZE
(
GIFLIB_MAJOR
)
%
BOOST_PP_STRINGIZE
(
GIFLIB_MINOR
)
%
BOOST_PP_STRINGIZE
(
GIFLIB_RELEASE
);
return
Py_BuildValue
(
"s"
,
f
.
str
().
c_str
());
#endif
}
#endif
/**
* bob.io.image c/c++ api version
*/
static
PyObject
*
bob_io_image_version
()
{
return
Py_BuildValue
(
"{ss}"
,
"api"
,
BOOST_PP_STRINGIZE
(
BOB_IO_IMAGE_API_VERSION
));
}
#endif // BOB_IMPORT_VERSION
#endif
/* BOB_IO_IMAGE_CONFIG_H */
bob/io/image/version.cpp
View file @
3899a9f4
/**
* @author Andre Anjos <andre.anjos@idiap.ch>
* @author Manuel Gunther <siebenkopf@googlemail.com>
* @date Wed 14 May 14:00:33 2014 CEST
*
* @brief Binds configuration information available from bob
...
...
@@ -10,81 +11,28 @@
#include
<bob.blitz/cleanup.h>
#include
<bob.core/config.h>
#include
<bob.io.base/config.h>
#include
<bob.io.image/config.h>
#include
<boost/preprocessor/stringize.hpp>
extern
"C"
{
#include
<jpeglib.h>
#define PNG_SKIP_SETJMP_CHECK
// #define requires because of the problematic pngconf.h.
// Look at the thread here:
// https://bugs.launchpad.net/ubuntu/+source/libpng/+bug/218409
#include
<png.h>
#include
<gif_lib.h>
#include
<tiffio.h>
}
/**
* LibJPEG version
*/
static
PyObject
*
libjpeg_version
()
{
boost
::
format
f
(
"%d (compiled with %d bits depth)"
);
f
%
LIBJPEG_VERSION
%
BITS_IN_JSAMPLE
;
return
Py_BuildValue
(
"s"
,
f
.
str
().
c_str
());
}
/**
* Libpng version
*/
static
PyObject
*
libpng_version
()
{
return
Py_BuildValue
(
"s"
,
PNG_LIBPNG_VER_STRING
);
}
/**
* Libtiff version
*/
static
PyObject
*
libtiff_version
()
{
static
const
std
::
string
beg_str
(
"LIBTIFF, Version "
);
static
const
size_t
beg_len
=
beg_str
.
size
();
std
::
string
vtiff
(
TIFFGetVersion
());
// Remove first part if it starts with "LIBTIFF, Version "
if
(
vtiff
.
compare
(
0
,
beg_len
,
beg_str
)
==
0
)
vtiff
=
vtiff
.
substr
(
beg_len
);
// Remove multiple (copyright) lines if any
size_t
end_line
=
vtiff
.
find
(
"
\n
"
);
if
(
end_line
!=
std
::
string
::
npos
)
vtiff
=
vtiff
.
substr
(
0
,
end_line
);
return
Py_BuildValue
(
"s"
,
vtiff
.
c_str
());
}
/**
* Version of giflib support
*/
static
PyObject
*
giflib_version
()
{
#ifdef GIF_LIB_VERSION
return
Py_BuildValue
(
"s"
,
GIF_LIB_VERSION
);
#else
boost
::
format
f
(
"%s.%s.%s"
);
f
%
BOOST_PP_STRINGIZE
(
GIFLIB_MAJOR
)
%
BOOST_PP_STRINGIZE
(
GIFLIB_MINOR
)
%
BOOST_PP_STRINGIZE
(
GIFLIB_RELEASE
);
return
Py_BuildValue
(
"s"
,
f
.
str
().
c_str
());
#endif
}
static
PyObject
*
build_version_dictionary
()
{
PyObject
*
retval
=
PyDict_New
();
if
(
!
retval
)
return
0
;
auto
retval_
=
make_safe
(
retval
);
#ifdef HAVE_LIBJPEG
if
(
!
dict_steal
(
retval
,
"libjpeg"
,
libjpeg_version
()))
return
0
;
#endif
#ifdef HAVE_LIBPNG
if
(
!
dict_steal
(
retval
,
"libpng"
,
libpng_version
()))
return
0
;
#endif
#ifdef HAVE_LIBTIFF
if
(
!
dict_steal
(
retval
,
"libtiff"
,
libtiff_version
()))
return
0
;
#endif
#ifdef HAVE_GIFLIB
if
(
!
dict_steal
(
retval
,
"giflib"
,
giflib_version
()))
return
0
;
#endif
if
(
!
dict_steal
(
retval
,
"HDF5"
,
hdf5_version
()))
return
0
;
if
(
!
dict_steal
(
retval
,
"Boost"
,
boost_version
()))
return
0
;
if
(
!
dict_steal
(
retval
,
"Compiler"
,
compiler_version
()))
return
0
;
...
...
@@ -130,9 +78,13 @@ static PyObject* create_module (void) {
if
(
!
m
)
return
0
;
/* register version numbers and constants */
if
(
PyModule_AddIntConstant
(
m
,
"api"
,
BOB_IO_IMAGE_API_VERSION
)
<
0
)
return
0
;
if
(
PyModule_AddStringConstant
(
m
,
"module"
,
BOB_EXT_MODULE_VERSION
)
<
0
)
return
0
;
if
(
PyModule_AddObject
(
m
,
"externals"
,
build_version_dictionary
())
<
0
)
return
0
;
// call bob_io_image_version once to avoid compiler warning
auto
_
=
make_safe
(
bob_io_image_version
());
return
Py_BuildValue
(
ret
,
m
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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