Go to the documentation of this file.00001 #ifndef OPENTISSUE_GPU_IMAGE_IO_IMAGE_WRITE_H
00002 #define OPENTISSUE_GPU_IMAGE_IO_IMAGE_WRITE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/gpu/image/image.h>
00013 #include <OpenTissue/gpu/image/io/image_il_wrap.h>
00014
00015 #include <iostream>
00016 #include <string>
00017
00018 namespace OpenTissue
00019 {
00020 namespace image
00021 {
00030 bool write(
00031 std::string const & filename
00032 , OpenTissue::image::Image<unsigned char> const & image
00033 )
00034 {
00035 ilInit();
00036 iluInit();
00037 ilutInit();
00038
00039
00040
00041
00042 OpenTissue::image::detail::ilImage devil;
00043
00044 size_t width = image.width();
00045 size_t height = image.height();
00046
00047 unsigned char * pixel = static_cast<unsigned char *>( const_cast<void *>(image.get_data()) );
00048
00049 devil.TexImage(width, height, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, pixel);
00050
00051 ilEnable(IL_FILE_OVERWRITE);
00052
00053 bool result = !(0 == devil.Save(const_cast< char * >(filename.c_str())) );
00054
00055 ilShutDown();
00056
00057 return result;
00058 }
00059
00060 }
00061 }
00062
00063
00064 #endif