32#ifndef eman__imageio_h__
33#define eman__imageio_h__ 1
147 const Region * area = 0,
bool is_3d =
false) = 0;
164 bool use_host_endian =
true) = 0;
178 const Region * area = 0,
bool is_3d =
false) = 0;
194 const Region * area = 0,
bool is_3d =
false,
float minval = 0.0f,
float maxval = 0.0f) {
213 bool use_host_endian =
true) = 0;
221 virtual int read_ctf(
Ctf & ctf,
int image_index = 0);
229 virtual void write_ctf(
const Ctf & ctf,
int image_index = 0);
326 bool is_new_file =
false,
bool inbounds_only=
true);
338 bool is_new_file =
false,
bool inbounds_only=
true);
350 bool * is_new = 0,
bool overwrite =
false);
361#define DEFINE_IMAGEIO_FUNC \
362 int read_header(Dict & dict, int image_index = 0, const Region* area = 0, bool is_3d = false); \
363 int write_header(const Dict & dict, int image_index = 0, const Region * area = 0, EMUtil::EMDataType filestoragetype = EMUtil::EM_FLOAT, bool use_host_endian = true); \
364 int read_data(float* data, int image_index = 0, const Region* area = 0, bool is_3d = false); \
365 int write_data(float* data, int image_index = 0, const Region * area = 0, EMUtil::EMDataType filestoragetype = EMUtil::EM_FLOAT, bool use_host_endian = true); \
367 bool is_complex_mode(); \
368 bool is_image_big_endian(); \
static bool is_host_big_endian()
static void swap_bytes(T *data, size_t n=1)
swap the byte order of data with 'n' T-type elements.
Ctf is the base class for all CTF model.
Dict is a dictionary to store <string, EMObject> pair.
EMDataType
Image pixel data type used in EMAN.
FloatSize is used to describe a 1D, 2D or 3D rectangular size in floating numbers.
ImageIO classes are designed for reading/writing various electron micrography image formats,...
void check_region(const Region *area, const FloatSize &max_size, bool is_new_file=false, bool inbounds_only=true)
Validate image I/O region.
virtual int get_nimg()
Return the number of images in this image file.
virtual void flush()=0
Flush the IO buffer.
virtual int write_header(const Dict &dict, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)=0
Write a header to an image.
ImageIO(const string &fname, IOMode rw)
virtual int write_data(float *data, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)=0
Write data to an image.
string get_filename() const
virtual bool is_complex_mode()=0
Is this an complex image or not.
virtual int read_header(Dict &dict, int image_index=0, const Region *area=0, bool is_3d=false)=0
Read the header from an image.
FILE * sfopen(const string &filename, IOMode mode, bool *is_new=0, bool overwrite=false)
Run fopen safely.
virtual void write_ctf(const Ctf &ctf, int image_index=0)
Write CTF data to this image.
void check_read_access(int image_index)
Validate 'image_index' in file reading.
virtual int read_ctf(Ctf &ctf, int image_index=0)
Read CTF data from this image.
virtual bool is_single_image_format() const
Is this image format only storing 1 image or not.
virtual int read_data(float *data, int image_index=0, const Region *area=0, bool is_3d=false)=0
Read the data from an image.
virtual void init()=0
Do some initialization before doing the read/write.
void check_write_access(IOMode rw_mode, int image_index, int max_nimg=0)
Validate rw_mode and image_index in file writing.
virtual int read_data_8bit(unsigned char *data, int image_index=0, const Region *area=0, bool is_3d=false, float minval=0.0f, float maxval=0.0f)
Read the data from an image as an 8 bit array, regardless of format.
void become_host_endian(T *data, size_t n=1)
Convert data of this image into host endian format.
virtual bool is_image_big_endian()=0
Is this image in big endian or not.
IntSize is used to describe a 1D, 2D or 3D rectangular size in integers.
Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes...
#define ImageFormatException(desc)