channels.Configure(codestream);
int ref_component = channels.Get_source_component(0);
int minLevels = codestream.Get_min_dwt_levels();
int minLayers= codestream.Get_max_tile_layers();
Kdu_dims image_dims = new Kdu_dims();
codestream.Get_dims(ref_component, image_dims);
Kdu_coords imageSize = image_dims.Access_size();
r.setWidth(imageSize.Get_x());
r.setHeight(imageSize.Get_y());
r.setDWTLevels(minLevels);