20#ifdef MRTRIX_PNG_SUPPORT
39 Reader (
const std::string& filename);
42 uint32_t get_width()
const {
return width; }
43 uint32_t get_height()
const {
return height; }
44 int get_bitdepth()
const {
return bit_depth; }
45 int get_colortype()
const {
return color_type; }
46 int get_channels()
const {
return channels; }
48 size_t get_size()
const {
return png_get_rowbytes(png_ptr, info_ptr) * height; }
49 int get_output_bitdepth()
const {
return output_bitdepth; }
50 bool has_transparency()
const {
return png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS); }
59 png_uint_32 width, height;
60 int bit_depth, color_type;
72 Writer (
const Header&,
const std::string&);
75 size_t get_size()
const {
return png_get_rowbytes(png_ptr, info_ptr) * height;}
82 uint32_t width, height;
83 int color_type, bit_depth;
88 static void error_handler (png_struct_def*,
const char*);
89 static jmp_buf jmpbuf;
92 void fill (uint8_t* in_ptr, uint8_t* out_ptr,
const DataType data_type,
const size_t num_elements);
98 void Writer::fill (uint8_t* in_ptr, uint8_t* out_ptr,
const DataType data_type,
const size_t num_elements)
102 __set_fetch_store_functions<default_type> (fetch_func, store_func, data_type);
106 case DataType::Float64: multiplier = std::numeric_limits<uint16_t>::max();
break;
108 for (
size_t i = 0; i != num_elements; ++i) {
109 Raw::store_BE<T> (std::min (
default_type(std::numeric_limits<T>::max()), std::max (0.0,
std::round(multiplier * fetch_func (in_ptr, 0, 0.0, 1.0)))), out_ptr);
110 in_ptr += data_type.bytes();
111 out_ptr +=
sizeof(T);
static constexpr uint8_t Float32
static constexpr uint8_t Float64
static constexpr uint8_t Type
constexpr I round(const T x)
void load(Header &H, const std::string &path)
double default_type
the default type used throughout MRtrix
std::enable_if< is_adapter_type< typenamestd::remove_reference< ImageType >::type >::value, std::string >::type save(ImageType &&x, const std::string &filename, bool use_multi_threading=true)
save contents of an existing image to file (for debugging only)