Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

imachekal.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: imachekal.c,v 1.1 2005/09/09 08:22:45 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 * Compatibility/allocation of images 00038 */ 00039 #include "idima.h" 00040 #include "iderr.h" 00041 00042 /* 00043 * FUNCTION DESCRIPTION ************************************************** 00044 * 00045 * IdImaCheckTypeSizeAlloc (fonction) 00046 * 00047 * RESUME: Test Compatib. 2 im (type/size); Alloc meme taille/type si 2-ieme non allouee 00048 * 00049 * DESCRIPTION: Test Compatib. 2 im (type/size); Alloc meme taille/type si 2-ieme non allouee. 00050 * On peut imposer un Type donne (2-ieme parametre). 00051 * S'il vaut -1, tous types autorises 00052 * 00053 * SYNTAXE: PPIMAGE imDest = IdImaCheckTypeSizeAlloc (PPIMAGE imSource, int typeImpose, PPIMAGE imDest); 00054 * 00055 * RETOUR: type : PPIMAGE 00056 * role : Pointeur vers l'image resultat. Zero si echec. 00057 * 00058 * PARAMETRES: nom : imSource 00059 * type : PPIMAGE 00060 * role : Pointeur vers l'image source. 00061 * 00062 * nom : typeImpose 00063 * type : int 00064 * role : type Obligatoire pour l'image Source 00065 * s'il vaut -1, tous les types sont autorises 00066 * 00067 * nom : imDest 00068 * type : PPIMAGE 00069 * role : Pointeur vers l'image resultat 00070 * Si ce pointeur est nul, l'image est allouee par 00071 * la fonction. 00072 * Cette image peut eventuellement etre l'image source. 00073 * 00074 * FICHIER: ImChekAll.c 00075 * 00076 * EXEMPLE: if ( (imd=IdImaCheckTypeSizeAlloc(ims,-1,imd))==0 ) 00077 * IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00078 * 00079 * ******************************************************** END DESCRIPTION 00080 */ 00081 00082 PPIMAGE 00083 IdImaCheckTypeSizeAlloc(PPIMAGE imSource, int typeImpose, PPIMAGE imDest) 00084 { 00085 if (!imSource) { 00086 IdErrno = IDERR_POINTER_IS_NULL; 00087 return 0; 00088 } 00089 00090 if (IdLibidoType(imSource) != IMA) { 00091 IdErrno = IDERR_WRONG_LIBTYPE; 00092 return 0; 00093 } 00094 00095 if (typeImpose != -1) { 00096 /* 00097 * y a-t-il un type Impose 00098 */ 00099 if (IdImaType(imSource) != typeImpose) { 00100 IdErrno = IDERR_WRONG_LIBTYPE; 00101 return 0; 00102 } 00103 } 00104 00105 if (!imDest) { 00106 /* 00107 * Alloc. si necessaire * 00108 */ 00109 imDest = (PPIMAGE) IdImaAllocLikeImage(imSource); 00110 if (!imDest) { 00111 IdErrno = IDERR_ALLOC_IMA; 00112 return 0; 00113 } 00114 return imDest; 00115 } else { 00116 /* 00117 * Meme taille et type ? * 00118 */ 00119 00120 if (!IdImaSameSizeAndType(imSource, imDest)) { 00121 IdErrno = IDERR_WRONG_IMAGES; 00122 return 0; 00123 } else 00124 return imDest; 00125 } 00126 } 00127 00128 PPIMAGE 00129 IdImaCheckSizeTypeAlloc(PPIMAGE SourceIm, int type, PPIMAGE DestIm) 00130 { 00131 return IdImaCheckTypeSizeAlloc(SourceIm, type, DestIm); 00132 } 00133 00134 00135 /* 00136 * FUNCTION DESCRIPTION ************************************************** 00137 * 00138 * IdImaCheckSizeAlloc (fonction) 00139 * 00140 * RESUME: Test Compatib. 2 im (size); Alloc meme taille/type si 2-ieme non allouee. 00141 * 00142 * DESCRIPTION: Test Compatib. 2 im (size); Alloc meme taille/type si 2-ieme non allouee. 00143 * On peut imposer un Type donne (2-ieme parametre. 00144 * S'il vaut -1, tous types autorises) 00145 * 00146 * SYNTAXE: PPIMAGE imDest = IdImaCheckSizeAlloc (PPIMAGE imSource, int typeImpose, PPIMAGE imDest, int typeImDest); 00147 * 00148 * RETOUR: type : PPIMAGE 00149 * role : Pointeur vers l'image resultat. Zero si echec. 00150 * 00151 * PARAMETRES: nom : imSource 00152 * type : PPIMAGE 00153 * role : Pointeur vers l'image source. 00154 * 00155 * nom : typeImpose 00156 * type : int 00157 * role : type Obligatoire pour l'image Source 00158 * s'il vaut -1, tous les types sont autorises 00159 * 00160 * nom : imDest 00161 * type : PPIMAGE 00162 * role : Pointeur vers l'image resultat 00163 * Si ce pointeur est nul, l'image est allouee par 00164 * la fonction. 00165 * Cette image peut eventuellement etre l'image source. 00166 * 00167 * nom : typeImDest 00168 * type : int 00169 * role : Type de l'image resultat 00170 * 00171 * 00172 * FICHIER: ImChekAll.c 00173 * 00174 * EXEMPLE: if ( (imd=IdImaCheckSizeAlloc(ims,-1,imd,IMA_COMPLEX_DOUBLE))==0 ) 00175 * IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00176 * 00177 * ******************************************************** END DESCRIPTION 00178 */ 00179 00180 PPIMAGE 00181 IdImaCheckSizeAlloc(PPIMAGE imSource, int typeImpose, PPIMAGE imDest) 00182 { 00183 if (!imSource) { 00184 IdErrno = IDERR_POINTER_IS_NULL; 00185 return 0; 00186 } 00187 00188 if (IdLibidoType(imSource) != IMA) { 00189 IdErrno = IDERR_WRONG_LIBTYPE; 00190 return 0; 00191 } 00192 if (typeImpose != -1) { 00193 /* 00194 * y a-t-il un type Impose 00195 */ 00196 if (IdImaType(imSource) != typeImpose) { 00197 IdErrno = IDERR_WRONG_LIBTYPE; 00198 return 0; 00199 } 00200 } 00201 00202 if (!imDest) { 00203 /* 00204 * Alloc. si necessaire * 00205 */ 00206 imDest = (PPIMAGE) IdImaAlloc(IdImaDimX(imSource), 00207 IdImaDimY(imSource), 00208 IdImaType(imSource)); 00209 if (!imDest) { 00210 IdErrno = IDERR_ALLOC_IMA; 00211 return 0; 00212 } 00213 return imDest; 00214 } else { 00215 /* 00216 * Meme taille ? * 00217 */ 00218 if (!IdImaSameSize(imSource, imDest)) { 00219 IdErrno = IDERR_WRONG_IMAGES; 00220 return 0; 00221 } else 00222 return imDest; 00223 } 00224 } 00225 00226 /* 00227 * FUNCTION DESCRIPTION ************************************************** 00228 * 00229 * IdImaCheckTypeAlloc (fonction) 00230 * 00231 * RESUME: Test Compatib. 2 im (type); Alloc meme taille/type si 2-ieme non alloueee 00232 * 00233 * DESCRIPTION: Test Compatib. 2 im (type); Alloc meme taille/type si 2-ieme non alloueee 00234 * On peut imposer un Type donne (2-ieme parametre. 00235 * S'il vaut -1, tous types autorises) 00236 * 00237 * SYNTAXE: PPIMAGE imDest = IdImaCheckTypeAlloc (PPIMAGE imSource, int typeImpose, PPIMAGE imDest); 00238 * 00239 * RETOUR: type : PPIMAGE 00240 * role : Pointeur vers l'image resultat. Zero si echec. 00241 * 00242 * PARAMETRES: nom : imSource 00243 * type : PPIMAGE 00244 * role : Pointeur vers l'image source. 00245 * 00246 * nom : typeImpose 00247 * type : int 00248 * role : type Obligatoire pour l'image Source 00249 * s'il vaut -1, tous les types sont autorises 00250 * 00251 * nom : imDest 00252 * type : PPIMAGE 00253 * role : Pointeur vers l'image resultat 00254 * Si ce pointeur est nul, l'image est allouee par 00255 * la fonction. 00256 * Cette image peut eventuellement etre l'image source. 00257 * 00258 * 00259 * FICHIER: ImChekAll.c 00260 * 00261 * EXEMPLE: if ( (imd=IdImaCheckTypeAlloc(ims,-1,imd))==0 ) 00262 * IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00263 * 00264 * ******************************************************** END DESCRIPTION 00265 */ 00266 00267 PPIMAGE 00268 IdImaCheckTypeAlloc(PPIMAGE imSource, int typeImpose, PPIMAGE imDest) 00269 { 00270 if (!imSource) { 00271 IdErrno = IDERR_POINTER_IS_NULL; 00272 return 0; 00273 } 00274 00275 if (IdLibidoType(imSource) != IMA) { 00276 IdErrno = IDERR_WRONG_LIBTYPE; 00277 return 0; 00278 } 00279 00280 if (typeImpose != -1) { 00281 /* 00282 * y a-t-il un type Impose 00283 */ 00284 if (IdImaType(imSource) != typeImpose) { 00285 IdErrno = IDERR_WRONG_LIBTYPE; 00286 return 0; 00287 } 00288 } 00289 00290 if (!imDest) { 00291 /* 00292 * Alloc. si necessaire * 00293 */ 00294 imDest = (PPIMAGE) IdImaAlloc(IdImaDimX(imSource), 00295 IdImaDimY(imSource), 00296 IdImaType(imSource)); 00297 if (!imDest) { 00298 IdErrno = IDERR_ALLOC_IMA; 00299 return 0; 00300 } 00301 return imDest; 00302 } else { 00303 /* 00304 * Meme type ? * 00305 */ 00306 if (!IdImaSameType(imSource, imDest)) { 00307 IdErrno = IDERR_WRONG_IMAGES; 00308 return 0; 00309 } else 00310 return imDest; 00311 } 00312 } 00313 00314 /* 00315 * FUNCTION DESCRIPTION ************************************************** 00316 * 00317 * IdImaCheckSizeAllocType (fonction) 00318 * 00319 * RESUME: Test Compatib. 2 im (size); Alloc type choisi/meme taille si 2-ieme non allouee. 00320 * 00321 * DESCRIPTION: Test Compatib. 2 im (size); Alloc type choisi/meme taille si 2-ieme non allouee. 00322 * On PEUT imposer un Type donne pour l'image origine (2-ieme parametre. 00323 * S'il vaut -1, tous types autorises) 00324 * On DOIT preciser le type de l'image destination. 00325 * 00326 * SYNTAXE: PPIMAGE imDest = IdImaCheckSizeAlloc (PPIMAGE imSource, int typeImpose, PPIMAGE imDest, int typeImDest); 00327 * 00328 * RETOUR: type : PPIMAGE 00329 * role : Pointeur vers l'image resultat. Zero si echec. 00330 * 00331 * PARAMETRES: nom : imSource 00332 * type : PPIMAGE 00333 * role : Pointeur vers l'image source. 00334 * 00335 * nom : typeImpose 00336 * type : int 00337 * role : type Obligatoire pour l'image Source 00338 * s'il vaut -1, tous les types sont autorises 00339 * 00340 * nom : imDest 00341 * type : PPIMAGE 00342 * role : Pointeur vers l'image resultat 00343 * Si ce pointeur est nul, l'image est allouee par 00344 * la fonction. 00345 * Cette image peut eventuellement etre l'image source. 00346 * 00347 * nom : typeImDest 00348 * type : int 00349 * role : Type de l'image resultat 00350 * 00351 * FICHIER: ImChekAll.c 00352 * 00353 * EXEMPLE: if ( (imd=IdImaCheckSizeAlloc(ims,-1,imd,IMA_COMPLEX_DOUBLE))==0 ) 00354 * IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00355 * 00356 * ******************************************************** END DESCRIPTION 00357 */ 00358 00359 PPIMAGE 00360 IdImaCheckSizeAllocType(PPIMAGE imSource, int typeImpose, 00361 PPIMAGE imDest, int typeImDest) 00362 { 00363 if (!imSource) { 00364 IdErrno = IDERR_POINTER_IS_NULL; 00365 return 0; 00366 } 00367 00368 if (IdLibidoType(imSource) != IMA) { 00369 IdErrno = IDERR_WRONG_LIBTYPE; 00370 return 0; 00371 } 00372 00373 if (typeImpose != -1) { 00374 /* 00375 * y a-t-il un type Impose 00376 */ 00377 if (IdImaType(imSource) != typeImpose) { 00378 IdErrno = IDERR_WRONG_LIBTYPE; 00379 return 0; 00380 } 00381 } 00382 00383 if (!imDest) { 00384 /* 00385 * Alloc. si necessaire 00386 */ 00387 imDest = (PPIMAGE) IdImaAlloc(IdImaDimX(imSource), 00388 IdImaDimY(imSource), 00389 typeImDest); 00390 if (!imDest) { 00391 IdErrno = IDERR_ALLOC_IMA; 00392 return 0; 00393 } 00394 return imDest; 00395 } else { 00396 /* 00397 * Meme taille ? * 00398 */ 00399 if (!IdImaSameSize(imSource, imDest)) { 00400 IdErrno = IDERR_WRONG_IMAGES; 00401 return 0; 00402 } else 00403 if (IdImaType(imDest) != typeImDest) { 00404 IdErrno = IDERR_WRONG_LIBTYPE; 00405 return 0; 00406 } 00407 00408 return imDest; 00409 } 00410 } 00411 00412 /* 00413 * FUNCTION DESCRIPTION ************************************************** 00414 * 00415 * IdImaCheckTypeAllocSize (fonction) 00416 * 00417 * RESUME: Test Compatib. 2 im (type); Alloc meme type,taille choisie si 2-ieme non allouee 00418 * 00419 * DESCRIPTION: Test Compatib. 2 im (type); Alloc meme type,taille choisie si 2-ieme non allouee. 00420 * On peut imposer un Type donne pour l'image Source (2-ieme parametre. 00421 * S'il vaut -1, tous types autorises) 00422 * 00423 * SYNTAXE: PPIMAGE imDest = IdImaCheckTypeAllocSize (PPIMAGE imSource, int typeImpose, PPIMAGE imDest, int nouvTailleX, int nouvTailleY); 00424 * 00425 * RETOUR: type : PPIMAGE 00426 * role : Pointeur vers l'image resultat. Zero si echec. 00427 * 00428 * PARAMETRES: nom : imSource 00429 * type : PPIMAGE 00430 * role : Pointeur vers l'image source. 00431 * 00432 * nom : typeImpose 00433 * type : int 00434 * role : type Obligatoire pour l'image Source 00435 * s'il vaut -1, tous les types sont autorises 00436 * 00437 * nom : imDest 00438 * type : PPIMAGE 00439 * role : Pointeur vers l'image resultat 00440 * Si ce pointeur est nul, l'image est allouee par 00441 * la fonction. 00442 * Cette image peut eventuellement etre l'image source. 00443 * 00444 * nom : nouvTailleX 00445 * type : int 00446 * role : Taille en X de l'image resultat, 00447 * si elle n'est pas deja allouee 00448 * 00449 * nom : nouvTailleY 00450 * type : int 00451 * role : Taille en Y de l'image resultat, 00452 * si elle n'est pas deja allouee 00453 * 00454 * FICHIER: ImChekAll.c 00455 * 00456 * EXEMPLE: if ( (imd=IdImaCheckTypeAllocSize(ims,-1,imd,128,256))==0 ) 00457 * IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00458 * 00459 * ******************************************************** END DESCRIPTION 00460 */ 00461 00462 PPIMAGE 00463 IdImaCheckTypeAllocSize(PPIMAGE imSource, int typeImpose, 00464 PPIMAGE imDest, int nouvTailleX, int nouvTailleY) 00465 { 00466 if (!imSource) { 00467 IdErrno = IDERR_POINTER_IS_NULL; 00468 return 0; 00469 } 00470 00471 if (IdLibidoType(imSource) != IMA) { 00472 IdErrno = IDERR_WRONG_LIBTYPE; 00473 return 0; 00474 } 00475 00476 if (typeImpose != -1) { 00477 if (IdImaType(imSource) != typeImpose) { 00478 IdErrno = IDERR_WRONG_LIBTYPE; 00479 return 0; 00480 } 00481 } 00482 00483 if (!imDest) { 00484 /* 00485 * Alloc. si necessaire * 00486 */ 00487 imDest = (PPIMAGE) IdImaAlloc(nouvTailleX, nouvTailleY, 00488 IdImaType(imSource)); 00489 if (!imDest) { 00490 IdErrno = IDERR_ALLOC_IMA; 00491 return 0; 00492 } 00493 return imDest; 00494 } else { 00495 /* 00496 * Meme type ? * 00497 */ 00498 00499 if (!IdImaSameType(imSource, imDest)) { 00500 IdErrno = IDERR_WRONG_IMAGES; 00501 00502 return 0; 00503 } else 00504 return imDest; 00505 } 00506 }

Generated on Wed Oct 19 09:28:33 2005 for SIMRI3D by doxygen 1.3.7