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

imapart.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: imapart.c,v 1.1 2005/09/09 08:22:49 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 : Creation d'une structure image a partir d'une portion 00039 * d'une autre image 00040 * 00041 **************************************************************************/ 00042 #include <string.h> // For memcpy 00043 #include <stdlib.h> 00044 #include "idima.h" 00045 #include "iderr.h" 00046 #include "idprint.h" 00047 00048 /* FUNCTION DESCRIPTION ************************************************** 00049 00050 IdImaAllocSubImage (fonction) 00051 00052 RESUME: Alloc d'1 im. a partir d'1 portion d'1 autre im. ss duplic. de pixels 00053 00054 DESCRIPTION: Allocation d'une image a partir d'une portion d'une autre 00055 image sans duplic. de pixels. 00056 ATTENTION: L'image d'origine ne doit en aucun cas etre liberee 00057 avant cette sous-image. En effet l'information pixel n'est pas 00058 dupliquee. Les modifications de la sous-image sont faites dans 00059 la zone correspondante de l'image d'origine. 00060 Cette fonction peut donc etre tres utile pour faire un 00061 traitement sur une portion seulement d'une image. 00062 00063 SYNTAXE: PPIMAGE sousImage = IdImaAllocSubImage (PPIMAGE ims, int ox, int oy, int lx, int ly); 00064 00065 RETOUR: type : PPIMAGE 00066 role : Pointeur vers l'image resultat. Zero si echec. 00067 00068 PARAMETRES: nom : ims 00069 type : PPIMAGE 00070 role : Pointeur vers l'image source 00071 00072 nom : ox, oy 00073 type : int 00074 role : Origine en X et Y de la sous-image. 00075 00076 nom : lx, ly 00077 type : int 00078 role : Taille en X et Y de la sous-image. 00079 00080 FICHIER: imapart.c 00081 00082 EXEMPLE: if ( (imss=IdImaAllocSubImage(ims,0,0,10,10))==0 ) 00083 IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00084 // Filtrage median sur la sous-image 00085 imr = IdImaMedian(imss,imr,5); 00086 IdImaFreeSubImage(imss); 00087 00088 ******************************************************** END DESCRIPTION */ 00089 00109 PPIMAGE IdImaAllocSubImage ( PPIMAGE im, int ox, int oy, int lx, int ly ) 00110 { 00111 int x; 00112 int y, j; 00113 PPIMAGE_UCHAR ims = (PPIMAGE_UCHAR)im; 00114 PPIMAGE_UCHAR imd = NULL; 00115 PRIVATE_IMAGE * si; 00116 00117 if ( (ox < 0) || (ox+lx>IdImaDimX(im)) || (lx<=0) ) { 00118 IdErrno = IDERR_X_OUT_OF_IMAGE; 00119 return 0; 00120 } 00121 if ( (oy < 0) || (oy+ly>IdImaDimY(im)) || (ly<=0) ) { 00122 IdErrno = IDERR_Y_OUT_OF_IMAGE; 00123 return 0; 00124 } 00125 if ( im==0 ) { 00126 IdErrno = IDERR_POINTER_IS_NULL; 00127 return 0; 00128 } 00129 00130 if ( IdLibidoType(im) != IMA) { 00131 IdErrno = IDERR_WRONG_TYPE; 00132 return(PPIMAGE)0; 00133 } 00134 00135 si=(PRIVATE_IMAGE *)calloc(1, sizeof(PRIVATE_IMAGE)+ly*sizeof(void *)); 00136 if(si){ 00137 00138 x = ox*IdSizeOfType(im); 00139 si->DimX=si->UsedNbX=lx; 00140 si->DimY=si->UsedNbY=ly; 00141 si->Type=IdImaType(im); 00142 si->subObject=1; 00143 imd = (PPIMAGE_UCHAR)&(si[1]); 00144 for ( y=oy, j=0; y<oy+ly; y++, j++ ) 00145 imd[j]= &(ims[y][x]); 00146 IdSetFileName(imd,IdGetFileName(ims)); 00147 } 00148 else IdErrno = IDERR_POINTER_IS_NULL; /* a mettre le bon code */ 00149 00150 /* Calcul du resultat *****/ 00151 return (PPIMAGE) imd; 00152 } 00153 00154 00155 /* FUNCTION DESCRIPTION ************************************************** 00156 00157 IdImaModifSubImage (fonction) 00158 00159 RESUME: Modif de l'emplacement d'1 ss im. SANS duplic. de la structure 00160 00161 DESCRIPTION: Modif de l'emplacement d'1 ss im. SANS duplic. de la structure 00162 ATTENTION: L'image d'origine ne doit en aucun cas etre liberee 00163 avant cette sous-image. En effet l'information pixel n'est pas 00164 dupliquee. Les modifications de la sous-image sont faites dans 00165 la zone correspondante de l'image d'origine. 00166 Cette fonction peut donc etre tres utile pour faire un 00167 traitement sur une portion seulement d'une image. 00168 00169 SYNTAXE: PPIMAGE sousImage = IdImaModifSubImage (PPIMAGE ims, PPIMAGE sousImage, int ox, int oy); 00170 00171 RETOUR: type : PPIMAGE 00172 role : Pointeur vers l'image resultat. Zero si echec. 00173 00174 PARAMETRES: nom : ims 00175 type : PPIMAGE 00176 role : Pointeur vers l'image source 00177 00178 nom : ims 00179 type : PPIMAGE 00180 role : Pointeur vers l'imagette a modifier 00181 00182 nom : ox, oy 00183 type : int 00184 role : Origine en X et Y de la nouvelle sous-image. 00185 00186 FICHIER: imapart.c 00187 00188 EXEMPLE: imss=IdImaModifSubImage(ims,imss,debX,debY); 00189 00190 00191 ******************************************************** END DESCRIPTION */ 00192 00211 PPIMAGE IdImaModifSubImage ( im, ssim, ox, oy ) 00212 PPIMAGE im, ssim; 00213 int ox, oy; 00214 { 00215 int lx, ly; 00216 00217 int x = ox*IdSizeOfType(im); 00218 int y, j; 00219 PPIMAGE_UCHAR ims = (PPIMAGE_UCHAR)im; 00220 PPIMAGE_UCHAR imd = (PPIMAGE_UCHAR)ssim; 00221 /* PRIVATE_IMAGE * si; */ 00222 00223 if ( im==0 ) { 00224 IdErrno = IDERR_POINTER_IS_NULL; 00225 return 0; 00226 } 00227 if ( ssim==0 ) { 00228 IdErrno = IDERR_POINTER_IS_NULL; 00229 return 0; 00230 } 00231 00232 if ( IdLibidoType(im) != IMA) { 00233 IdErrno = IDERR_WRONG_TYPE; 00234 return(PPIMAGE)0; 00235 } 00236 00237 lx=IdImaDimX(ssim); 00238 ly=IdImaDimY(ssim); 00239 00240 if ( (ox < 0) || (ox+lx>IdImaDimX(im)) ) { 00241 IdErrno = IDERR_X_OUT_OF_IMAGE; 00242 return 0; 00243 } 00244 if ( (oy < 0) || (oy+ly>IdImaDimY(im)) ) { 00245 IdErrno = IDERR_Y_OUT_OF_IMAGE; 00246 return 0; 00247 } 00248 00249 /* si=(PRIVATE_IMAGE *)calloc(1, sizeof(PRIVATE_IMAGE)+ly*sizeof(void *));*/ 00250 /* imd = (PPIMAGE_UCHAR)&(si[1]); */ 00251 00252 for ( y=oy, j=0; y<oy+ly; y++, j++ ) 00253 imd[j]= &(ims[y][x]); 00254 00255 IdSetFileName(imd,IdGetFileName(ims)); 00256 00257 /* Calcul du resultat *****/ 00258 return (PPIMAGE) imd; 00259 } 00260 00261 /***************************************************/ 00262 00263 00264 /* FUNCTION DESCRIPTION ************************************************** 00265 00266 IdImaFreeSubImage (macro) 00267 00268 RESUME: Liberation d'1 image constituee comme 1 portion d'1 autre image 00269 00270 DESCRIPTION: Liberation d'une image constituee comme une portion d'une autre 00271 image. 00272 ATTENTION: L'image d'origine ne doit en aucun cas etre liberee 00273 avant cette sous-image. En effet l'information pixel n'est pas 00274 dupliquee. Les modifications de la sous-image sont faites dans 00275 la zone correspondante de l'image d'origine. 00276 00277 SYNTAXE: void IdImaFreeSubImage (PPIMAGE im); 00278 00279 RETOUR: type : void 00280 00281 PARAMETRES: nom : im 00282 type : PPIMAGE 00283 role : Pointeur vers la sous-image a liberer. 00284 00285 FICHIER: imapart.c 00286 00287 EXEMPLE: if ( (imss=IdImaAllocSubImage(ims,0,0,10,10))==0 ) 00288 IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00289 / * Filtrage median sur la sous-image * / 00290 imr = IdImaMedian(ims,imr,5); 00291 IdImaFreeSubImage(imss); 00292 00293 ******************************************************** END DESCRIPTION */ 00294 void _IdImaFreeSubImage(pi) 00295 PPIMAGE * pi; 00296 { 00297 if(*pi){ 00298 /* les lignes ne doivent pas etre liberees, puisqu'elles 00299 appartiennent a l'image d'origine !!! */ 00300 if(_IdImaPrivate(*pi)->_message)free((_IdImaPrivate(*pi)->_message)); 00301 _IdImaPrivate(*pi)->_message=0; 00302 if(_IdImaPrivate(*pi)->_fichier)free((_IdImaPrivate(*pi)->_fichier)); 00303 _IdImaPrivate(*pi)->_fichier=0; 00304 free(_IdImaPrivate(*pi)); 00305 *pi=0; 00306 } 00307 } 00308 00309 /* FUNCTION DESCRIPTION ************************************************** 00310 00311 IdImaArrayToImage (fonction) 00312 00313 RESUME: Alloc d'1 im a partir d'1 tableau 2D SANS duplication de pixels 00314 00315 DESCRIPTION: Allocation d'une image a partir d'un tableau 2D SANS duplication des pixels 00316 ATTENTION: Le tableau d'origine ne doit en aucun cas etre liberee 00317 avant l'image. En effet l'information pixel n'est pas 00318 dupliquee. Les modifications de l'image sont faites dans 00319 la zone correspondante du tableau d'origine. 00320 Cette fonction peut donc etre tres utile pour transformer un 00321 tableau 2D en une image Libido sans recopier les pixels. 00322 00323 SYNTAXE: PPIMAGE image = IdImaArrayToImage (void ** tab2D, int lx, int ly); 00324 00325 RETOUR: type : PPIMAGE 00326 role : Pointeur vers l'image resultat. Zero si echec. 00327 00328 PARAMETRES: nom : tab2D 00329 type : void ** 00330 role : Pointeur vers l'image source 00331 00332 nom : lx, ly 00333 type : int 00334 role : Taille en X et Y du tableau 00335 00336 FICHIER: imapart.c 00337 00338 EXEMPLE: 00339 00340 ******************************************************** END DESCRIPTION */ 00341 00354 PPIMAGE IdImaArrayToImage ( tab2D, ty, dimx , dimy ) 00355 void ** tab2D; 00356 int ty; /* type de donnees. ex : IMA_UCHAR... */ 00357 int dimx, dimy; 00358 { 00359 /* int x = dimx*IdTypeSize(ty); */ 00360 int j; 00361 PPIMAGE imd=NULL; 00362 PRIVATE_IMAGE * si; 00363 00364 if ( tab2D==0 ) { 00365 IdErrno = IDERR_POINTER_IS_NULL; 00366 return 0; 00367 } 00368 00369 si=(PRIVATE_IMAGE *)calloc(1, sizeof(PRIVATE_IMAGE)+dimy*sizeof(void *)); 00370 if(si){ 00371 si->DimX=dimx; 00372 si->DimY=dimy; 00373 si->Type=ty; 00374 imd = (PPIMAGE)&(si[1]); 00375 for ( j=0; j<dimy; j++ ) 00376 imd[j]= tab2D[j]; 00377 00378 } 00379 /* Calcul du resultat *****/ 00380 return imd; 00381 } 00382 00383 00384 00385 /* FUNCTION DESCRIPTION ************************************************** 00386 00387 IdImaVecteurToImage (fonction) 00388 00389 RESUME: Alloc d'1 im a partir d'1 tableau 1D SANS duplication de pixels 00390 00391 DESCRIPTION: Allocation d'une image a partir d'un tableau 1D SANS duplication des pixels 00392 ATTENTION: Le tableau 1D d'origine ne doit en aucun cas etre libere 00393 avant l'image. En effet l'information pixel n'est pas 00394 dupliquee. Les modifications de l'image sont faites dans 00395 la zone correspondante du tableau d'origine. 00396 Cette fonction peut donc etre tres utile pour transformer un 00397 tableau 1D en une image Libido sans recopier les pixels. 00398 00399 SYNTAXE: PPIMAGE image = IdImaVecteurToImage ( void tableau1D[], int type, int dimx, int dimy); 00400 00401 RETOUR: type : PPIMAGE 00402 role : Pointeur vers l'image resultat. Zero si echec. 00403 00404 PARAMETRES: 00405 nom : tableau1D 00406 type : tableau 00407 role : Vecteur de valeurs 00408 00409 nom : type 00410 type : int 00411 role : Type LibIDO des donnees 00412 00413 nom : dimx, dimy 00414 type : int 00415 role : Taille en X et Y de l'image 00416 00417 FICHIER: imapart.c 00418 00419 ******************************************************** END DESCRIPTION */ 00420 00433 PPIMAGE IdImaVecteurToImage ( tab1D, ty, dimx , dimy ) 00434 void *tab1D; 00435 int ty; /* type de donnees: IMA_UCHAR... */ 00436 int dimx, dimy; 00437 { 00438 int lgLig = dimx*IdTypeSize(ty); 00439 int j; 00440 PPIMAGE imd=NULL; 00441 PRIVATE_IMAGE * si; 00442 00443 if ( tab1D==0 ) { 00444 IdErrno = IDERR_POINTER_IS_NULL; 00445 return 0; 00446 } 00447 00448 /* controler que NX * NY <= lgr vecteur .... JPR */ 00449 00450 00451 si=(PRIVATE_IMAGE *)calloc(1, sizeof(PRIVATE_IMAGE)+dimy*sizeof(void *)); 00452 if(si){ 00453 si->DimX=dimx; 00454 si->DimY=dimy; 00455 si->Type= (unsigned short)ty; 00456 imd = (PPIMAGE)&(si[1]); 00457 00458 for ( j=0; j<dimy; j++ ) 00459 imd[j]=(char *)tab1D + j*lgLig; 00460 00461 } 00462 return imd; 00463 } 00464 /***************************************************/ 00465 00466 /* FUNCTION DESCRIPTION ************************************************** 00467 00468 IdImaVecteurToImageOffset (fonction) 00469 00470 RESUME: Alloc d'1 im a partir d'une portion d'1 tableau 1D SANS duplication de pixels avec saut entete 00471 00472 DESCRIPTION: Allocation d'une image a partir d'une portion d'un tableau 1D SANS duplication des pixels avec saut entete 00473 00474 ATTENTION: L'image d'origine ne doit en aucun cas etre liberee 00475 avant ce tableau. En effet l'information pixel n'est pas 00476 dupliquee. Les modifications de l'image sont faites dans 00477 la zone correspondante du tableau d'origine. 00478 Cette fonction peut donc etre tres utile pour transformer un 00479 tableau 1D en une image Libido sans recopier les pixels. 00480 00481 SYNTAXE: PPIMAGE image = IdImaVecteurToImageOffset ( void tableau1D[], int type, int dimx, int dimy, int offset); 00482 00483 RETOUR: type : PPIMAGE 00484 role : Pointeur vers l'image resultat. Zero si echec. 00485 00486 PARAMETRES: 00487 nom : tableau1D 00488 type : void * 00489 role : Vecteur de valeurs 00490 00491 nom : type 00492 type : int 00493 role : Type LibIDO des donnees 00494 00495 nom : dimx, dimy 00496 type : int 00497 role : Taille en X et Y de l'image 00498 00499 nom : offset 00500 type : int 00501 role : Nombre d'elements du tableau que l'on veut 'sauter' 00502 pour fabriquer le Signal 00503 00504 FICHIER: imapart.c 00505 00506 ******************************************************** END DESCRIPTION */ 00507 00522 PPIMAGE IdImaVecteurToImageOffset ( tab1D, ty, dimx , dimy, offset ) 00523 void *tab1D; 00524 int ty; /* type de donnees: IMA_UCHAR... */ 00525 int dimx, dimy; 00526 int offset; 00527 { 00528 /* int x = dimx*IdTypeSize(ty); */ 00529 int j; 00530 PPIMAGE imd=0; 00531 PRIVATE_IMAGE * si; 00532 00533 if ( tab1D==0 ) { 00534 IdErrno = IDERR_POINTER_IS_NULL; 00535 return 0; 00536 } 00537 00538 /* controler que NX * NY <= lgr vecteur .... JPR */ 00539 00540 si=(PRIVATE_IMAGE *)calloc(1, sizeof(PRIVATE_IMAGE)+dimy*sizeof(void *)); 00541 if(si){ 00542 si->DimX=dimx; 00543 si->DimY=dimy; 00544 si->Type=(unsigned short)ty; 00545 imd = (PPIMAGE)&(si[1]); 00546 00547 for ( j=0; j<dimy; j++ ){ 00548 /* ou n'importe quoi * */ 00549 imd[j]=(char *)tab1D +offset + j*IdTypeSize(ty)*dimx;} 00550 } 00551 00552 return imd; 00553 } 00554 00555 /* FUNCTION DESCRIPTION ************************************************** 00556 00557 IdImaExtractSubImage (fonction) 00558 00559 RESUME: Extrait d'1 im. a partir d'1 portion d'1 autre image 00560 00561 DESCRIPTION: Extraction (AVEC dupplication des pixels) d'une image a partir 00562 d'une portion d'une autre image. 00563 Si l'image a extraire est deja alouee, elle devra 00564 avoir la bonne taille. 00565 00566 SYNTAXE: PPIMAGE sousImage = IdImaExtractSubImage (PPIMAGE ims, PPIMAGE sousImage, int ox, int oy, int lx, int ly); 00567 00568 RETOUR: type : PPIMAGE 00569 role : Pointeur vers l'image resultat. Zero si echec. 00570 00571 PARAMETRES: nom : ims 00572 type : PPIMAGE 00573 role : Pointeur vers l'image source 00574 00575 nom : sousImage 00576 type : PPIMAGE 00577 role : Pointeur vers le sous-image 00578 00579 nom : ox, oy 00580 type : int 00581 role : Origine en X et Y de la sous-image. 00582 00583 nom : lx, ly 00584 type : int 00585 role : Taille en X et Y de la sous-image. 00586 00587 FICHIER: imapart.c 00588 00589 EXEMPLE: if ( (imss=IdImaExtractSubImage(ims,0,0,10,10))==0 ) 00590 IdErrPrintf("ERREUR: %s",IdErrMsg(IdErrno)); 00591 / * Filtrage median sur la sous-image * / 00592 imr = IdImaMedian(imss,imr,5); 00593 IdImaFree(imss); 00594 00595 ******************************************************** END DESCRIPTION */ 00596 00613 PPIMAGE IdImaExtractSubImage ( im, sousImRes, ox, oy, lx, ly ) 00614 PPIMAGE im; 00615 PPIMAGE sousImRes; 00616 int ox, oy; 00617 int lx, ly; 00618 { 00619 PPIMAGE sousIm; 00620 00621 if ( (ox < 0) || (ox+lx>IdImaDimX(im)) || (lx<=0) ) { 00622 IdErrno = IDERR_X_OUT_OF_IMAGE; 00623 return NULL; 00624 } 00625 if ( (oy < 0) || (oy+ly>IdImaDimY(im)) || (ly<=0) ) { 00626 IdErrno = IDERR_Y_OUT_OF_IMAGE; 00627 return NULL; 00628 } 00629 if ( im==0 ) { 00630 IdErrno = IDERR_POINTER_IS_NULL; 00631 return 0; 00632 } 00633 00634 if ( IdLibidoType(im) != IMA) { 00635 IdErrno = IDERR_WRONG_TYPE; 00636 return(PPIMAGE)NULL; 00637 } 00638 00639 sousIm=IdImaAllocSubImage(im, ox, oy, lx, ly ); 00640 if(!sousIm) { IdErrno = IDERR_ALLOC_SUB; 00641 return NULL; /* positionner IdErrNo... */ 00642 } 00643 00644 /* Si sousImRes n'existe pas, on l'alloue meme taille/type que sousIm */ 00645 00646 sousImRes=(PPIMAGE) IdImaCheckTypeAllocSize (sousIm,-1,sousImRes,lx,ly); 00647 00648 if (!sousImRes){ IdErrPrintf ("Impossible Allouer Sous-Image\n"); 00649 /* IdErrno positionne par IdImaCheckTypeSizeAlloc */ 00650 return NULL; 00651 } 00652 00653 sousImRes=IdImaCopy(sousIm,sousImRes); 00654 00655 /* 00656 JAMAIS d'erreur, car filtree par IdImaCheckTypeSizeAlloc 00657 */ 00658 00659 IdImaFreeSubImage(sousIm); 00660 return (sousImRes); 00661 } 00662 00663 /* FUNCTION DESCRIPTION ************************************************** 00664 00665 IdImaSignalFromLine (fonction) 00666 00667 RESUME: Alloc d'1 SIGNAL a partir d'1 portion de ligne (+rapide que recopie des pixels) 00668 00669 DESCRIPTION: Alloc d'1 SIGNAL a partir d'1 portion de ligne (+rapide que recopie des pixels). 00670 Le Signal sera alloue avec le meme type LibIDO que l'image. 00671 00672 SYNTAXE: PSIGNAL signal = IdImaSignalFromLine (PPIMAGE ims, int ox, int oy, int lx); 00673 00674 RETOUR: type : PSIGNAL 00675 role : Pointeur vers le SIGNAL resultat. Zero si echec. 00676 00677 PARAMETRES: nom : ims 00678 type : PPIMAGE 00679 role : Pointeur vers l'image source 00680 00681 nom : ox, oy 00682 type : int 00683 role : Origine en X et Y du SIGNAL. 00684 00685 nom : lx, ly 00686 type : int 00687 role : Longueurdu SIGNAL 00688 00689 FICHIER: imapart.c 00690 00691 EXEMPLE: 00692 00693 ******************************************************** END DESCRIPTION */ 00694 00695 PSIGNAL IdImaSignalFromLine ( im, ox, oy, lx ) 00696 PPIMAGE im; 00697 int ox, oy; 00698 int lx; 00699 { 00700 int x; 00701 00702 PPIMAGE_UCHAR ims = (PPIMAGE_UCHAR)im; 00703 PSIGNAL_UCHAR imd = NULL; 00704 PRIVATE_SIGNAL * si; 00705 00706 if ( im==0 ) { 00707 IdErrno = IDERR_POINTER_IS_NULL; 00708 return 0; 00709 } 00710 00711 if ( IdLibidoType(im) != IMA) { 00712 IdErrno = IDERR_WRONG_TYPE; 00713 return(PPIMAGE)0; 00714 } 00715 00716 if ( (ox < 0) || (ox+lx>IdImaDimX(im)) || (lx<=0) ) { 00717 IdErrno = IDERR_X_OUT_OF_IMAGE; 00718 return 0; 00719 } 00720 00721 if (oy < 0) { 00722 IdErrno = IDERR_Y_OUT_OF_IMAGE; 00723 return 0; 00724 } 00725 00726 x = ox*IdSizeOfType(im); 00727 00728 si=(PRIVATE_SIGNAL *)calloc (1,sizeof(PRIVATE_SIGNAL)+lx*IdSizeOfType(im)); 00729 if(si){ 00730 si->DimX=si->UsedNbX=lx; 00731 si->Type=IdLibidoDataType(im) | SIG; 00732 imd = (PSIGNAL_UCHAR)&(si[1]); 00733 memcpy(imd,ims[oy]+x,lx*IdSizeOfType(im)); 00734 IdSetFileName(imd,IdGetFileName(ims)); 00735 } 00736 00737 else IdErrno = IDERR_POINTER_IS_NULL; /* a mettre le bon code */ 00738 00739 /* Calcul du resultat *****/ 00740 return (PSIGNAL) imd; 00741 } 00742 00743 /* FUNCTION DESCRIPTION ************************************************** 00744 00745 IdImaReuseSigFromLine (fonction) 00746 00747 RESUME: Copie d'un morceau de ligne d'une image dans un signal deja alloue 00748 00749 DESCRIPTION: remplissage d'1 SIGNAL a partir d'1 portion de ligne (plus rapide 00750 que copie pixel a pixel) 00751 00752 SYNTAXE: PSIGNAL signal = IdImaReuseSigFromLine (PPIMAGE ims, int ox, int oy, PSIGNAL sig); 00753 00754 RETOUR: type : PSIGNAL 00755 role : Pointeur vers le SIGNAL resultat. Zero si echec. 00756 00757 PARAMETRES: nom : ims 00758 type : PPIMAGE 00759 role : Pointeur vers l'image source 00760 00761 nom : ox, oy 00762 type : int 00763 role : Origine en X et Y du SIGNAL. 00764 00765 nom : sig 00766 type : PSIGNAL 00767 role : signal a remplir 00768 00769 FICHIER: imapart.c 00770 00771 00772 ******************************************************** END DESCRIPTION */ 00773 00774 PSIGNAL IdImaReuseSigFromLine ( im, ox, oy, sig ) 00775 PPIMAGE im; 00776 PSIGNAL sig; 00777 int ox, oy; 00778 { 00779 /* JPR ?? */ 00780 /* 00781 PPIMAGE_UCHAR ims = (PPIMAGE_UCHAR)im; 00782 PSIGNAL_UCHAR sigs = (PSIGNAL_UCHAR)sig; 00783 */ 00784 int x; 00785 00786 if ( im==0 || sig==0) { 00787 IdErrno = IDERR_POINTER_IS_NULL; 00788 return(PSIGNAL)0; 00789 } 00790 00791 if ( (IdLibidoType(im) != IMA) || (IdLibidoType(sig) != SIG) 00792 || (IdLibidoDataType(im)!=IdLibidoDataType(sig))) { 00793 IdErrno = IDERR_WRONG_TYPE; 00794 return(PSIGNAL)0; 00795 } 00796 00797 if ( (ox < 0) || ((ox+IdSigDimX(sig))>IdImaDimX(im)) ) { 00798 IdErrno = IDERR_X_OUT_OF_IMAGE; 00799 return 0; 00800 } 00801 00802 if ( (oy < 0) || (oy>=IdImaDimY(im)) ) { 00803 IdErrno = IDERR_Y_OUT_OF_IMAGE; 00804 return(PSIGNAL)0; 00805 } 00806 x = ox*IdSizeOfType(im); 00807 memcpy(sig,(char *)im[oy]+x*IdSizeOfType(im),IdSigDimX(sig)*IdSizeOfType(im)); 00808 IdSetFileName(sig,IdGetFileName(im)); 00809 00810 return (PSIGNAL) sig; 00811 } 00812

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