| 452 | } |
| 453 | |
| 454 | bool IPLFileIO::readRaw32BitPlanar(int stride, IPLRawImageType format, IPLImage *&image, std::ifstream &file) |
| 455 | { |
| 456 | char buffer; |
| 457 | int x=0; |
| 458 | int y=0; |
| 459 | |
| 460 | // RRRGGGBBB |
| 461 | int currentPlane = 0; |
| 462 | |
| 463 | // BBBGGGRRR |
| 464 | if(format == IPL_RAW_32BIT_BGR) |
| 465 | currentPlane = 2; |
| 466 | |
| 467 | // get length of file: |
| 468 | file.seekg (0, file.end); |
| 469 | int length = file.tellg(); |
| 470 | int planeLength = length/4; |
| 471 | file.seekg (0, file.beg); |
| 472 | |
| 473 | while(file.good()) |
| 474 | { |
| 475 | file.read(&buffer, 1); |
| 476 | |
| 477 | image->plane(currentPlane)->cp(x, y) = buffer * FACTOR_TO_FLOAT; |
| 478 | |
| 479 | x++; |
| 480 | if(x % stride == 0) |
| 481 | { |
| 482 | x = 0; |
| 483 | y++; |
| 484 | } |
| 485 | |
| 486 | if(((int) file.tellg()+1) % planeLength == 0) |
| 487 | { |
| 488 | if(format == IPL_RAW_32BIT_RGB) |
| 489 | currentPlane++; |
| 490 | else |
| 491 | currentPlane--; |
| 492 | |
| 493 | x = 0; |
| 494 | y = 0; |
| 495 | |
| 496 | if(currentPlane >= image->getNumberOfPlanes() || currentPlane < 0) |
| 497 | return true; |
| 498 | } |
| 499 | } |
| 500 | return true; |
| 501 | } |
| 502 | |
| 503 | /*! |
| 504 | * \brief IPLFileIO::loadRAWFile |