/home/neoflo/smb4k/SERVEUR/Millie/trunk/src/BorderExtenderCopy.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 #include "BorderExtenderCopy.hpp"
00033 
00034 using namespace Millie;
00035 
00036 
00037 BorderExtenderCopy::BorderExtenderCopy()
00038 {}
00039 
00040 void BorderExtenderCopy::extend(Image & out,
00041                                 const Image & in,
00042                                 int toppadding,
00043                                 int leftpadding,
00044                                 int rightpadding,
00045                                 int bottompadding) const
00046 {
00047   if(out.getNumComponents() != in.getNumComponents())
00048     throw Millie::IllegalArgument("BorderExtenderCopy::extend");
00049 
00050   if(toppadding<0 || leftpadding<0 || rightpadding<0 || bottompadding<0)
00051     throw Millie::IllegalArgument("BorderExtenderCopy::extend");
00052 
00053 
00054   out.resize(in.getWidth() + leftpadding + rightpadding,
00055              in.getHeight() + bottompadding + toppadding);
00056 
00057   for(int canal = 0; canal< out.getNumComponents(); canal++)
00058   {
00059     /*coin haut gauche*/
00060     for(int j = 0; j< toppadding; j++)
00061       for(int i = 0; i< leftpadding; i++)
00062         out.setPixel(i,j, canal, in.getPixel(0,0,canal));
00063 
00064     /*ligne supérieur*/
00065     for(int j = 0; j< toppadding; j++)
00066       for(int i = leftpadding; i< (in.getWidth() + leftpadding); i++)
00067         out.setPixel(i,j, canal, in.getPixel( i-leftpadding , 0, canal));
00068 
00069     /*coin supérieur droite*/
00070     for(int j = 0; j< toppadding; j++)
00071       for(int i = (in.getWidth()+ leftpadding); i< out.getWidth(); i++)
00072         out.setPixel(i,j, canal, in.getPixel(in.getWidth()-1, 0, canal));
00073 
00074     /*ligne gauche*/
00075     for(int j = toppadding; j<(in.getHeight()+ toppadding); j++)
00076       for(int i = 0; i<leftpadding; i++)
00077         out.setPixel(i,j, canal, in.getPixel(0, j-toppadding, canal));
00078 
00079     /*ligne droite*/
00080     for(int j = toppadding; j<(in.getHeight()+ toppadding); j++)
00081       for(int i = (in.getWidth()+ leftpadding); i< out.getWidth(); i++)
00082         out.setPixel(i,j, canal, in.getPixel(in.getWidth()-1, j-toppadding, canal));
00083 
00084     /*coin bas gauche*/
00085     for(int j = (in.getHeight()+ toppadding); j< out.getHeight(); j++)
00086       for(int i = 0; i< leftpadding; i++)
00087         out.setPixel(i,j, canal, in.getPixel(0, in.getHeight()-1, canal));
00088 
00089     /*coin bas droit*/
00090     for(int j = (in.getHeight()+ toppadding); j< out.getHeight(); j++)
00091       for(int i = (in.getWidth()+ leftpadding); i< out.getWidth(); i++)
00092         out.setPixel(i,j, canal, in.getPixel(in.getWidth()-1, in.getHeight()-1, canal));
00093 
00094     /*ligne bas*/
00095     for(int j = (in.getHeight()+ toppadding); j< out.getHeight(); j++)
00096       for(int i = leftpadding; i<(in.getWidth()+ leftpadding); i++)
00097         out.setPixel(i,j, canal, in.getPixel(i-leftpadding, in.getHeight()-1, canal));
00098 
00099     /*centre*/
00100     for(int j = toppadding; j< (in.getHeight()+ toppadding); j++)
00101       for(int i = leftpadding; i < (in.getWidth() + leftpadding); i++)
00102         out.setPixel(i, j, canal, in.getPixel(i-leftpadding, j-toppadding, canal));
00103 
00104 
00105   }
00106 }

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