当前位置: 首页>>代码示例>>C++>>正文


C++ LibRaw::open_file方法代码示例

本文整理汇总了C++中LibRaw::open_file方法的典型用法代码示例。如果您正苦于以下问题:C++ LibRaw::open_file方法的具体用法?C++ LibRaw::open_file怎么用?C++ LibRaw::open_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LibRaw的用法示例。


在下文中一共展示了LibRaw::open_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: libraw_open_file_ex

 int libraw_open_file_ex(libraw_data_t* lr, const char *file,INT64 sz)
 {
     if(!lr) return EINVAL;
     LibRaw *ip = (LibRaw*) lr->parent_class;
     return ip->open_file(file,sz);
 }
开发者ID:iMackee,项目名称:AnDSLR,代码行数:6,代码来源:libraw_c_api.cpp

示例2: main


//.........这里部分代码省略.........
              {
                fprintf(stderr,"Cannot open %s: %s\n",argv[arg],strerror(errno));
                continue;
              }
            if(fstat(file,&st))
              {
                fprintf(stderr,"Cannot stat %s: %s\n",argv[arg],strerror(errno));
                close(file);
                continue;
              }
            if(!(iobuffer = malloc(st.st_size)))
              {
                fprintf(stderr,"Cannot allocate %d kbytes for memory buffer\n",(int)(st.st_size/1024));
                close(file);
                continue;
              }
            int rd;
            if(st.st_size!=(rd=read(file,iobuffer,st.st_size)))
              {
                fprintf(stderr,"Cannot read %d bytes instead of  %d to memory buffer\n",(int)rd,(int)st.st_size);
                close(file);
                free(iobuffer);
                continue;
              }
            close(file);
            if( (ret = RawProcessor.open_buffer(iobuffer,st.st_size)) != LIBRAW_SUCCESS)
              {
                fprintf(stderr,"Cannot open_buffer %s: %s\n",argv[arg],libraw_strerror(ret));
                free(iobuffer);
                continue; // no recycle b/c open file will recycle itself
              }
          }
        else
          {
            if(use_bigfile)
              // force open_file switch to bigfile processing
              ret = RawProcessor.open_file(argv[arg],1);
            else
              ret = RawProcessor.open_file(argv[arg]);
                        
            if( ret  != LIBRAW_SUCCESS)
              {
                fprintf(stderr,"Cannot open %s: %s\n",argv[arg],libraw_strerror(ret));
                continue; // no recycle b/c open_file will recycle itself
              }
          }

      if(use_timing)
        timerprint("LibRaw::open_file()",argv[arg]);


      timerstart();
      if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
        {
          fprintf(stderr,"Cannot unpack %s: %s\n",argv[arg],libraw_strerror(ret));
          continue;
        }

      if(use_timing)
        timerprint("LibRaw::unpack()",argv[arg]);

      timerstart();
      if (LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_process()))
        {
          fprintf(stderr,"Cannot do postpocessing on %s: %s\n",argv[arg],libraw_strerror(ret));
          if(LIBRAW_FATAL_ERROR(ret))
            continue; 
        }
      if(use_timing)
        timerprint("LibRaw::dcraw_process()",argv[arg]);

      snprintf(outfn,sizeof(outfn),
               "%s.%s",
               argv[arg], OUT.output_tiff ? "tiff" : (P1.colors>1?"ppm":"pgm"));

      if(verbosity)
        {
          printf("Writing file %s\n",outfn);
        }

      if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
        fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret));

#ifndef WIN32
      if(use_mmap && iobuffer)
        {
          munmap(iobuffer,msize);
          iobuffer=0;
        }
#endif
      else if(use_mem && iobuffer)
        {
          free(iobuffer);
          iobuffer = 0;
        }
            
      RawProcessor.recycle(); // just for show this call
    }
  return 0;
}
开发者ID:itosue,项目名称:LibRaw,代码行数:101,代码来源:dcraw_emu.cpp

示例3: main


//.........这里部分代码省略.........
                  return 1;
              }
      }
  putenv ((char*)"TZ=UTC"); // dcraw compatibility, affects TIFF datestamp field
  OUT.filtering_mode = LIBRAW_FILTERING_AUTOMATIC;
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other

  if(verbosity>1)
          RawProcessor.set_progress_handler(my_progress_callback,(void*)"Sample data passed");
#ifdef _OPENMP
  if(verbosity)
          printf ("Using %d threads\n", omp_get_max_threads());
#endif

  for ( ; arg < argc; arg++)
        {
            char outfn[1024];

            if(verbosity) printf("Processing file %s\n",argv[arg]);
#ifndef WIN32
            if(use_mmap)
                {
                    int file = open(argv[arg],O_RDONLY);
                    struct stat st;
                    if(file<0)
                        {
                            fprintf(stderr,"Cannot open %s: %s\n",argv[arg],strerror(errno));
                            continue;
                        }
                    if(fstat(file,&st))
                        {
                            fprintf(stderr,"Cannot stat %s: %s\n",argv[arg],strerror(errno));
                            close(file);
                            continue;
                        }
                    int pgsz = getpagesize();
                    msize = ((st.st_size+pgsz-1)/pgsz)*pgsz;
                    iobuffer = mmap(NULL,msize,PROT_READ,MAP_PRIVATE,file,0);
                    if(!iobuffer)
                        {
                            fprintf(stderr,"Cannot mmap %s: %s\n",argv[arg],strerror(errno));
                            close(file);
                            continue;
                        }
                    close(file);
                    if( (ret = RawProcessor.open_buffer(iobuffer,st.st_size) != LIBRAW_SUCCESS))
                        {
                            fprintf(stderr,"Cannot open_buffer %s: %s\n",argv[arg],libraw_strerror(ret));
                            continue; // no recycle b/c open file will recycle itself
                        }

                }
            else
#endif
                {
                    if( (ret = RawProcessor.open_file(argv[arg])) != LIBRAW_SUCCESS)
                        {
                            fprintf(stderr,"Cannot open %s: %s\n",argv[arg],libraw_strerror(ret));
                            continue; // no recycle b/c open_file will recycle itself
                        }
                }
            if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
                {
                    fprintf(stderr,"Cannot unpack %s: %s\n",argv[arg],libraw_strerror(ret));
                    continue;
                }
            if (LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_process()))
                {
                    fprintf(stderr,"Cannot do postpocessing on %s: %s\n",argv[arg],libraw_strerror(ret));
                    if(LIBRAW_FATAL_ERROR(ret))
                        continue; 
                }
            snprintf(outfn,sizeof(outfn),
                     "%s.%s",
                     argv[arg], OUT.output_tiff ? "tiff" : (P1.colors>1?"ppm":"pgm"));

            if(verbosity)
                {
                    printf("Writing file %s\n",outfn);
                }

            if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
                fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret));

#ifndef WIN32
            if(use_mmap && iobuffer)
                {
                    munmap(iobuffer,msize);
                    iobuffer=0;
                }
#endif
            
            RawProcessor.recycle(); // just for show this call
        }
    return 0;
}
开发者ID:adamhooper,项目名称:libraw-dead,代码行数:101,代码来源:dcraw_emu.cpp


注:本文中的LibRaw::open_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。