/home/neoflo/smb4k/SERVEUR/Millie/trunk/src/ImageMono.cpp

Aller à la documentation de ce fichier.
00001 /******************************************************************************
00002  *       __    _    _   _       _       _   _____                             *
00003  *       | \  / |  | | | |     | |     | |  | ___|                            *
00004  *       |  \/  |  | | | |     | |     | |  | |_                              *
00005  *       |      |  | | | |     | |     | |  |  _|                             *
00006  *       | |\/| |  | | | |__   | |__   | |  | |__                             *
00007  *       |_|  |_|  |_| |____|  |____|  |_|  |____|                            *
00008  * __________________________________________________________________________ *
00009  *                 Multifunctional Library For Image Processing               *
00010  *                                                                            *
00011  *                                                                            *
00012  *                                                                            *
00013  *      (c) Copyright 2007 by Humbert Florent                                 *
00014  *                                                                            *
00015  *      This program is free software; you can redistribute it and/or modify  *
00016  *      it under the terms of the GNU General Public License as published by  *
00017  *      the Free Software Foundation; only version 2 of the License.          *
00018  *                                                                            *
00019  *      This program is distributed in the hope that it will be useful,       *
00020  *      but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00021  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00022  *      GNU General Public License for more details.                          *
00023  *                                                                            *
00024  *      You should have received a copy of the GNU General Public License     *
00025  *      along with this program; if not, write to the Free Software           *
00026  *      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA             *
00027  *      02111-1307, USA.                                                      *
00028  ******************************************************************************/
00029 
00032 #ifdef _IMAGEMONO_HPP_
00033 
00034 #include <iostream>
00035 #include <sstream>
00036 #include <exception>
00037 #include <stdexcept>
00038 
00039 #include "ImageMono.hpp"
00040 
00041 namespace  Millie {
00042 
00043 template <typename T>
00044 TImageMono<T>::TImageMono()
00045 {
00046   _dataBuffer = new DataBuffer<T>(0);
00047   _largeur = 0;
00048   _hauteur = 0;
00049 }
00050 
00051 template <typename T>
00052 TImageMono<T>::TImageMono(int largeur, int hauteur)
00053 {
00054 
00055   if(largeur<0 || hauteur <0)
00056   {
00057     std::ostringstream oss;
00058     oss<<"ImageMono : Largeur " << largeur<<" Hauteur : " << hauteur;
00059     throw Millie::IllegalArgument(oss.str());
00060   }
00061   if(largeur ==0 || hauteur ==0) {
00062    _largeur = 0;
00063    _hauteur = 0;
00064   }
00065   else {
00066    _largeur = largeur;
00067    _hauteur = hauteur;
00068   }
00069 
00070   _dataBuffer = new DataBuffer<T>(_largeur * _hauteur);
00071 
00072   T null = 0;
00073 
00074   /*si la taille est nulle, on ne rentre pas dans la boucle*/
00075   for(int i = 0; i< _largeur * _hauteur; i++)
00076    (*_dataBuffer)[i] = null;
00077 }
00078 
00079 template <typename T>
00080 TImageMono<T>::TImageMono(TImageMono<T>& origine)
00081 {
00082 
00083     _largeur = origine.getWidth();
00084     _hauteur = origine.getHeight();
00085     _dataBuffer = new DataBuffer<T>(*origine._dataBuffer);
00086 
00087 }
00088 
00089 template <typename T>
00090 TImageMono<T>& TImageMono<T>::operator=(TImageMono<T> & origine)
00091 {
00092    _dataBuffer->resize(origine.getHeight() * origine.getWidth());
00093 
00094   _largeur = origine.getWidth();
00095   _hauteur = origine.getHeight();
00096   (*_dataBuffer) = *(origine._dataBuffer);
00097 
00098   return *this;
00099 }
00100 
00101 template <typename T>
00102 TImageMono<T>::~TImageMono()
00103 {
00104     delete _dataBuffer;
00105 }
00106 
00107 template <typename T>
00108 int TImageMono<T>::getWidth() const
00109 {
00110   return _largeur;
00111 }
00112 
00113 template <typename T>
00114 int TImageMono<T>::getHeight() const
00115 {
00116   return _hauteur;
00117 }
00118 
00119 
00120 template <typename T>
00121 void  TImageMono<T>::resize(int taillex, int tailley)
00122 {
00123   if(taillex<0 || tailley<0)
00124     throw Millie::IllegalArgument("ImageMono::resize");
00125 
00126   _dataBuffer->resize(taillex * tailley);
00127 
00128   _largeur = taillex;
00129   _hauteur = tailley;
00130 
00131 }
00132 
00133 }
00134 
00135 #endif

Généré le Fri May 18 23:24:33 2007 pour Millie par  doxygen 1.5.1