summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/img.cc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/see/img.cc')
-rw-r--r--2005/i/robert/src/ovision/see/img.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/2005/i/robert/src/ovision/see/img.cc b/2005/i/robert/src/ovision/see/img.cc
index 52ce584..fa38e4a 100644
--- a/2005/i/robert/src/ovision/see/img.cc
+++ b/2005/i/robert/src/ovision/see/img.cc
@@ -11,7 +11,7 @@
/// Constructeur
Img::Img (void)
- : tabData_ (0), tabSegm_ (0)
+ : tabY_ (0), tabData_ (0), tabSegm_ (0)
{
}
@@ -20,6 +20,7 @@ Img::~Img (void)
{
delete [] tabData_;
delete [] tabSegm_;
+ delete [] tabY_;
}
/// Ecrit les valeurs RGB dans un fichier
@@ -35,6 +36,16 @@ Img::writeRaw (const char *filename, unsigned char *tab) const
file.close ();
}
+/// Crée le tableau Y
+void
+Img::doTabY ()
+{
+ delete [] tabY_;
+ tabY_ = new int[height_];
+ for (int i=0; i<height_; ++i)
+ tabY_[i] = i*width_;
+}
+
/// Charge les valeurs RGB dans un fichier
void
Img::loadRaw (const char *filename, const Image::PixelFormat colorMode_, const int width_, const int height_)
@@ -43,6 +54,7 @@ Img::loadRaw (const char *filename, const Image::PixelFormat colorMode_, const i
this->width_ = width_;
this->height_ = height_;
nbPixels_ = width_ * height_;
+ doTabY ();
this->colorMode_ = colorMode_;
// Initialise tabData_
delete[] tabData_;
@@ -64,16 +76,21 @@ Img::loadMultipeRaw (const std::vector<std::string> &imgList, const Image::Pixel
this->width_ = width_;
this->height_ = height_ * imgList.size ();
nbPixels_ = width_ * height_;
+ doTabY ();
this->colorMode_ = colorMode_;
// Initialise tabData_
delete[] tabData_;
tabData_ = new unsigned char[nbPixels_*3];
+ unsigned char *t = tabData_;
// Ouvre les images et stocke les données dans tabData_
for (std::vector<std::string>::const_iterator iter=imgList.begin(); iter != imgList.end(); iter++)
{
std::ifstream file (iter->c_str (), std::ios::in);
if (file)
- file.read ((char *)tabData_, nbPixels_*3);
+ {
+ file.read ((char *)t, nbPixels_*3);
+ t += nbPixels_*3;
+ }
else
std::cerr << "Img::loadRaw Erreur d'ouverture de fichier " << *iter << std::endl;
file.close ();
@@ -90,6 +107,7 @@ Img::load (ImageReader &loader)
Image image;
image.read (loader);
loader.getParam (width_, height_, colorMode_);
+ doTabY ();
nbPixels_ = width_ * height_;
tabData_ = new unsigned char[image.getBufSize ()];
memcpy (tabData_, image.getBuf (), image.getBufSize ());