00001 /************************************************************************* 00002 * $Id: imazoom.c,v 1.1 2005/09/09 08:22:50 bellet Exp $ 00003 ************************************************************************** 00004 This software is governed by the CeCILL license under French law and 00005 abiding by the rules of distribution of free software. You can use, 00006 modify and/ or redistribute the software under the terms of the CeCILL 00007 license as circulated by CEA, CNRS and INRIA at the following URL 00008 "http://www.cecill.info". 00009 00010 As a counterpart to the access to the source code and rights to copy, 00011 modify and redistribute granted by the license, users are provided only 00012 with a limited warranty and the software's author, the holder of the 00013 economic rights, and the successive licensors have only limited 00014 liability. 00015 00016 In this respect, the user's attention is drawn to the risks associated 00017 with loading, using, modifying and/or developing or reproducing the 00018 software by the user in light of its specific status of free software, 00019 that may mean that it is complicated to manipulate, and that also 00020 therefore means that it is reserved for developers and experienced 00021 professionals having in-depth computer knowledge. Users are therefore 00022 encouraged to load and test the software's suitability as regards their 00023 requirements in conditions enabling the security of their systems and/or 00024 data to be ensured and, more generally, to use and operate it in the 00025 same conditions as regards security. 00026 00027 The fact that you are presently reading this means that you have had 00028 knowledge of the CeCILL license and that you accept its terms. 00029 00030 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 00031 l'Image). All rights reserved. See License.txt for details. 00032 00033 Version 1.0 05/09/2005 00034 *************************************************************************/ 00035 00036 /************************************************************************* 00037 * 00038 * Description : Module offrant la possibilite de changer la taille d'une 00039 * image (IdImaZoom) . 00040 * 00041 **************************************************************************/ 00042 #include "idima.h" 00043 #include "iderr.h" 00044 #include "idprint.h" 00045 00046 00047 /* FUNCTION DESCRIPTION ************************************************** 00048 00049 IdImaZoom (fonction) 00050 00051 RESUME: Cree une copie d'une image en changeant ses dimensions. 00052 00053 DESCRIPTION: Cree une copie d'une image en changeant ses dimensions. 00054 00055 SYNTAXE: PPIMAGE imRes = IdImaZoom ( PPIMAGE imRes, PPIMAGE imSource ); 00056 00057 RETOUR: type : PPIMAGE 00058 acces : O 00059 role : Pointeur vers l'image resultat, ou 0 si echec. 00060 00061 PARAMETRES: 00062 nom : imout 00063 type : PPIMAGE 00064 acces : I,O,N 00065 role : Pointeur vers la nouvelle image. Doit etre alloue 00066 avant l'appel a la fonction. 00067 00068 nom : imin 00069 type : PPIMAGE 00070 acces : I,N 00071 role : Pointeur vers l'image d'origine. 00072 00073 VERSION: V1.00 00074 00075 FICHIER: imazoom.c 00076 00077 EXEMPLE: if( IdImaZoom(imout,imin) ) { 00078 IdErrPrintf("Erreur lors du changement d'echelle"); 00079 IdExit(1); 00080 } 00081 00082 ******************************************************** END DESCRIPTION */ 00083 PPIMAGE IdImaZoom (imout,imin) 00084 PPIMAGE imout, imin; 00085 { 00086 /* JPR */ 00087 #define CC(t1) for (j=0; j<toy; j++) \ 00088 for (i=0; i<tox; i++) \ 00089 ((t1)imout)[j][i]=((t1)imin)[(int)(j*rapporty)][(int)(i*rapportx)]; 00090 00091 00092 00093 int curx=IdImaDimX (imin); 00094 int cury=IdImaDimY (imin); 00095 int tox=IdImaDimX (imout); 00096 int toy=IdImaDimY (imout); 00097 int i,j; 00098 00099 float rapportx=((float)(curx))/tox; 00100 float rapporty=((float)(cury))/toy; 00101 /* IdPrintf(" zoom x %f zoomy %f \n",rapportx,rapporty); */ 00102 00103 if(IdImaType(imin)==IdImaType(imout)) 00104 { 00105 switch(IdImaType(imin)) 00106 { 00107 case IMA_UCHAR: CC(PPIMAGE_UCHAR); break; 00108 case IMA_CHAR: CC(PPIMAGE_CHAR); break; 00109 case IMA_USHORT: CC(PPIMAGE_USHORT); break; 00110 case IMA_SHORT: CC(PPIMAGE_SHORT); break; 00111 case IMA_LONG: CC(PPIMAGE_LONG); break; 00112 case IMA_FLOAT: CC(PPIMAGE_FLOAT); break; 00113 case IMA_DOUBLE: CC(PPIMAGE_DOUBLE); break; 00114 case IMA_RGB: CC(PPIMAGE_RGB); break; 00115 default: 00116 IdErrno=IDERR_WRONG_LIBTYPE; 00117 IdPrintf("Type %d non traite par IdImaZoom\n",IdImaType(imin)); 00118 return 0; 00119 } 00120 return imout; 00121 } 00122 else 00123 { IdErrno=IDERR_WRONG_IMAGES; 00124 IdPrintf("images de type differents\n"); 00125 return 0; 00126 } 00127 00128 } 00129