34 #ifndef AIMS_IO_JPEGR_H 
   35 #define AIMS_IO_JPEGR_H 
   65                     unsigned zfame, 
unsigned tframe );
 
   73   inline JpegReader<T> & 
 
   84                             const carto::AllocatorContext & context, 
 
   92     catch( std::exception & e )
 
   98     int frame = -1, border = 0;
 
   99     options->getProperty( 
"frame", frame );
 
  100     options->getProperty( 
"border", border );
 
  103     std::vector<int> dims;
 
  106     if( dims.size() < 1 )
 
  107       dims.push_back( hdr->
dimX() );
 
  108     if( dims.size() < 2 )
 
  109       dims.push_back( hdr->
dimY() );
 
  110     if( dims.size() < 3 )
 
  111       dims.push_back( hdr->
dimZ() );
 
  112     if( dims.size() < 4 )
 
  113       dims.push_back( hdr->
dimT() );
 
  115     unsigned tmin = 0, tmax = dims[3] - 1;
 
  118       if( tmax < (
unsigned) frame )
 
  121         throw std::domain_error( 
"frame higher than file dimT" );
 
  123       if( (
unsigned) frame < tmax )
 
  124         files.erase( files.begin() + ( frame + 1 ) * hdr->
dimZ(), 
 
  127         files.erase( files.begin(), files.begin() + frame * hdr->
dimZ() );
 
  132     carto::AllocatorContext 
 
  133       cont2( context.accessMode(), 
 
  135              ( 
new carto::FileDataSource
 
  136                ( *files.begin(), 0, carto::DataSource::Read ) ), 
 
  137              false, context.useFactor() );
 
  149     dims[3] = tmax - tmin + 1;
 
  159     unsigned i = 0, s, t, ns = (unsigned) data.
dimZ(), 
nt = tmax - tmin + 1;
 
  160     for( t=0; t<
nt; ++t )
 
  161       for( s=0; s<ns; ++s, ++i )
 
  162         readFrame( data, dir + files[i], s, t );
 
  174       const std::string & name, 
 
  175       unsigned z, 
unsigned t)
 
  177     struct jpeg_decompress_struct cinfo;
 
  178     struct jpeg_error_mgr jerr;
 
  181     JSAMPROW row_pointer[1];
 
  183     cinfo.err = jpeg_std_error( &jerr );
 
  184     jpeg_create_decompress( &cinfo );
 
  186     fp = fopen( name.c_str(), 
"rb" );
 
  190     jpeg_stdio_src( &cinfo, fp );
 
  191     if( jpeg_read_header( &cinfo, TRUE ) != 1 )
 
  198         cinfo.out_color_space = JCS_RGB;
 
  199         cinfo.out_color_components = 3;
 
  203         cinfo.out_color_space = JCS_GRAYSCALE;
 
  204         cinfo.out_color_components = 1;
 
  206       jpeg_start_decompress( &cinfo );
 
  207       for( i=0; i<cinfo.image_height; ++i )
 
  209         row_pointer[0] = (JSAMPROW) &data( 0, i, z, t );
 
  210         jpeg_read_scanlines( &cinfo, row_pointer, 1 );
 
  214     jpeg_finish_decompress( &cinfo );
 
  216     jpeg_destroy_decompress( &cinfo );
 
void setSizeY(float sizey)
void setSizeT(float sizet)
void setHeader(aims::Header *hdr)
void setSizeZ(float sizez)
void setSizeX(float sizex)
void read(AimsData< T > &thing, const carto::AllocatorContext &context, carto::Object options)
void readFrame(AimsData< T > &thing, const std::string &filename, unsigned zfame, unsigned tframe)
called by read(), but you can call it for single frame reading (axial slice)
JpegReader(const std::string &name)
static std::string dirname(const std::string &)
virtual bool getProperty(const std::string &, Object &) const
virtual bool removeProperty(const std::string &)
virtual void setProperty(const std::string &, Object)
virtual bool hasProperty(const std::string &) const
The class for EcatSino data write operation.
GenesisReader< T > & operator>>(GenesisReader< T > &reader, AimsData< T > &thing)