34 #ifndef AIMS_IO_JPEGW_H 35 #define AIMS_IO_JPEGW_H 66 unsigned zfame,
unsigned tframe );
76 operator << ( JpegWriter<T> & writer,
const AimsData<T> & thing )
78 writer.write( thing );
87 unsigned t, z, dt = thing.
dimT(), dz = thing.
dimZ();
97 std::vector<std::string> files = hdr.outputFilenames();
99 hdr.setProperty(
"file_type", std::string(
"JPEG" ) );
102 hdr.setProperty(
"filenames", files );
107 for( t=0; t<dt; ++t )
108 for( z=0; z<dz; ++z, ++i )
112 + hdr.extension() +
".minf" );
118 const std::string & filename,
unsigned z,
121 struct jpeg_compress_struct cinfo;
122 struct jpeg_error_mgr jerr;
125 JSAMPROW row_pointer[1];
127 cinfo.err = jpeg_std_error( &jerr );
128 jpeg_create_compress( &cinfo );
130 cinfo.image_width = thing.
dimX();
131 cinfo.image_height = thing.
dimY();
132 cinfo.in_color_space = (
sizeof( T ) == 3 ? JCS_RGB : JCS_GRAYSCALE );
133 cinfo.input_components = (
sizeof( T ) == 3 ? 3 : 1 );
134 cinfo.input_gamma = 1;
135 jpeg_set_defaults( &cinfo );
136 if(
sizeof( T ) != 3 )
137 cinfo.data_precision = 8 *
sizeof( T );
138 cinfo.smoothing_factor = 0;
139 jpeg_set_quality( &cinfo, 100, TRUE );
140 cinfo.density_unit = 1;
141 cinfo.X_density = (UINT16) ( 25.4 / thing.
sizeX() );
142 cinfo.Y_density = (UINT16) ( 25.4 / thing.
sizeY() );
144 fp = fopen( filename.c_str(),
"wb" );
148 jpeg_stdio_dest( &cinfo, fp );
149 jpeg_start_compress( &cinfo, TRUE );
151 for( i=0; i<cinfo.image_height; ++i )
153 row_pointer[0] = (JSAMPROW) &thing( 0, i, z, t );
154 jpeg_write_scanlines( &cinfo, row_pointer, 1 );
157 jpeg_finish_compress( &cinfo );
159 jpeg_destroy_compress( &cinfo );
void write(const AimsData< T > &thing)
The class for EcatSino data write operation.
static std::string removeExtension(const std::string &)
JpegWriter(const std::string &name)
void writeFrame(const AimsData< T > &thing, const std::string &filename, unsigned zfame, unsigned tframe)
called by write(), but you can call it for single frame writing (axial slice)
static std::string dirname(const std::string &)
const aims::Header * header() const
std::string removeExtension(const std::string &name) const
Return a name without .jpg extension.