56 static const std::map<QImage::Format, QString> formatNames = {
57 {QImage::Format_Invalid,
"Format_Invalid"},
58 {QImage::Format_Mono,
"Format_Mono"},
59 {QImage::Format_MonoLSB,
"Format_MonoLSB"},
60 {QImage::Format_Indexed8,
"Format_Indexed8"},
61 {QImage::Format_RGB32,
"Format_RGB32"},
62 {QImage::Format_ARGB32,
"Format_ARGB32"},
63 {QImage::Format_ARGB32_Premultiplied,
"Format_ARGB32_Premultiplied"},
64 {QImage::Format_RGB16,
"Format_RGB16"},
65 {QImage::Format_ARGB8565_Premultiplied,
"Format_ARGB8565_Premultiplied"},
66 {QImage::Format_RGB666,
"Format_RGB666"},
67 {QImage::Format_ARGB6666_Premultiplied,
"Format_ARGB6666_Premultiplied"},
68 {QImage::Format_RGB555,
"Format_RGB555"},
69 {QImage::Format_ARGB8555_Premultiplied,
"Format_ARGB8555_Premultiplied"},
70 {QImage::Format_RGB888,
"Format_RGB888"},
71 {QImage::Format_RGB444,
"Format_RGB444"},
72 {QImage::Format_ARGB4444_Premultiplied,
"Format_ARGB4444_Premultiplied"},
73 {QImage::Format_RGBX8888,
"Format_RGBX8888"},
74 {QImage::Format_RGBA8888,
"Format_RGBA8888"},
75 {QImage::Format_RGBA8888_Premultiplied,
"Format_RGBA8888_Premultiplied"},
76 {QImage::Format_BGR30,
"Format_BGR30"},
77 {QImage::Format_A2BGR30_Premultiplied,
"Format_A2BGR30_Premultiplied"},
78 {QImage::Format_RGB30,
"Format_RGB30"},
79 {QImage::Format_A2RGB30_Premultiplied,
"Format_A2RGB30_Premultiplied"},
80 {QImage::Format_Alpha8,
"Format_Alpha8"},
81 {QImage::Format_Grayscale8,
"Format_Grayscale8"},
82 {QImage::Format_Grayscale16,
"Format_Grayscale16"},
85 auto it = formatNames.find(format);
86 if (it != formatNames.end()) {
89 return "Format_Inconnu";
127 const carto::AllocatorContext & context,
135 catch( std::exception & e )
141 int frame = -1, border = 0;
142 options->getProperty(
"frame", frame );
143 options->getProperty(
"border", border );
147 unsigned tmin = 0, tmax = hdr->
dimT() - 1;
150 if( tmax < (
unsigned) frame )
153 throw std::domain_error(
"frame higher than file dimT" );
155 if( (
unsigned) frame < tmax )
156 files.erase( files.begin() + ( frame + 1 ) * hdr->
dimZ(),
159 files.erase( files.begin(), files.begin() + frame * hdr->
dimZ() );
164 carto::AllocatorContext al
165 ( context.accessMode(),
167 (
new carto::FileDataSource( *files.begin(), 0,
168 carto::DataSource::Read ) ),
169 false, context.useFactor() );
172 tmax - tmin + 1, border, al );
174 std::vector<float> vs( 4, 1. );
175 vs[0] = hdr->
sizeX();
176 vs[1] = hdr->
sizeY();
177 vs[2] = hdr->
sizeZ();
178 vs[3] = hdr->
sizeT();
181 std::vector<int> dims(4);
182 dims[0] = hdr->
dimX();
183 dims[1] = hdr->
dimY();
184 dims[2] = hdr->
dimZ();
185 dims[3] = tmax - tmin + 1;
195 unsigned i = 0, s, t, ns = (unsigned) data.
getSizeZ(),
196 nt = tmax - tmin + 1;
197 for( t=0; t<nt; ++t )
198 for( s=0; s<ns; ++s, ++i )
199 readFrame( *data, hdr, dir + files[i], s, t );
211 const std::string & name,
unsigned z,
216 const QImage *imp = 0;
221 imp = &hdr->qimage();
226 qio.setFileName( name.c_str() );
227 qio.setFormat( format.c_str() );
229 if( format ==
"JP2" )
242 const QImage & im = *imp;
251 if ( im.allGray() && (im.depth() == (
sizeof(T) * 8) && im.colorCount() == 0 ) )
252 for( y=0; y<dy; ++y )
253 memcpy( &data.
at( 0, y, z, t ), im.scanLine( y ), dx *
sizeof( T ) );
256 for( y=0; y<dy; ++y )
257 for(
int x=0; x<dx; ++x )
258 data.
at( x, y, z, t ) = convertColor( im.pixel( x, y ) );