#include <emimio.h>
Inheritance diagram for EMAN::EmimIO:
Public Member Functions | |
EmimIO (const string &filename, IOMode rw_mode=READ_ONLY) | |
~EmimIO () | |
bool | is_single_image_format () const |
Is this image format only storing 1 image or not. | |
int | get_nimg () |
Return the number of images in this image file. | |
Static Public Member Functions | |
static bool | is_valid (const void *first_block) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
Private Types | |
EMIM_COMPLEX = 1 | |
PARM_NONE = 0 | |
PARM_NORM = 1 | |
NUM_INT_IN_FILE_HEADER = 16 | |
enum | { EMIM_COMPLEX = 1, PARM_NONE = 0, PARM_NORM = 1, NUM_INT_IN_FILE_HEADER = 16 } |
Private Attributes | |
string | filename |
IOMode | rw_mode |
EmimFileHeader | efh |
FILE * | emim_file |
bool | is_big_endian |
bool | initialized |
Static Private Attributes | |
static const char * | MAGIC = "EMIM" |
Classes | |
struct | EmimFileHeader |
struct | EmimImageHeader |
EmimFileHeader defines the number of images 'n' in the file. All following images have the same dimensions:nx x ny x nz.
Definition at line 48 of file emimio.h.
anonymous enum [private] |
Definition at line 66 of file emimio.h.
00067 { 00068 EMIM_COMPLEX = 1, 00069 PARM_NONE = 0, 00070 PARM_NORM = 1, 00071 NUM_INT_IN_FILE_HEADER = 16 00072 };
EmimIO::EmimIO | ( | const string & | filename, | |
IOMode | rw_mode = READ_ONLY | |||
) | [explicit] |
Definition at line 44 of file emimio.cpp.
References efh, is_big_endian, and EMAN::ByteOrder::is_host_big_endian().
00045 : filename(file), rw_mode(rw), emim_file(0), initialized(false) 00046 { 00047 is_big_endian = ByteOrder::is_host_big_endian(); 00048 memset(&efh, 0, sizeof(EmimFileHeader)); 00049 }
EmimIO::~EmimIO | ( | ) |
int EmimIO::get_nimg | ( | ) | [virtual] |
Return the number of images in this image file.
Reimplemented from EMAN::ImageIO.
Definition at line 212 of file emimio.cpp.
References EMAN::ImageIO::init().
bool EMAN::EmimIO::is_single_image_format | ( | ) | const [inline, virtual] |
Is this image format only storing 1 image or not.
Some image formats like MRC only store 1 image in a file, so this function returns 'true' for them. Other image formats like IMAGIC/HDF5 may store mutliple images, so this function returns 'false' for them.
Reimplemented from EMAN::ImageIO.
Definition at line 58 of file emimio.h.
bool EmimIO::is_valid | ( | const void * | first_block | ) | [static] |
Definition at line 86 of file emimio.cpp.
References data, ENTERFUNC, EXITFUNC, EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), MAGIC, and EMAN::ByteOrder::swap_bytes().
00087 { 00088 ENTERFUNC; 00089 00090 if (!first_block) { 00091 return false; 00092 } 00093 00094 const char *data = static_cast < const char *>(first_block); 00095 const int *idata = static_cast < const int *>(first_block); 00096 int count = idata[2]; 00097 00098 if (strncmp(data, MAGIC, sizeof(MAGIC)) == 0) { 00099 bool data_big_endian = ByteOrder::is_data_big_endian(&count); 00100 00101 if (data_big_endian != ByteOrder::is_host_big_endian()) { 00102 ByteOrder::swap_bytes(&count); 00103 } 00104 00105 if (count >= 0 && count <= 1 << 20) { 00106 return true; 00107 } 00108 } 00109 EXITFUNC; 00110 return false; 00111 }
EmimFileHeader EMAN::EmimIO::efh [private] |
FILE* EMAN::EmimIO::emim_file [private] |
string EMAN::EmimIO::filename [private] |
bool EMAN::EmimIO::initialized [private] |
bool EMAN::EmimIO::is_big_endian [private] |
const char * EmimIO::MAGIC = "EMIM" [static, private] |
IOMode EMAN::EmimIO::rw_mode [private] |