#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 | |
bool | is_valid (const void *first_block) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
Private Types | |
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.
|
Definition at line 260 of file dm4io.h. 00260 { NUM_ID_INT = 4 }; //actually its int+long+int=16 bytes
|
|
Definition at line 697 of file dm4io.cpp. References is_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 }
|
|
Definition at line 704 of file dm4io.cpp. References dm4file, and tagtable. 00705 { 00706 if (dm4file) { 00707 fclose(dm4file); 00708 dm4file = 0; 00709 } 00710 if (tagtable) { 00711 delete tagtable; 00712 tagtable = 0; 00713 } 00714 }
|
|
Definition at line 766 of file dm4io.cpp. References data. 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 }
|
|
|
|
Definition at line 264 of file dm4io.h. Referenced by ~DM4IO(). |
|
|
|
|
|
Definition at line 265 of file dm4io.h. Referenced by DM4IO(). |
|
|
|
|