Skip to content
Snippets Groups Projects
Commit fde01333 authored by Marco Biasini's avatar Marco Biasini
Browse files

made PNG/TIFF optional

parent ece28e5f
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,8 @@ option(USE_MESA "use software rendered Mesa instead of hardware GL"
OFF)
option(ENABLE_IMG "whether the image processing module should be compiled"
ON)
option(ENABLE_PNG_TIFF "whether the img module should compiled with PNG/TIFF support"
ON)
option(ENABLE_INFO "whether openstructure should be compiled with support for the info library"
ON)
option(USE_NUMPY "whether numpy support is added"
......@@ -88,6 +90,10 @@ else()
set(_DOUBLE_PREC OFF)
endif()
if (NOT ENABLE_TIFF_PNG)
set(ENABLE_GFX OFF)
endif()
if (NOT ENABLE_INFO)
set(ENABLE_GFX OFF)
endif()
......@@ -199,7 +205,9 @@ if (ENABLE_GFX)
endif()
if (ENABLE_IMG OR ENABLE_GFX)
find_package(PNG REQUIRED)
if (ENABLE_TIFF_PNG)
find_package(PNG REQUIRED)
endif()
else()
set (PNG_LIBRARY "")
endif()
......@@ -213,8 +221,10 @@ endif()
if (ENABLE_IMG)
find_package(FFTW REQUIRED)
if (ENABLE_TIFF_PNG)
find_package(TIFF REQUIRED)
endif()
endif()
if (ENABLE_STATIC)
......
......@@ -32,6 +32,13 @@ if (PROFILE)
else()
set(profiling_enabled 0)
endif()
if (ENABLE_TIFF_PNG)
set(tiff_enabled 1)
set(png_enabled 1)
else()
set(tiff_enabled 0)
set(png_enabled 0)
endif()
if (ENABLE_IMG)
set(img_enabled 1)
else()
......
......@@ -28,6 +28,8 @@
#define OST_PROFILING_ENABLED @profiling_enabled@
#define OST_ANIMATIONS_ENABLED @animations_enabled@
#define OST_IMG_ENABLED @img_enabled@
#define OST_PNG_ENABLED @png_enabled@
#define OST_TIFF_ENABLED @tiff_enabled@
#define OST_DOUBLE_PRECISION @double_prec@
#define OST_STATIC_PROPERTY_WORKAROUND @static_props@
#define OST_FFT_USE_THREADS @fftw_use_threads@
......
......@@ -23,10 +23,14 @@
#include <ost/io/img/map_io_mrc_handler.hh>
#include <ost/io/img/map_io_dm3_handler.hh>
#include <ost/io/img/map_io_situs_handler.hh>
#if OST_TIFF_ENABLED
#include <ost/io/img/map_io_tiff_handler.hh>
#include <ost/io/img/map_io_jpk_handler.hh>
#endif
#if OST_PNG_ENABLED
#include <ost/io/img/map_io_png_handler.hh>
#endif
#include <ost/io/img/map_io_dat_handler.hh>
#include <ost/io/img/map_io_jpk_handler.hh>
#include <ost/io/img/map_io_nanoscope_handler.hh>
#include <ost/io/img/map_io_ipl_handler.hh>
#include <ost/io/img/image_format.hh>
......@@ -58,10 +62,6 @@ img::ImageHandle load_image2(const String& loc, const ImageFormatBase& formatst
void export_map_io()
{
class_<boost::logic::tribool>("tribool", init<boost::logic::tribool>())
.def(init<bool>())
;
implicitly_convertible<bool,boost::logic::tribool>();
enum_<Endianess>("Endianess")
.value("OST_BIG_ENDIAN", OST_BIG_ENDIAN)
......@@ -133,7 +133,11 @@ void export_map_io()
.def("SetNormalizeOnSave", &Situs::SetNormalizeOnSave)
.def("GetNormalizeOnSave", &Situs::GetNormalizeOnSave)
;
#if OST_TIFF_ENABLED
class_<boost::logic::tribool>("tribool", init<boost::logic::tribool>())
.def(init<bool>())
;
implicitly_convertible<bool,boost::logic::tribool>();
class_<TIF, bases<ImageFormatBase> >("TIF", init<boost::logic::tribool,Format,bool,bool,int>
((arg("normalize_on_save") = boost::logic::tribool(boost::logic::indeterminate),arg("format")=OST_DEFAULT_FORMAT,arg("signed")=false,arg("phasecolor")=false,arg("subimage") = -1)))
.def("SetNormalizeOnSave", &TIF::SetNormalizeOnSave)
......@@ -149,12 +153,19 @@ void export_map_io()
.def("SetSubimage", &TIF::SetSubimage)
.def("GetSubimage", &TIF::GetSubimage)
;
class_<JPK, bases<TIF> >("JPK", init<boost::logic::tribool,Format,bool,bool,int>
((arg("normalize_on_save") = boost::logic::tribool(boost::logic::indeterminate),arg("format")=OST_DEFAULT_FORMAT,arg("signed")=false,arg("phasecolor")=false,arg("subimage") = -1)))
;
class_<Nanoscope, bases<ImageFormatBase> >("Nanoscope", init <int>(arg("subimage")=-1))
#endif
#if OST_PNG_ENABLED
class_<PNG, bases<ImageFormatBase> >("PNG", init<bool>(arg("normalize_on_save") = false))
.def("SetNormalizeOnSave", &PNG::SetNormalizeOnSave)
.def("GetNormalizeOnSave", &PNG::GetNormalizeOnSave)
;
#endif
class_<DAT, bases<ImageFormatBase> >("DAT", init<bool,Format,bool,Endianess>((arg("normalize_on_save") = false,arg("format")=OST_DEFAULT_FORMAT,arg("signed")=false,arg("endianess") = OST_LOCAL_ENDIAN)))
.def("SetNormalizeOnSave", &DAT::SetNormalizeOnSave)
.def("GetNormalizeOnSave", &DAT::GetNormalizeOnSave)
......@@ -171,11 +182,6 @@ void export_map_io()
.def("GetBitDepth", &IPL::GetBitDepth)
;
class_<JPK, bases<TIF> >("JPK", init<boost::logic::tribool,Format,bool,bool,int>
((arg("normalize_on_save") = boost::logic::tribool(boost::logic::indeterminate),arg("format")=OST_DEFAULT_FORMAT,arg("signed")=false,arg("phasecolor")=false,arg("subimage") = -1)))
;
class_<Nanoscope, bases<ImageFormatBase> >("Nanoscope", init <int>(arg("subimage")=-1))
;
def("SaveImage",save_image1);
......
......@@ -5,19 +5,16 @@ map_io_spi_handler.cc
map_io_situs_handler.cc
map_io_mrc_handler.cc
map_io_dm3_handler.cc
map_io_tiff_handler.cc
map_io_dat_handler.cc
map_io_ipl_handler.cc
map_io_jpk_handler.cc
map_io_nanoscope_handler.cc
map_io_png_handler.cc
map_io_df3_handler.cc
convert_vax_data.c
image_format.cc
tiff_util.cc
PARENT_SCOPE
)
set(OST_IO_IMG_HEADERS
load_map.hh
map_io_df3_handler.hh
......@@ -40,3 +37,10 @@ tiff_util.hh
jpk_util.hh
PARENT_SCOPE
)
if (ENABLE_TIFF_PNG)
list(OST_IO_IMG_SOURCES map_io_jpk_handler.cc
map_io_png_handler.cc map_io_iff_handler.cc tiff_util.cc)
list(OST_IO_IMG_HEADERS map_io_jpk_handler.hh
map_io_png_handler.hh map_io_iff_handler.hh tiff_util.hh)
endif()
......@@ -33,10 +33,14 @@
# include <ost/io/img/map_io_mrc_handler.hh>
# include <ost/io/img/map_io_dm3_handler.hh>
# include <ost/io/img/map_io_situs_handler.hh>
#if OST_TIFF_ENABLED
# include <ost/io/img/map_io_tiff_handler.hh>
# include <ost/io/img/map_io_jpk_handler.hh>
#endif
#if OST_PNG_ENABLED
# include <ost/io/img/map_io_png_handler.hh>
#endif
# include <ost/io/img/map_io_dat_handler.hh>
# include <ost/io/img/map_io_jpk_handler.hh>
# include <ost/io/img/map_io_nanoscope_handler.hh>
# include <ost/io/img/map_io_df3_handler.hh>
# include <ost/io/img/map_io_ipl_handler.hh>
......@@ -61,9 +65,13 @@ IOManager::IOManager()
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIOSitusHandlerFactory));
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIOMrcHandlerFactory));
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIODm3HandlerFactory));
#if OST_TIFF_ENABLED
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIOTiffHandlerFactory));
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIOPngHandlerFactory));
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIOJpkHandlerFactory));
#endif
#if OST_PNG_ENABLED
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIOPngHandlerFactory));
#endif
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIODatHandlerFactory));
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIONanoscopeHandlerFactory));
RegisterFactory(MapIOHandlerFactoryBasePtr(new MapIODF3HandlerFactory));
......
......@@ -29,10 +29,14 @@
#include <ost/io/img/map_io_mrc_handler.hh>
#include <ost/io/img/map_io_dm3_handler.hh>
#include <ost/io/img/map_io_situs_handler.hh>
#if OST_TIFF_ENABLED
#include <ost/io/img/map_io_tiff_handler.hh>
#include <ost/io/img/map_io_jpk_handler.hh>
#endif
#if OST_PNG_ENABLED
#include <ost/io/img/map_io_png_handler.hh>
#endif
#include <ost/io/img/map_io_dat_handler.hh>
#include <ost/io/img/map_io_jpk_handler.hh>
#include <ost/io/img/map_io_nanoscope_handler.hh>
#include <ost/io/img/map_io_ipl_handler.hh>
#include <ost/img/alg/normalizer_factory.hh>
......@@ -60,10 +64,12 @@ BOOST_AUTO_TEST_CASE(test_io_img)
float_formats["CCP4 (float)"]=new MRC;
float_formats["MRC (float)"]=new MRC(false,MRC_OLD_FORMAT);
float_formats["SPIDER"]= new Spider;
#if OST_TIFF_ENABLED
float_formats["JPK (float)"]= new JPK(false,OST_FLOAT_FORMAT);
float_formats["JPK (double)"]= new JPK(false,OST_DOUBLE_FORMAT);
float_formats["TIF (float)"]= new TIF(false,OST_FLOAT_FORMAT);
float_formats["TIF (double)"]= new TIF(false,OST_DOUBLE_FORMAT);
#endif
for(std::map<String,ImageFormatBase*>::iterator it=float_formats.begin();it!=float_formats.end();++it){
ost::io::SaveImage(testimage,fname,*(it->second));
ost::img::ImageHandle loadedimage=ost::io::LoadImage(fname,*(it->second));
......@@ -83,8 +89,10 @@ BOOST_AUTO_TEST_CASE(test_io_img)
//int 16 formats
std::map<String,ImageFormatBase*> int_formats;
int_formats["IPL (16 bit)"]=new IPL(true,OST_BIT16_FORMAT);
#if OST_TIFF_ENABLED
int_formats["TIF (16 bit)"]=new TIF;
int_formats["JPK (16 bit)"]=new JPK;
#endif
// int_formats["DF3"]=new DF3(true);
for(std::map<String,ImageFormatBase*>::iterator it=int_formats.begin();it!=int_formats.end();++it){
ost::io::SaveImage(testimage,fname,*(it->second));
......@@ -135,9 +143,13 @@ BOOST_AUTO_TEST_CASE(test_io_img)
//byte formats
std::map<String,ImageFormatBase*> byte_formats;
#if OST_PNG_ENABLED
byte_formats["PNG"]=new PNG;
byte_formats["JPK (byte)"]= new JPK(true,OST_BIT8_FORMAT);
#endif
#if OST_TIFF_ENABLED
byte_formats["TIF (byte)"]= new TIF(true,OST_BIT8_FORMAT);
byte_formats["JPK (byte)"]= new JPK(true,OST_BIT8_FORMAT);
#endif
for(std::map<String,ImageFormatBase*>::iterator it=byte_formats.begin();it!=byte_formats.end();++it){
ost::io::SaveImage(testimage,fname,*(it->second));
ost::img::ImageHandle loadedimage=ost::io::LoadImage(fname,*(it->second));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment