From 7b3948ab3d5cfb28360a41d9d803ac31d71dff54 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 4 Dec 2014 23:09:25 -0600 Subject: [PATCH] added support for the image interface to envi --- envi/envi.h | 6 +++--- image/image.h | 30 ++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/envi/envi.h b/envi/envi.h index e10e880..f87f601 100644 --- a/envi/envi.h +++ b/envi/envi.h @@ -6,7 +6,7 @@ #include "../envi/bip.h" #include "../envi/bil.h" #include -//#include "../image/CImg.h" +#include "../image/image.h" namespace stim{ @@ -641,10 +641,10 @@ public: //load mask from maskfile and save it into memory bool load_mask(unsigned char * mask, std::string maskname){ //open the mask file - cimg_library::CImg mask_image(maskname.c_str()); + stim::image mask_image(maskname); //save mask file into memory memcpy(mask, mask_image.data(), mask_image.size()); - mask_image.clear(); + //mask_image.clear(); return true; } diff --git a/image/image.h b/image/image.h index 28b80ab..289dbbd 100644 --- a/image/image.h +++ b/image/image.h @@ -4,6 +4,8 @@ #include "CImg.h" #include + +namespace stim{ //This static class provides the STIM interface for loading images // Use this interface for all image management - that way the actual library can be changed without problems @@ -12,18 +14,27 @@ template class image{ - cimg_library::CImg data; + cimg_library::CImg img; public: + //default constructor + image(){ + } + + //constructor (load an image file) + image(std::string filename){ + img.load(filename.c_str()); + } + //Load an image from a file void load(std::string filename){ - data.load(filename.c_str()); + img.load(filename.c_str()); } //save a file void save(std::string filename){ - data.save(filename.c_str()); + img.save(filename.c_str()); } //create an image from an interlaced buffer @@ -38,8 +49,17 @@ public: } } - data = cimg_library::CImg(non_interleaved, width, height, 1, channels); + img = cimg_library::CImg(non_interleaved, width, height, 1, channels); + } + + //returns a pointer to the first pixel of the image data + T* data(){ + return img.data(); + } + //returns the size (number of values) of the image + unsigned long size(){ + return img.size(); } @@ -48,5 +68,7 @@ public: }; +}; //end namespace stim + #endif -- libgit2 0.21.4