00001
00019 #include "vetCodec_BMP.h"
00020
00021 #include <new>
00022
00023 #include <string.h>
00024 #include "external_BMP/MicrosoftBMP_RT.h"
00025 #include "external_BMP/MicrosoftRCBMP_RT.h"
00026 #include "external_BMP/MicrosoftMonoBMP_RT.h"
00027
00028
00029
00030 #include <stdlib.h>
00031
00032
00033
00034 vetCodec_BMP::vetCodec_BMP(char *filename, FileFormat format) : vetFrameRGB96(), vetCodec()
00043 {
00044 DEBUGMSG("vetCodec_BMP::vetCodec_BMP(char *filename, FileFormat format) [CONTRUCTOR] ", *filename)
00045
00046 myParams = NULL;
00047 reset();
00048 setParameters(NULL);
00049
00050 load( filename, format );
00051
00052 strcpy(myParams->fileNameBase, filename);
00053 myParams->fileFormat = format;
00054 }
00055
00056 vetCodec_BMP::vetCodec_BMP( vetCodec_BMPParameters* initParams ) : vetFrameRGB96(), vetCodec()
00057 {
00058 DEBUGMSG("vetCodec_BMP::vetCodec_BMP(vetCodec_BMPParameters* initParams) [CONTRUCTOR] ", *filename)
00059
00060 myParams = NULL;
00061 reset();
00062 setParameters(initParams);
00063 }
00064
00065 VETRESULT vetCodec_BMP::reset()
00066 {
00067 INFO("VETRESULT vetCodec_BMP::reset() [SET DEFAULT PARAMETERS]")
00068
00069 setName("Bitmap Coder");
00070 setDescription("Read or write images to bitmap format.");
00071 setVersion(1.0);
00072
00073 if (myParams != NULL)
00074 {
00075 myParams->reset();
00076 strcpy(fileNameBuffer, myParams->fileNameBase);
00077 }
00078
00079 height = 0;
00080 width = 0;
00081
00082
00083 if ( data != NULL )
00084
00085 delete [] data;
00086 data = NULL;
00087
00088 return VETRET_OK;
00089 }
00090
00091 bool vetCodec_BMP::EoF()
00092 {
00093 if (data == NULL)
00094 return true;
00095 return false;
00096 }
00097
00098 VETRESULT vetCodec_BMP::setParameters (vetCodec_BMPParameters* initParams)
00099 {
00100
00101 if ( initParams == NULL )
00102 myParams = new vetCodec_BMPParameters();
00103 else
00104 myParams = initParams;
00105
00106 return VETRET_OK;
00107 }
00108 VETRESULT vetCodec_BMP::setFilterParameters (vetFilterParameters* initParams) { return setParameters(static_cast<vetCodec_BMPParameters*>(initParams)); };
00109 vetFilterParameters* vetCodec_BMP::getFilterParameters () { return static_cast<vetFilterParameters*>(myParams); };
00110
00111
00112 VETRESULT vetCodec_BMP::extractTo(vetFrameYUV420& img)
00113 {
00114 DEBUGMSG("VETRESULT vetCodec_BMP::extractTo(vetFrameYUV420& img) [pushing data]", doBuffering)
00115
00116 int ret = VETRET_OK;
00117
00118 if ( myParams->autoOuput && !myParams->doBuffering )
00119 {
00120 doFileNameCurrent();
00121
00122
00123 ret = load(img, fileNameBuffer, myParams->fileFormat);
00124
00125 if ( myParams->fileNameProgression )
00126 myParams->fileNameIndex++;
00127
00128 return ret;
00129 }
00130
00131 if ( myParams->autoInput )
00132 {
00133 doFileNameCurrent();
00134
00135 ret = load(fileNameBuffer, myParams->fileFormat);
00136
00137 if ( myParams->fileNameProgression )
00138 myParams->fileNameIndex++;
00139 }
00140
00141
00142 vetFrameRGB96::operator >> (img);
00143
00144 return ret;
00145 }
00146
00147 VETRESULT vetCodec_BMP::extractTo(vetFrameRGB24& img)
00148 {
00149 DEBUGMSG("VETRESULT vetCodec_BMP::extractTo(vetFrameRGB24& img) [pushing data]", doBuffering)
00150
00151 int ret = VETRET_OK;
00152
00153 if ( myParams->autoOuput && !myParams->doBuffering )
00154 {
00155 doFileNameCurrent();
00156
00157
00158 ret = load(img, fileNameBuffer, myParams->fileFormat);
00159
00160 if ( myParams->fileNameProgression )
00161 myParams->fileNameIndex++;
00162
00163 return ret;
00164 }
00165
00166 if ( myParams->autoInput )
00167 {
00168 doFileNameCurrent();
00169
00170 ret = load(fileNameBuffer, myParams->fileFormat);
00171
00172 if ( myParams->fileNameProgression )
00173 myParams->fileNameIndex++;
00174 }
00175
00176
00177 vetFrameRGB96::operator >> (img);
00178
00179 return ret;
00180 }
00181
00182
00183 VETRESULT vetCodec_BMP::extractTo(vetFrameT<unsigned char>& img)
00184 {
00185 DEBUGMSG("VETRESULT vetCodec_BMP::extractTo(vetFrameT& img) [pushing data]", doBuffering)
00186
00187 return VETRET_NOT_IMPLEMENTED;
00188 }
00189
00190
00191
00192 VETRESULT vetCodec_BMP::importFrom(vetFrameYUV420& img)
00193 {
00194 DEBUGMSG("VETRESULT vetCodec_BMP::importFrom(vetFrameYUV420& img) [reading data]", doBuffering)
00195
00196 int ret = VETRET_OK;
00197
00198 if ( myParams->autoOuput && !myParams->doBuffering )
00199 {
00200 doFileNameCurrent();
00201
00202 ret = save(img, fileNameBuffer, myParams->fileFormat);
00203
00204 if ( myParams->fileNameProgression )
00205 myParams->fileNameIndex++;
00206
00207 return ret;
00208 }
00209
00210 vetFrameRGB96::operator << (img);
00211
00212 if ( myParams->autoOuput )
00213 {
00214 doFileNameCurrent();
00215
00216 ret = save(fileNameBuffer, myParams->fileFormat);
00217
00218 if ( myParams->fileNameProgression )
00219 myParams->fileNameIndex++;
00220 }
00221
00222 return ret;
00223 }
00224
00225
00226 VETRESULT vetCodec_BMP::importFrom(vetFrameRGB24& img)
00227 {
00228 DEBUGMSG("VETRESULT vetCodec_BMP::importFrom(vetFrameRGB24& img) [reading data]", doBuffering)
00229
00230 int ret = VETRET_OK;
00231
00232 if ( myParams->autoOuput && !myParams->doBuffering )
00233 {
00234 doFileNameCurrent();
00235
00236 ret = save(img, fileNameBuffer, myParams->fileFormat);
00237
00238 if ( myParams->fileNameProgression )
00239 myParams->fileNameIndex++;
00240
00241 return ret;
00242 }
00243
00244 vetFrameRGB96::operator << (img);
00245
00246 if ( myParams->autoOuput )
00247 {
00248 doFileNameCurrent();
00249
00250 ret = save(fileNameBuffer, myParams->fileFormat);
00251
00252 if ( myParams->fileNameProgression )
00253 myParams->fileNameIndex++;
00254 }
00255
00256 return ret;
00257 }
00258
00259 VETRESULT vetCodec_BMP::importFrom(vetFrameT<unsigned char>& img)
00260 {
00261 DEBUGMSG("VETRESULT vetCodec_BMP::importFrom(vetFrameYUV420& img) [reading data]", doBuffering)
00262
00263 return VETRET_NOT_IMPLEMENTED;
00264 }
00265
00266 void vetCodec_BMP::setFileName(const char *filename)
00267 {
00268 strncpy(myParams->fileNameBase, filename, 64);
00269 strcpy(fileNameBuffer, myParams->fileNameBase);
00270 }
00271
00272
00273 void vetCodec_BMP::doFileNameCurrent()
00274 {
00275
00276 sprintf( fileNameIndexBuffer, "%d", myParams->fileNameIndex );
00277
00278 strcpy( fileNameBuffer, myParams->fileNameBase );
00279
00280 if ( myParams->fileNameIndex != -1 )
00281 strcat( fileNameBuffer, fileNameIndexBuffer );
00282
00283 strcat( fileNameBuffer, (const char*)".bmp" );
00284
00285 DEBUGMSG("void vetCodec_BMP::doFileNameCurrent()", fileNameBuffer);
00286
00287 }
00288
00289
00290 void vetCodec_BMP::getFileNameCurrent(char* filename)
00291 {
00292 doFileNameCurrent();
00293 strcpy( filename, fileNameBuffer );
00294 }
00295
00296
00297
00298 VETRESULT vetCodec_BMP::save()
00299 {
00300 INFO("VETRESULT vetCodec_BMP::save() [saving buffered data]")
00301
00302 int ret = VETRET_OK;
00303
00304 doFileNameCurrent();
00305 ret = save(fileNameBuffer, myParams->fileFormat);
00306
00307 return ret;
00308 }
00309
00310 VETRESULT vetCodec_BMP::save(char *filename, int format)
00311 {
00312 DEBUGMSG("VETRESULT vetCodec_BMP::save(char *filename, FileFormat format) [saving buffered data]", filename)
00313
00314 int ret = VETRET_OK;
00315
00316 ret = save(*this, filename, static_cast<FileFormat>(format) );
00317
00318 return ret;
00319 }
00320
00321
00322 VETRESULT vetCodec_BMP::load()
00323 {
00324 INFO("VETRESULT vetCodec_BMP::load() [loading data to buffer]")
00325
00326 int ret = VETRET_OK;
00327
00328 doFileNameCurrent();
00329 ret = load(fileNameBuffer, myParams->fileFormat);
00330
00331 return ret;
00332 }
00333
00334
00335 VETRESULT vetCodec_BMP::load(char *filename, int format)
00336 {
00337 DEBUGMSG("VETRESULT vetCodec_BMP::load(char *filename, FileFormat format) [loading data to buffer]", filename)
00338
00339 int ret = VETRET_OK;
00340
00341 ret = load(*this, filename, static_cast<FileFormat>(format) );
00342
00343 return ret;
00344 }
00345
00346
00347
00348
00349
00350
00351 VETRESULT vetCodec_BMP::load(vetFrameYUV420& source, char *filename, FileFormat format)
00352 {
00353 DEBUGMSG("VETRESULT vetCodec_BMP::load(vetFrameYUV420& source, char *filename, ..) [loading file data to frame]", filename)
00354
00355 int ret = VETRET_OK;
00356
00357
00358
00359
00360
00361 return VETRET_NOT_IMPLEMENTED;
00362 }
00363
00364 VETRESULT vetCodec_BMP::load(vetFrameRGB24& source, char *filename, FileFormat format)
00365 {
00366 DEBUGMSG("VETRESULT vetCodec_BMP::load(vetFrameRGB24& source, char *filename, ..) [loading file data to frame]", filename)
00367
00368 int ret = VETRET_OK;
00369
00370 switch ( static_cast<FileFormat>(format) )
00371 {
00372 case FORMAT_BMP_24:
00373 {
00374 MicrosoftBMP_RT bmp(filename);
00375
00376 if ( !bmp.read() )
00377 throw("Invalid Bitmap file specified");
00378
00379 if ( source.width != bmp.ImageWidth || source.height != bmp.ImageHeight )
00380 source.reAllocCanvas(bmp.ImageWidth, bmp.ImageHeight);
00381
00382 bmp.extract_data( (unsigned char *)source.data[0] );
00383 }
00384 break;
00385
00386 case FORMAT_BMP_RC:
00387 {
00388 MicrosoftRCBMP_RT bmp(filename);
00389
00390 if ( !bmp.read() )
00391 throw("Invalid Bitmap file specified");
00392 if ( source.width != bmp.ImageWidth || source.height != bmp.ImageHeight )
00393 source.reAllocCanvas(bmp.ImageWidth, bmp.ImageHeight);
00394
00395 bmp.extract_data( (unsigned char *)source.data[0] );
00396 }
00397 break;
00398
00399 case FORMAT_BMP_MONO:
00400 {
00401 MicrosoftMonoBMP_RT bmp(filename);
00402
00403 if ( !bmp.read() )
00404 throw("Invalid Bitmap file specified");
00405
00406 if ( source.width != bmp.ImageWidth || source.height != bmp.ImageHeight )
00407 source.reAllocCanvas(bmp.ImageWidth, bmp.ImageHeight);
00408
00409 bmp.extract_data( (unsigned char *)source.data[0] );
00410 }
00411 break;
00412
00413 default:
00414 {
00415
00416 MicrosoftBMP_RT* bmp;
00417 MicrosoftRCBMP_RT *bmp_rc;
00418 MicrosoftMonoBMP_RT *bmp_mono;
00419
00420 if ( ( bmp = new MicrosoftBMP_RT(filename) ) != NULL && bmp->read() )
00421 {
00422
00423 if ( source.width != bmp->ImageWidth || source.height != bmp->ImageHeight )
00424 source.reAllocCanvas(bmp->ImageWidth, bmp->ImageHeight);
00425
00426 bmp->extract_data( (unsigned char *)source.data[0] );
00427
00428 }
00429 else if ( (bmp_rc = new MicrosoftRCBMP_RT(filename) ) != NULL && bmp_rc->read() )
00430 {
00431
00432 if ( source.width != bmp_rc->ImageWidth || source.height != bmp_rc->ImageHeight )
00433 source.reAllocCanvas(bmp_rc->ImageWidth, bmp_rc->ImageHeight);
00434
00435 bmp_rc->extract_data( (unsigned char *)source.data[0] );
00436
00437 }
00438 else if ( (bmp_mono = new MicrosoftMonoBMP_RT(filename) ) != NULL && bmp_mono->read() )
00439 {
00440
00441 if ( source.width != bmp_mono->ImageWidth || source.height != bmp_mono->ImageHeight )
00442 source.reAllocCanvas(bmp_mono->ImageWidth, bmp_mono->ImageHeight);
00443
00444 bmp_mono->extract_data( (unsigned char *)source.data[0] );
00445
00446 }
00447 }
00448 break;
00449
00450 }
00451
00452 return ret;
00453 }
00454
00455 VETRESULT vetCodec_BMP::load(vetFrameRGB96& source, char *filename, FileFormat format)
00456 {
00457 DEBUGMSG("VETRESULT vetCodec_BMP::load(vetFrameRGB& source, char *filename, ..) [loading file data to frame]", filename)
00458
00459 int ret = VETRET_OK;
00460
00461 switch ( static_cast<FileFormat>(format) )
00462 {
00463 case FORMAT_BMP_24:
00464 {
00465 MicrosoftBMP_RT bmp(filename);
00466
00467 if ( !bmp.read() )
00468 throw("Invalid Bitmap file specified");
00469
00470 if ( source.width != bmp.ImageWidth || source.height != bmp.ImageHeight )
00471 source.reAllocCanvas(bmp.ImageWidth, bmp.ImageHeight);
00472
00473 bmp.extract_data( (int*)source.data[0] );
00474 }
00475 break;
00476
00477 case FORMAT_BMP_RC:
00478 {
00479 MicrosoftRCBMP_RT bmp(filename);
00480
00481 if ( !bmp.read() )
00482 throw("Invalid Bitmap file specified");
00483 if ( source.width != bmp.ImageWidth || source.height != bmp.ImageHeight )
00484 source.reAllocCanvas(bmp.ImageWidth, bmp.ImageHeight);
00485
00486 bmp.extract_data( (int*)source.data[0] );
00487 }
00488 break;
00489
00490 case FORMAT_BMP_MONO:
00491 {
00492 MicrosoftMonoBMP_RT bmp(filename);
00493
00494 if ( !bmp.read() )
00495 throw("Invalid Bitmap file specified");
00496
00497 if ( source.width != bmp.ImageWidth || source.height != bmp.ImageHeight )
00498 source.reAllocCanvas(bmp.ImageWidth, bmp.ImageHeight);
00499
00500 bmp.extract_data( (int*)source.data[0] );
00501 }
00502 break;
00503
00504 default:
00505 {
00506
00507 MicrosoftBMP_RT* bmp;
00508 MicrosoftRCBMP_RT *bmp_rc;
00509 MicrosoftMonoBMP_RT *bmp_mono;
00510
00511 if ( ( bmp = new MicrosoftBMP_RT(filename) ) != NULL && bmp->read() )
00512 {
00513
00514 if ( source.width != bmp->ImageWidth || source.height != bmp->ImageHeight )
00515 source.reAllocCanvas(bmp->ImageWidth, bmp->ImageHeight);
00516
00517 bmp->extract_data( (int*)source.data[0] );
00518
00519 }
00520 else if ( (bmp_rc = new MicrosoftRCBMP_RT(filename) ) != NULL && bmp_rc->read() )
00521 {
00522
00523 if ( source.width != bmp_rc->ImageWidth || source.height != bmp_rc->ImageHeight )
00524 source.reAllocCanvas(bmp_rc->ImageWidth, bmp_rc->ImageHeight);
00525
00526 bmp_rc->extract_data( (int*)source.data[0] );
00527
00528 }
00529 else if ( (bmp_mono = new MicrosoftMonoBMP_RT(filename) ) != NULL && bmp_mono->read() )
00530 {
00531
00532 if ( source.width != bmp_mono->ImageWidth || source.height != bmp_mono->ImageHeight )
00533 source.reAllocCanvas(bmp_mono->ImageWidth, bmp_mono->ImageHeight);
00534
00535 bmp_mono->extract_data( (int*)source.data[0] );
00536
00537 }
00538 }
00539 break;
00540
00541 }
00542
00543 return ret;
00544 }
00545
00546
00547 VETRESULT vetCodec_BMP::load(vetFrameT<unsigned char>& source, char *filename, FileFormat format)
00548 {
00549 DEBUGMSG("VETRESULT vetCodec_BMP::load(vetFrameT& source, char *filename, ..) [loading file data to frame]", filename)
00550
00551 if ( source.getWidth() != 0 || source.getHeight() != 0 )
00552 return VETRET_PARAM_ERR;
00553
00554 int ret = VETRET_OK;
00555
00556
00557
00558
00559
00560
00561 return ret;
00562 }
00563
00564
00565 VETRESULT vetCodec_BMP::save(vetFrameYUV420& source, char *filename, FileFormat format)
00566 {
00567 DEBUGMSG("VETRESULT vetCodec_BMP::save(vetFrameYUV420& source, char *filename, FileFormat format) [saving frame to file]", filename)
00568
00569 if ( source.width == 0 || source.height == 0 || source.data == NULL )
00570 return VETRET_PARAM_ERR;
00571
00572 int ret = VETRET_OK;
00573
00574
00575
00576
00577
00578
00579
00580 return ret;
00581 }
00582
00583 VETRESULT vetCodec_BMP::save(vetFrameRGB24& source, char *filename, FileFormat format)
00584 {
00585 DEBUGMSG("VETRESULT vetCodec_BMP::save(vetFrameRGB24& source, char *filename, FileFormat format) [saving frame to file]", filename)
00586
00587 if ( source.width == 0 || source.height == 0 || source.data == NULL )
00588 return VETRET_PARAM_ERR;
00589
00590 int ret = VETRET_OK;
00591
00592
00593 switch (format)
00594 {
00595 case vetCodec_BMP::FORMAT_BMP_RC:
00596 {
00597
00598 MicrosoftRCBMP_RT *btmp;
00599 btmp = new MicrosoftRCBMP_RT( filename );
00600 if ( btmp == NULL )
00601 ret = VETRET_CODER_FILEOUT_ER;
00602 else if ( !btmp->set_size(source.width, source.height) )
00603 ret = VETRET_CODER_SIZE_ER;
00604 else if ( !btmp->set_palette_grey256() )
00605 ret = VETRET_CODER_PALETTE_ER;
00606 else {
00607 btmp->put_data_grey( (unsigned char *)source.data[0] );
00608 if ( !btmp->write() )
00609 ret = VETRET_CODER_WRITE_ER;
00610 }
00611 delete btmp ;
00612 break;
00613 }
00614 case vetCodec_BMP::FORMAT_BMP_MONO:
00615 {
00616
00617 MicrosoftMonoBMP_RT *btmp;
00618 btmp = new MicrosoftMonoBMP_RT( filename );
00619 if( btmp == NULL )
00620 ret = VETRET_CODER_FILEOUT_ER;
00621 else if ( !btmp->set_size(source.width, source.height) )
00622 ret = VETRET_CODER_SIZE_ER;
00623 else {
00624 btmp->put_data_grey( (unsigned char *)source.data[0] );
00625 if ( !btmp->write() )
00626 ret = VETRET_CODER_WRITE_ER;
00627 }
00628 delete btmp ;
00629 break;
00630 }
00631
00632 default:
00633 {
00634
00635 MicrosoftBMP_RT *btmp;
00636 btmp = new MicrosoftBMP_RT( filename );
00637
00638 if ( btmp == NULL )
00639 ret = VETRET_CODER_FILEOUT_ER;
00640 else if ( !btmp->set_size(source.width, source.height) )
00641 ret = VETRET_CODER_SIZE_ER;
00642 else {
00643 btmp->put_data_grey( (unsigned char *)source.data[0] );
00644 if ( !btmp->write() )
00645 ret = VETRET_CODER_WRITE_ER;
00646 }
00647 delete btmp ;
00648 break;
00649 }
00650
00651 }
00652
00653 return ret;
00654 }
00655
00656
00657
00658 VETRESULT vetCodec_BMP::save(vetFrameRGB96& source, char *filename, FileFormat format)
00659 {
00660 DEBUGMSG("VETRESULT vetCodec_BMP::save(vetFrameRGB96& source, char *filename, FileFormat format) [saving frame to file]", filename)
00661
00662 if ( source.getWidth() == 0 || source.getHeight() == 0 )
00663 return VETRET_PARAM_ERR;
00664
00665 int ret = VETRET_OK;
00666
00667 switch (format)
00668 {
00669 case vetCodec_BMP::FORMAT_BMP_RC:
00670 {
00671
00672 MicrosoftRCBMP_RT *btmp;
00673 btmp = new MicrosoftRCBMP_RT( filename );
00674 if ( btmp == NULL )
00675 ret = VETRET_CODER_FILEOUT_ER;
00676 else if ( !btmp->set_size(source.width, source.height) )
00677 ret = VETRET_CODER_SIZE_ER;
00678 else if ( !btmp->set_palette_grey256() )
00679 ret = VETRET_CODER_PALETTE_ER;
00680 else {
00681 btmp->put_data_grey( (int *)source.data[0] );
00682 if ( !btmp->write() )
00683 ret = VETRET_CODER_WRITE_ER;
00684 }
00685 delete btmp ;
00686 break;
00687 }
00688 case vetCodec_BMP::FORMAT_BMP_MONO:
00689 {
00690
00691 MicrosoftMonoBMP_RT *btmp;
00692 btmp = new MicrosoftMonoBMP_RT( filename );
00693 if( btmp == NULL )
00694 ret = VETRET_CODER_FILEOUT_ER;
00695 else if ( !btmp->set_size(source.width, source.height) )
00696 ret = VETRET_CODER_SIZE_ER;
00697 else {
00698 btmp->put_data_grey( (int *)source.data[0] );
00699 if ( !btmp->write() )
00700 ret = VETRET_CODER_WRITE_ER;
00701 }
00702 delete btmp ;
00703 break;
00704 }
00705
00706 default:
00707 {
00708
00709 MicrosoftBMP_RT *btmp;
00710 btmp = new MicrosoftBMP_RT( filename );
00711
00712 if ( btmp == NULL )
00713 ret = VETRET_CODER_FILEOUT_ER;
00714 else if ( !btmp->set_size(source.width, source.height) )
00715 ret = VETRET_CODER_SIZE_ER;
00716 else {
00717 btmp->put_data_grey( (int *)source.data[0] );
00718 if ( !btmp->write() )
00719 ret = VETRET_CODER_WRITE_ER;
00720 }
00721 delete btmp ;
00722 break;
00723 }
00724
00725 }
00726
00727 return ret;
00728 }
00729
00730
00731
00732
00733 VETRESULT vetCodec_BMP::save(vetFrameT<unsigned char>& source, char *filename, FileFormat format)
00734 {
00735 DEBUGMSG("VETRESULT vetCodec_BMP::save(vetFrameT& source, char *filename, FileFormat format) [saving frame to file]", filename)
00736
00737 if ( source.width == 0 || source.height == 0 || source.data == NULL )
00738 return VETRET_PARAM_ERR;
00739
00740 int ret = VETRET_OK;
00741
00742
00743
00744
00745
00746 return ret;
00747
00748 }
00749
00750
00751
00760 void vetCodec_BMP::setFileNameProgression(bool value) { myParams->fileNameProgression = value; }
00761
00774 void vetCodec_BMP::setAutoOutputEnabled(bool value) { myParams->autoOuput = value; }
00775
00788 void vetCodec_BMP::setAutoInputEnabled(bool value) { myParams->autoInput = value; }
00789
00802 void vetCodec_BMP::setDoBuffering(bool value) { myParams->doBuffering = value; }
00803
00804 void vetCodec_BMP::setFileFormat(FileFormat format) { myParams->fileFormat = format; }
00805
00817 int vetCodec_BMP::getFileNameIndex() { return myParams->fileNameIndex; }
00826 bool vetCodec_BMP::isFileNameProgressionEnabled() { return myParams->fileNameProgression; }
00827
00838 bool vetCodec_BMP::isAutoInputEnabled() { return myParams->autoInput; }
00839
00852 bool vetCodec_BMP::isAutoOutputEnabled() { return myParams->autoOuput; }
00853
00867 bool vetCodec_BMP::isBufferingEnabled() { return myParams->doBuffering; }
00868
00880 vetCodec_BMP::FileFormat vetCodec_BMP::getFileFormat()
00881 {
00882 return myParams->fileFormat;
00883 }
00884
00885
00886
00887
00888
00889
00890
00891
00892 vetCodec_BMPParameters::vetCodec_BMPParameters()
00893 {
00894 reset();
00895 }
00896
00897 vetCodec_BMPParameters::vetCodec_BMPParameters(const char* filename, vetCodec_BMP::FileFormat format)
00898 {
00899 reset();
00900 setFileName(filename);
00901 setFileFormat(format);
00902 }
00903
00904 void vetCodec_BMPParameters::reset()
00905 {
00906 strcpy(fileNameBase, (const char*)"OUTPUT_1\0");
00907 setFileFormat();
00908 setDoBuffering(true);
00909 setFileNameProgression(true);
00910 setFileNameIndex(-1);
00911 setAutoInputEnabled(false);
00912 setAutoOutputEnabled(true);
00913 }
00914
00915
00916
00917 void vetCodec_BMPParameters::setFileName(const char *filename)
00918 {
00919 strncpy(fileNameBase, filename, 64);
00920 }
00921
00922
00923 void vetCodec_BMPParameters::getFileName(char *filename)
00924 {
00925 strcpy(filename, fileNameBase);
00926 }
00927
00928
00929 int vetCodec_BMPParameters::saveToStreamXML(FILE *fp)
00930 {
00931 if ( fp == NULL )
00932 return VETRET_PARAM_ERR;
00933
00934 if( fprintf(fp, "<vetCodec_BMPParameters>\n") == EOF )
00935 return VETRET_INTERNAL_ERR;
00936
00937 if ( fprintf(fp, " <filename value=\"%s\" />\n", fileNameBase) == EOF)
00938 return VETRET_INTERNAL_ERR;
00939
00940 if ( fprintf(fp, " <fileFormat value=\"%i\" />\n", (int)fileFormat) == EOF)
00941 return VETRET_INTERNAL_ERR;
00942
00943 if ( fprintf(fp, " <fileNameIndex value=\"%i\" />\n", fileNameIndex) == EOF)
00944 return VETRET_INTERNAL_ERR;
00945
00946 if ( fprintf(fp, " <doBuffering value=\"%u\" />\n", (int)doBuffering) == EOF)
00947 return VETRET_INTERNAL_ERR;
00948
00949 if ( fprintf(fp, " <autoOuput value=\"%u\" />\n", (int)autoOuput) == EOF)
00950 return VETRET_INTERNAL_ERR;
00951
00952 if ( fprintf(fp, " <autoInput value=\"%u\" />\n", (int)autoInput) == EOF)
00953 return VETRET_INTERNAL_ERR;
00954
00955 if( fprintf(fp, "</vetCodec_BMPParameters>\n") == EOF )
00956 return VETRET_INTERNAL_ERR;
00957
00958 return VETRET_OK;
00959 }
00960
00961
00962 int vetCodec_BMPParameters::loadFromStreamXML(FILE *fp)
00963 {
00964 if ( fscanf(fp, "<vetCodec_BMPParameters>\n") == EOF )
00965 throw "error in XML file, unable to import data.";
00966
00967 if ( fscanf(fp, " <filename value=\"%s\" />\n", fileNameBase) == EOF )
00968 throw "error in XML file, unable to import data.";
00969
00970 if ( fscanf(fp, " <fileNameIndex value=\"%i\" />\n", &fileNameIndex) == EOF )
00971 throw "error in XML file, unable to import data.";
00972
00973 int boolTmp = 1;
00974 if ( fscanf(fp, " <doBuffering value=\"%u\" />\n", &boolTmp) == EOF )
00975 throw "error in XML file, unable to import data.";
00976
00977 if (boolTmp == 0)
00978 doBuffering = false;
00979 else
00980 doBuffering = true;
00981
00982 boolTmp = 0;
00983 if ( fscanf(fp, " <autoOuput value=\"%u\" />\n", &boolTmp) == EOF )
00984 throw "error in XML file, unable to import data.";
00985
00986 if (boolTmp == 0)
00987 autoOuput = false;
00988 else
00989 autoOuput = true;
00990
00991 boolTmp = 0;
00992 if ( fscanf(fp, " <autoInput value=\"%u\" />\n", &boolTmp) == EOF )
00993 throw "error in XML file, unable to import data.";
00994
00995 if (boolTmp == 0)
00996 autoInput = false;
00997 else
00998 autoInput = true;
00999
01000 return VETRET_OK;
01001 }
01002
01003
01004
01005