00001
00017 #include "vetFilterGeometric.h"
00018 #include <math.h>
00019
00020
00025 vetFilterGeometric::vetFilterGeometric(vetFilterGeometricParameters* initParams) : vetFilter()
00026 {
00027 INFO("vetFilterGeometric::vetFilterGeometric(..* initParams) : vetFilter() [CONTRUCTOR]")
00028 myParams = NULL;
00029 setParameters(initParams);
00030
00031 setName("Geometric Editing Filter");
00032 setDescription("Resize, Crop, Rotation, Flip");
00033 setVersion(1.0);
00034 }
00035
00039 vetFilterGeometric::~vetFilterGeometric()
00040 {
00041 INFO("vetFilterGeometric::~vetFilterGeometric() [DESTRUCTOR]")
00042
00043 printf("vetFilterGeometric::~vetFilterGeometric() [DESTRUCTOR]");
00044
00045
00046 if (myParams != NULL)
00047 delete myParams;
00048 myParams = NULL;
00049 }
00050
00056 VETRESULT vetFilterGeometric::reset()
00057 {
00058 INFO("VETRESULT vetFilterGeometric::reset() [SET DEFAULT PARAMETERS]")
00059
00060 releaseBuffers();
00061
00062 if (myParams != NULL)
00063 {
00064 myParams->reset();
00065 allocateBuffer(myParams->currentBuffer);
00066 }
00067 else
00068 setParameters(NULL);
00069
00070 return VETRET_OK;
00071 }
00072
00082 VETRESULT vetFilterGeometric::setParameters (vetFilterGeometricParameters* initParams)
00083 {
00084 if (initParams != NULL && myParams == initParams)
00085 return VETRET_PARAM_ERR;
00086
00087 if ( initParams == NULL )
00088 {
00089 if ( myParams != NULL )
00090 reset();
00091 else
00092 myParams = new vetFilterGeometricParameters();
00093 }
00094 else
00095 {
00096 if ( myParams != NULL )
00097 delete myParams;
00098
00099 myParams = initParams;
00100 }
00101
00102 allocateBuffer(myParams->currentBuffer);
00103
00104 return VETRET_OK;
00105 }
00106
00107
00118 VETRESULT vetFilterGeometric::importFrom(vetFrameYUV420& img)
00119 {
00120 DEBUGMSG("VETRESULT vetFilterGeometric::importFrom(vetFrameYUV420& img) [reading data]", myParams->runMode)
00121
00122 switch ( myParams->runMode )
00123 {
00124 case vetFilterGeometricParameters::DO_NOTHING:
00125 if ( !isBufferYUV() )
00126 {
00127 useBufferYUV(img.width, img.height);
00128 *bufferYUV = img;
00129 return VETRET_OK_DEPRECATED;
00130 }
00131 else
00132 {
00133 *bufferYUV = img;
00134 return VETRET_OK;
00135 }
00136
00137 case vetFilterGeometricParameters::ROTATE90:
00138 return rotate90(img);
00139
00140 case vetFilterGeometricParameters::ROTATE180:
00141 return rotate180(img);
00142
00143 case vetFilterGeometricParameters::ROTATE270:
00144 return rotate270(img);
00145
00146 case vetFilterGeometricParameters::ROTATE:
00147 return rotate( img, myParams->par_Rotation );
00148
00149 case vetFilterGeometricParameters::FLIP_VERTICAL:
00150 return flipVertical(img);
00151
00152 case vetFilterGeometricParameters::FLIP_HORIZONTAL:
00153 return flipHorizontal(img);
00154
00155 case vetFilterGeometricParameters::RESIZE:
00156 return resize( img, myParams->par_ResizeWidth, myParams->par_ResizeHeight );
00157
00158 case vetFilterGeometricParameters::RESIZECANVAS:
00159 return resizeCanvas( img, myParams->par_ResizeWidth, myParams->par_ResizeHeight );
00160
00161 default:
00162 return VETRET_PARAM_ERR;
00163 }
00164 }
00165
00176 VETRESULT vetFilterGeometric::importFrom(vetFrameRGB24& img)
00177 {
00178 DEBUGMSG("VETRESULT vetFilterGeometric::importFrom(vetFrameRGB24& img) [reading data]", myParams->runMode)
00179
00180 switch ( myParams->runMode )
00181 {
00182 case vetFilterGeometricParameters::DO_NOTHING:
00183 if ( !isBufferRGB() )
00184 {
00185 useBufferRGB(img.width, img.height);
00186 *bufferRGB = img;
00187 return VETRET_OK_DEPRECATED;
00188 }
00189 else
00190 {
00191 *bufferRGB = img;
00192
00193 return VETRET_OK;
00194 }
00195
00196 case vetFilterGeometricParameters::ROTATE90:
00197 return rotate90(img);
00198
00199 case vetFilterGeometricParameters::ROTATE180:
00200 return rotate180(img);
00201
00202 case vetFilterGeometricParameters::ROTATE270:
00203 return rotate270(img);
00204
00205 case vetFilterGeometricParameters::ROTATE:
00206 return rotate( img, myParams->par_Rotation );
00207
00208 case vetFilterGeometricParameters::FLIP_VERTICAL:
00209 return flipVertical(img);
00210
00211 case vetFilterGeometricParameters::FLIP_HORIZONTAL:
00212 return flipHorizontal(img);
00213
00214 case vetFilterGeometricParameters::RESIZE:
00215 return resize( img, myParams->par_ResizeWidth, myParams->par_ResizeHeight );
00216
00217 case vetFilterGeometricParameters::RESIZECANVAS:
00218 return resizeCanvas( img, myParams->par_ResizeWidth, myParams->par_ResizeHeight );
00219
00220 default:
00221 return VETRET_PARAM_ERR;
00222 }
00223
00224 }
00225
00236 VETRESULT vetFilterGeometric::importFrom(vetFrameT<unsigned char>& img)
00237 {
00238 DEBUGMSG("VETRESULT vetFilterGeometric::importFrom(vetFrameT& img) [reading data]", myParams->runMode)
00239
00240 switch ( myParams->runMode )
00241 {
00242 case vetFilterGeometricParameters::DO_NOTHING:
00243 if ( !isBufferTuC() )
00244 {
00245 useBufferTuC(img.width, img.height, img.profile);
00246 *bufferTuC = img;
00247 return VETRET_OK_DEPRECATED;
00248 }
00249 else
00250 {
00251 *bufferTuC = img;
00252 return VETRET_OK;
00253 }
00254
00255 case vetFilterGeometricParameters::ROTATE90:
00256 return rotate90(img);
00257
00258 case vetFilterGeometricParameters::ROTATE180:
00259 return rotate180(img);
00260
00261 case vetFilterGeometricParameters::ROTATE270:
00262 return rotate270(img);
00263
00264 case vetFilterGeometricParameters::ROTATE:
00265 return rotate( img, myParams->par_Rotation );
00266
00267 case vetFilterGeometricParameters::FLIP_VERTICAL:
00268 return flipVertical(img);
00269
00270 case vetFilterGeometricParameters::FLIP_HORIZONTAL:
00271 return flipHorizontal(img);
00272
00273 case vetFilterGeometricParameters::RESIZE:
00274 return resize( img, myParams->par_ResizeWidth, myParams->par_ResizeHeight );
00275
00276 case vetFilterGeometricParameters::RESIZECANVAS:
00277 return resizeCanvas( img, myParams->par_ResizeWidth, myParams->par_ResizeHeight );
00278
00279 default:
00280 return VETRET_PARAM_ERR;
00281 }
00282
00283 }
00284
00285
00286
00287
00291
00292
00293
00294
00295
00296 VETRESULT vetFilterGeometric::resize(vetFrameYUV420& img, unsigned int dimX , unsigned int dimY)
00297 {
00298 useBufferYUV(dimX, dimY);
00299
00300 return VETRET_NOT_IMPLEMENTED;
00301 }
00302
00303 VETRESULT vetFilterGeometric::resize(vetFrameRGB24& img, unsigned int dimX , unsigned int dimY)
00304 {
00305 useBufferRGB(dimX, dimY);
00306
00307 float rx=(float)bufferRGB->width/(float)dimX;
00308 float ry=(float)bufferRGB->height/(float)dimY;
00309
00310 for ( unsigned int y=0; y < dimY; y++ )
00311 for ( unsigned int x=0; x < dimX; x++ )
00312 bufferRGB->data[y*bufferRGB->width+x] = img.data[(int)( ((float)x*rx) + ((float)y*ry * (float)img.width) )];
00313
00314 return VETRET_OK;
00315 }
00316
00317 VETRESULT vetFilterGeometric::resize(vetFrameT<unsigned char>& img, unsigned int dimX , unsigned int dimY)
00318 {
00319 useBufferTuC(dimX, dimY, img.profile);
00320
00321 return VETRET_NOT_IMPLEMENTED;
00322 }
00324
00325 VETRESULT vetFilterGeometric::resizeCanvas(vetFrameYUV420& img, unsigned int dimX, unsigned int dimY)
00326 {
00327 useBufferYUV(dimX, dimY);
00328
00329 return VETRET_NOT_IMPLEMENTED;
00330 }
00331
00332 VETRESULT vetFilterGeometric::resizeCanvas(vetFrameRGB24& img, unsigned int dimX, unsigned int dimY)
00333 {
00334 useBufferRGB(dimX, dimY);
00335
00336 for ( unsigned int y=0; y < img.height; y++ )
00337 for ( unsigned int x=0; x < img.width; x++ )
00338 bufferRGB->data[y*bufferRGB->width+x] = img.data[ y * img.width + x ];
00339
00340 return VETRET_OK;
00341 }
00342
00343 VETRESULT vetFilterGeometric::resizeCanvas(vetFrameT<unsigned char>& img, unsigned int dimX, unsigned int dimY)
00344 {
00345 useBufferTuC(dimX, dimY, img.profile);
00346
00347 return VETRET_NOT_IMPLEMENTED;
00348 }
00350
00351 VETRESULT vetFilterGeometric::resizeCanvas(vetFrameYUV420& img, unsigned int dimX, unsigned int dimY, unsigned char& valY, unsigned char& valU, unsigned char& valV)
00352 {
00353 useBufferYUV(dimX, dimY);
00354
00355 return VETRET_NOT_IMPLEMENTED;
00356 }
00357
00358
00359 VETRESULT vetFilterGeometric::resizeCanvas(vetFrameRGB24& img, unsigned int dimX, unsigned int dimY, PixelRGB24 background)
00360 {
00361 useBufferRGB(dimX, dimY);
00362
00363 PixelRGB24 bgRGB24((unsigned char)background[0], (unsigned char)background[1], (unsigned char)background[2] );
00364
00365 for ( unsigned int i=0; i < dimX * dimY; i++ )
00366 bufferRGB->data[i] = bgRGB24;
00367
00368 for ( unsigned int y=0; y < img.height; y++ )
00369 for ( unsigned int x=0; x < img.width; x++ )
00370 bufferRGB->data[y*bufferRGB->width+x] = img.data[ y * img.width + x ];
00371
00372 return VETRET_OK;
00373 }
00374
00375 VETRESULT vetFilterGeometric::resizeCanvas(vetFrameT<unsigned char>& img, unsigned int dimX, unsigned int dimY, unsigned char& val1, unsigned char& val2, unsigned char& val3)
00376 {
00377 useBufferTuC(dimX, dimY, img.profile);
00378
00379 return VETRET_NOT_IMPLEMENTED;
00380 }
00381
00383
00384 VETRESULT vetFilterGeometric::rotate90(vetFrameYUV420& img)
00385 {
00386 INFO("VETRESULT vetFilterGeometric::rotate90(vetFrameYUV420& img)")
00387
00388 useBufferYUV(img.height, img.width);
00389
00390 return VETRET_NOT_IMPLEMENTED;
00391 }
00392
00393 VETRESULT vetFilterGeometric::rotate90(vetFrameRGB24& img)
00394 {
00395 INFO("VETRESULT vetFilterGeometric::rotate90(vetFrameRGB24& img)")
00396
00397 useBufferRGB(img.height, img.width);
00398
00399 for ( unsigned int y=0; y < bufferRGB->height; y++ )
00400 for ( unsigned int x=0; x < bufferRGB->width; x++ )
00401 bufferRGB->data[(bufferRGB->width-1-x)*bufferRGB->height+y] = img.data[x*img.width + y];
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434 return VETRET_OK;
00435 }
00436
00437 VETRESULT vetFilterGeometric::rotate90(vetFrameT<unsigned char>& img)
00438 {
00439 INFO("VETRESULT vetFilterGeometric::rotate90(vetFrameT<unsigned char>& img)")
00440
00441 useBufferTuC(img.height, img.width, img.profile);
00442
00443 return VETRET_NOT_IMPLEMENTED;
00444 }
00445
00447
00448 VETRESULT vetFilterGeometric::rotate180(vetFrameYUV420& img)
00449 {
00450 INFO("VETRESULT vetFilterGeometric::rotate180(vetFrameYUV420& img)")
00451
00452 useBufferYUV(img.height, img.width);
00453
00454 return VETRET_NOT_IMPLEMENTED;
00455 }
00456
00457 VETRESULT vetFilterGeometric::rotate180(vetFrameRGB24& img)
00458 {
00459 INFO("VETRESULT vetFilterGeometric::rotate180(vetFrameRGB24& img)")
00460
00461 useBufferRGB(img.width, img.height);
00462
00463 for (unsigned int i=0; i < bufferRGB->width*bufferRGB->height; i++)
00464 bufferRGB->data[i] = img.data[img.width*img.height-1-i];
00465
00466 return VETRET_OK;
00467 }
00468
00469 VETRESULT vetFilterGeometric::rotate180(vetFrameT<unsigned char>& img)
00470 {
00471 INFO("VETRESULT vetFilterGeometric::rotate180(vetFrameT<unsigned char>& img)")
00472
00473 useBufferTuC(img.height, img.width, img.profile);
00474
00475 return VETRET_NOT_IMPLEMENTED;
00476 }
00478
00479 VETRESULT vetFilterGeometric::rotate270(vetFrameYUV420& img)
00480 {
00481 INFO("VETRESULT vetFilterGeometric::rotate270(vetFrameYUV420& img)")
00482
00483 useBufferYUV(img.height, img.width);
00484
00485 return VETRET_NOT_IMPLEMENTED;
00486 }
00487
00488 VETRESULT vetFilterGeometric::rotate270(vetFrameRGB24& img)
00489 {
00490 INFO("VETRESULT vetFilterGeometric::rotate270(vetFrameCach24e& img)")
00491
00492 useBufferRGB(img.height, img.width);
00493
00494 for ( unsigned int y=0; y < bufferRGB->height; y++ )
00495 for ( unsigned int x=0; x < bufferRGB->width; x++ )
00496 bufferRGB->data[(bufferRGB->height-1-y)*bufferRGB->width+x] = img.data[x*img.width + y];
00497
00498 return VETRET_OK;
00499 }
00500
00501 VETRESULT vetFilterGeometric::rotate270(vetFrameT<unsigned char>& img)
00502 {
00503 INFO("VETRESULT vetFilterGeometric::rotate270(vetFrameT<unsigned char>& img)")
00504
00505 useBufferTuC(img.height, img.width, img.profile);
00506
00507 return VETRET_NOT_IMPLEMENTED;
00508 }
00510
00511 VETRESULT vetFilterGeometric::rotate(vetFrameYUV420& img, float alpha)
00512 {
00513 unsigned int ex,ey;
00514 float ox,oy;
00515 float dx=(float) img.width;
00516 float dy=(float) img.height;
00517 float x1,x2,x3,x4,y1,y2,y3,y4;
00518 float xmin,xmax,ymin,ymax;
00519
00520 alpha*=(float)3.141592654/180;
00521
00522 x1=0.;
00523 x2=dx*cos(alpha);
00524 x3=dx*cos(alpha)-dy*sin(alpha);
00525 x4=-dy*sin(alpha);
00526 y1=0.;
00527 y2=dx*sin(alpha);
00528 y3=dy*cos(alpha)+dx*sin(alpha);
00529 y4=dy*cos(alpha);
00530
00531 xmin=x1;
00532 if (x2<xmin) xmin=x2;
00533 if (x3<xmin) xmin=x3;
00534 if (x4<xmin) xmin=x4;
00535 xmax=x1;
00536 if (x2>xmax) xmax=x2;
00537 if (x3>xmax) xmax=x3;
00538 if (x4>xmax) xmax=x4;
00539 ymin=y1;
00540 if (y2<ymin) ymin=y2;
00541 if (y3<ymin) ymin=y3;
00542 if (y4<ymin) ymin=y4;
00543 ymax=y1;
00544 if (y2>ymax) ymax=y2;
00545 if (y3>ymax) ymax=y3;
00546 if (y4>ymax) ymax=y4;
00547
00548 ex=(int)(xmax-xmin)+1;
00549 ey=(int)(ymax-ymin)+1;
00550
00551
00552 ox=xmin-x1;
00553 oy=ymin-y1;
00554
00555
00556 useBufferYUV(ex, ey);
00557
00558
00559 return VETRET_NOT_IMPLEMENTED;
00560 }
00561
00562 VETRESULT vetFilterGeometric::rotate(vetFrameRGB24& img, float alpha)
00563 {
00564 unsigned int ex,ey;
00565 float ox,oy;
00566 float dx=(float) img.width;
00567 float dy=(float) img.height;
00568 float x1,x2,x3,x4,y1,y2,y3,y4;
00569 float xmin,xmax,ymin,ymax;
00570
00571 alpha*=(float)3.141592654/180;
00572
00573 x1=0.;
00574 x2=dx*cos(alpha);
00575 x3=dx*cos(alpha)-dy*sin(alpha);
00576 x4=-dy*sin(alpha);
00577 y1=0.;
00578 y2=dx*sin(alpha);
00579 y3=dy*cos(alpha)+dx*sin(alpha);
00580 y4=dy*cos(alpha);
00581
00582 xmin=x1;
00583 if (x2<xmin) xmin=x2;
00584 if (x3<xmin) xmin=x3;
00585 if (x4<xmin) xmin=x4;
00586 xmax=x1;
00587 if (x2>xmax) xmax=x2;
00588 if (x3>xmax) xmax=x3;
00589 if (x4>xmax) xmax=x4;
00590 ymin=y1;
00591 if (y2<ymin) ymin=y2;
00592 if (y3<ymin) ymin=y3;
00593 if (y4<ymin) ymin=y4;
00594 ymax=y1;
00595 if (y2>ymax) ymax=y2;
00596 if (y3>ymax) ymax=y3;
00597 if (y4>ymax) ymax=y4;
00598
00599 ex=(int)(xmax-xmin)+1;
00600 ey=(int)(ymax-ymin)+1;
00601
00602
00603 ox=xmin-x1;
00604 oy=ymin-y1;
00605
00606
00607 useBufferRGB(ex, ey);
00608
00609
00610 float cc=cos(-alpha);
00611 float ss=sin(-alpha);
00612
00613 for ( unsigned int y=0; y < ey; y++ )
00614 for ( unsigned int x=0; x < ex; x++ )
00615 bufferRGB->data[y*bufferRGB->width+x] = img.data[(int)( (( (float)(y+oy)*cc+(float)(x+ox)*ss) * img.width) + ((float)(x+ox)*cc-(float)(y+oy)*ss) )];
00616
00617 return VETRET_OK;
00618 }
00619
00620 VETRESULT vetFilterGeometric::rotate(vetFrameT<unsigned char>& img, float alpha)
00621 {
00622 unsigned int ex,ey;
00623 float ox,oy;
00624 float dx=(float) img.width;
00625 float dy=(float) img.height;
00626 float x1,x2,x3,x4,y1,y2,y3,y4;
00627 float xmin,xmax,ymin,ymax;
00628
00629 alpha*=(float)3.141592654/180;
00630
00631 x1=0.;
00632 x2=dx*cos(alpha);
00633 x3=dx*cos(alpha)-dy*sin(alpha);
00634 x4=-dy*sin(alpha);
00635 y1=0.;
00636 y2=dx*sin(alpha);
00637 y3=dy*cos(alpha)+dx*sin(alpha);
00638 y4=dy*cos(alpha);
00639
00640 xmin=x1;
00641 if (x2<xmin) xmin=x2;
00642 if (x3<xmin) xmin=x3;
00643 if (x4<xmin) xmin=x4;
00644 xmax=x1;
00645 if (x2>xmax) xmax=x2;
00646 if (x3>xmax) xmax=x3;
00647 if (x4>xmax) xmax=x4;
00648 ymin=y1;
00649 if (y2<ymin) ymin=y2;
00650 if (y3<ymin) ymin=y3;
00651 if (y4<ymin) ymin=y4;
00652 ymax=y1;
00653 if (y2>ymax) ymax=y2;
00654 if (y3>ymax) ymax=y3;
00655 if (y4>ymax) ymax=y4;
00656
00657 ex=(int)(xmax-xmin)+1;
00658 ey=(int)(ymax-ymin)+1;
00659
00660
00661 ox=xmin-x1;
00662 oy=ymin-y1;
00663
00664
00665 useBufferTuC(ex, ey, img.profile);
00666
00667
00668 return VETRET_NOT_IMPLEMENTED;
00669 }
00670
00672
00673 VETRESULT vetFilterGeometric::flipHorizontal(vetFrameYUV420& img)
00674 {
00675 INFO("VETRESULT vetFilterGeometric::flipHorizontal(vetFrameYUV420& img)")
00676
00677 useBufferYUV(img.width, img.height);
00678
00679 return VETRET_NOT_IMPLEMENTED;
00680 }
00681
00682 VETRESULT vetFilterGeometric::flipHorizontal(vetFrameRGB24& img)
00683 {
00684 INFO("VETRESULT vetFilterGeometric::flipHorizontal(vetFrameRGB24& img)")
00685
00686 useBufferRGB(img.width, img.height);
00687
00688 for ( unsigned int y=0; y < bufferRGB->height; y++ )
00689 for ( unsigned int x=0; x < bufferRGB->width; x++ )
00690 bufferRGB->data[x+y*bufferRGB->width] = img.data[y*img.width + (img.width-1)-x];
00691
00692 return VETRET_OK;
00693 }
00694
00695 VETRESULT vetFilterGeometric::flipHorizontal(vetFrameT<unsigned char>& img)
00696 {
00697 INFO("VETRESULT vetFilterGeometric::flipHorizontal(vetFrameT<unsigned char>& img)")
00698
00699 useBufferTuC(img.width, img.height, img.profile);
00700
00701 return VETRET_NOT_IMPLEMENTED;
00702 }
00703
00705
00706 VETRESULT vetFilterGeometric::flipVertical(vetFrameYUV420& img)
00707 {
00708 INFO("VETRESULT vetFilterGeometric::flipVertical(vetFrameYUV420& img)")
00709
00710 useBufferYUV(img.width, img.height);
00711
00712 return VETRET_NOT_IMPLEMENTED;
00713 }
00714
00715 VETRESULT vetFilterGeometric::flipVertical(vetFrameRGB24& img)
00716 {
00717 INFO("VETRESULT vetFilterGeometric::flipVertical(vetFrameRGB24& img)")
00718
00719 useBufferRGB(img.width, img.height);
00720
00721 for ( unsigned int i=0; i < bufferRGB->height; i++ )
00722 memcpy( &bufferRGB->data[i*bufferRGB->width], &img.data[(bufferRGB->height-i-1)*bufferRGB->width], bufferRGB->width * sizeof(PixelRGB24) );
00723
00724
00725 return VETRET_OK;
00726 }
00727
00728 VETRESULT vetFilterGeometric::flipVertical(vetFrameT<unsigned char>& img)
00729 {
00730 INFO("VETRESULT vetFilterGeometric::flipVertical(vetFrameT<unsigned char>& img)")
00731
00732 useBufferTuC(img.width, img.height, img.profile);
00733
00734 return VETRET_NOT_IMPLEMENTED;
00735 }
00736
00738
00739
00740
00741
00743
00744
00745
00746
00747
00748
00750
00751
00752
00753
00754
00755 vetFilterGeometricParameters::vetFilterGeometricParameters(RUNMODE mode) : vetFilterParameters()
00756 {
00757 runMode = mode;
00758 }
00759
00760 void vetFilterGeometricParameters::reset()
00761 {
00762 runMode = vetFilterGeometricParameters::DO_NOTHING;
00763 par_Rotation = 0;
00764 par_ResizeWidth = 0;
00765 par_ResizeHeight = 0;
00766 par_forzeSize = false;
00767 currentBuffer = vetFilterParameters::NONE;
00768 }
00769
00770 int vetFilterGeometricParameters::saveToStreamXML(FILE *fp)
00771 {
00772
00773 if ( fp == NULL )
00774 return VETRET_PARAM_ERR;
00775
00776 if( fprintf(fp, "<vetFilterGeometricParameters>\n") == EOF )
00777 return VETRET_INTERNAL_ERR;
00778
00779 if ( fprintf(fp, " <runmode value=\"%i\" />\n", (int)runMode) == EOF)
00780 return VETRET_INTERNAL_ERR;
00781
00782 if ( fprintf(fp, " <rotation value=\"%f\" />\n", par_Rotation) == EOF)
00783 return VETRET_INTERNAL_ERR;
00784
00785 if ( fprintf(fp, " <resize width=\"%u\" height=\"%u\" />\n", par_ResizeWidth, par_ResizeHeight) == EOF)
00786 return VETRET_INTERNAL_ERR;
00787
00788 if ( fprintf(fp, " <forzeSize value=\"%u\" />\n", (int)par_forzeSize) == EOF)
00789 return VETRET_INTERNAL_ERR;
00790
00791 if ( fprintf(fp, " <internalBufferType value=\"%u\" />\n", (int)currentBuffer) == EOF)
00792 return VETRET_INTERNAL_ERR;
00793
00794 if( fprintf(fp, "</vetFilterGeometricParameters>\n") == EOF )
00795 return VETRET_INTERNAL_ERR;
00796
00797 return VETRET_OK;
00798 }
00799
00800
00801 int vetFilterGeometricParameters::loadFromStreamXML(FILE *fp)
00802 {
00803 if ( fscanf(fp, "<vetFilterGeometricParameters>\n") == EOF )
00804 throw "error in XML file, unable to import data.";
00805
00806 int runTmp = 0;
00807 if ( fscanf(fp, " <runmode value=\"%i\" />\n", &runTmp) == EOF )
00808 throw "error in XML file, unable to import data.";
00809 else
00810 runMode = (RUNMODE)runTmp;
00811
00812 if ( fscanf(fp, " <rotation value=\"%f\" />\n", &par_Rotation) == EOF )
00813 throw "error in XML file, unable to import data.";
00814
00815 if ( fscanf(fp, " <resize width=\"%u\" height=\"%u\" />\n", &par_ResizeWidth, &par_ResizeHeight) == EOF )
00816 throw "error in XML file, unable to import data.";
00817
00818 int boolTmp = 0;
00819 if ( fscanf(fp, " <forzeSize value=\"%u\" />\n", &boolTmp) == EOF )
00820 throw "error in XML file, unable to import data.";
00821
00822 if (boolTmp == 0)
00823 par_forzeSize = false;
00824 else
00825 par_forzeSize = true;
00826
00827 int cB = (int)currentBuffer;
00828 if ( fscanf(fp, " <internalBufferType value=\"%u\" />\n", &cB) == EOF )
00829 throw "error in XML file, unable to import data.";
00830 currentBuffer = (BUFFER_TYPE)cB;
00831
00832 return VETRET_OK;
00833 }
00834
00835
00836
00837