MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / loadRawFile

Method loadRawFile

IPL/src/IPLFileIO.cpp:514–575  ·  view source on GitHub ↗

! * \brief IPLFileIO::loadRAWFile * \param filename * \param image pass by pointer reference, because we need to change the pointer * \param width * \param height * \param format: 8 bit (Grayscale)|24 bit (RGB)|24 bit (BGR)|32 bit (RGBA)|32 bit (ABGR) * \param interleaved: Interleaved|Planar * \param information * \return */

Source from the content-addressed store, hash-verified

512 * \return
513 */
514bool IPLFileIO::loadRawFile(std::string filename, IPLImage *&image, int width, int height, IPLRawImageType format, bool interleaved, std::string &information)
515{
516 std::string filePath;
517
518 // try loading relative filepaths to the _baseDir
519 if(!IPLFileIO::isAbsolutePath(filename))
520 {
521 filePath.append(IPLFileIO::_baseDir).append("/").append(filename);
522 }
523 else
524 {
525 filePath.append(filename);
526 }
527
528 std::ifstream file(filePath, std::ios::binary);
529
530 if(!file.is_open())
531 {
532 information.append("Could not open file");
533 image = NULL;
534 return false;
535 }
536
537 // clear old image
538 delete image;
539 // create IPLImage
540 if(format == IPL_RAW_8BIT)
541 image = new IPLImage(IPL_IMAGE_GRAYSCALE, width, height);
542 else
543 image = new IPLImage(IPL_IMAGE_COLOR, width, height);
544
545 // read file
546 switch (format) {
547 case 0: // 8 bit (Grayscale)
548 {
549 return readRaw8bit(width, image, file);
550 break;
551 }
552 case IPL_RAW_24BIT_RGB: // 24 bit (RGB)
553 case IPL_RAW_24BIT_BGR: // 24 bit (BGR)
554 {
555 if(interleaved)
556 return readRaw24BitInterleaved(width, format, image, file);
557 else
558 return readRaw24BitPlanar(width, format, image, file);
559 break;
560 }
561 case IPL_RAW_32BIT_RGB: // 32 bit (RGBA)
562 case IPL_RAW_32BIT_BGR: // 32 bit (ABGR)
563 {
564 if(interleaved)
565 return readRaw32BitInterleaved(width, format, image, file);
566 else
567 return readRaw32BitPlanar(width, format, image, file);
568 break;
569 }
570 default:
571 break;

Callers

nothing calls this directly

Calls 1

isAbsolutePathFunction · 0.85

Tested by

no test coverage detected