#include <dm4io.h>
Inheritance diagram for EMAN::DM4IO:
Public Member Functions | |
DM4IO (const string &filename, IOMode rw_mode=READ_ONLY) | |
~DM4IO () | |
Static Public Member Functions | |
static bool | is_valid (const void *first_block) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
Private Types | |
NUM_ID_INT = 4 | |
enum | { NUM_ID_INT = 4 } |
Private Attributes | |
string | filename |
IOMode | rw_mode |
FILE * | dm4file |
bool | is_big_endian |
bool | initialized |
GatanDM4::TagTable * | tagtable |
Each file starts with a TagGroupWithVersion record which saves the root TagGroup with some additional information.
Gatan DM4 file is a hierarchical binary image format. Everything in the image is a <key, value> pair, where key may be a container-type key which contains more key/value pairs. To read its header information, the whole file has to be parsed. During parsing, we check the keys that we are interested in and get their values.
The real binary data itself is also in this key/value hierarchy.
1 Gatan DM4 file contains 1 2D image.
All data is saved by default with big endian encoding.
Definition at line 250 of file dm4io.h.
anonymous enum [private] |
Definition at line 260 of file dm4io.h.
00260 { NUM_ID_INT = 4 }; //actually its int+long+int=16 bytes
DM4IO::DM4IO | ( | const string & | filename, | |
IOMode | rw_mode = READ_ONLY | |||
) | [explicit] |
Definition at line 697 of file dm4io.cpp.
References is_big_endian, EMAN::ByteOrder::is_host_big_endian(), and tagtable.
00698 : filename(dm4_filename), rw_mode(rw), dm4file(0), initialized(false) 00699 { 00700 is_big_endian = ByteOrder::is_host_big_endian(); 00701 tagtable = new TagTable(); 00702 }
DM4IO::~DM4IO | ( | ) |
bool DM4IO::is_valid | ( | const void * | first_block | ) | [static] |
Definition at line 766 of file dm4io.cpp.
References data, ENTERFUNC, EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), and EMAN::ByteOrder::swap_bytes().
Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().
00767 { 00768 ENTERFUNC; 00769 00770 if (!first_block) { 00771 return false; 00772 } 00773 00774 const int *data = static_cast < const int *>(first_block); 00775 00776 int img_ver = data[0]; 00777 int byte_order = data[3]; 00778 if (ByteOrder::is_data_big_endian(&img_ver) != ByteOrder::is_host_big_endian()) { 00779 ByteOrder::swap_bytes(&img_ver); 00780 ByteOrder::swap_bytes(&byte_order); 00781 } 00782 00783 if (img_ver != 4) { 00784 return false; 00785 } 00786 00787 if (byte_order != 0 && byte_order != 1) { 00788 return false; 00789 } 00790 00791 return true; 00792 }
FILE* EMAN::DM4IO::dm4file [private] |
string EMAN::DM4IO::filename [private] |
bool EMAN::DM4IO::initialized [private] |
bool EMAN::DM4IO::is_big_endian [private] |
IOMode EMAN::DM4IO::rw_mode [private] |
GatanDM4::TagTable* EMAN::DM4IO::tagtable [private] |