00001 00005 /* 00006 * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu) 00007 * Copyright (c) 2000-2006 Baylor College of Medicine 00008 * 00009 * This software is issued under a joint BSD/GNU license. You may use the 00010 * source code in this file under either license. However, note that the 00011 * complete EMAN2 and SPARX software packages have some GPL dependencies, 00012 * so you are responsible for compliance with the licenses of these packages 00013 * if you opt to use BSD licensing. The warranty disclaimer below holds 00014 * in either instance. 00015 * 00016 * This complete copyright notice must be included in any revised version of the 00017 * source code. Additional authorship citations may be added, but existing 00018 * author citations must be preserved. 00019 * 00020 * This program is free software; you can redistribute it and/or modify 00021 * it under the terms of the GNU General Public License as published by 00022 * the Free Software Foundation; either version 2 of the License, or 00023 * (at your option) any later version. 00024 * 00025 * This program is distributed in the hope that it will be useful, 00026 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00027 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00028 * GNU General Public License for more details. 00029 * 00030 * You should have received a copy of the GNU General Public License 00031 * along with this program; if not, write to the Free Software 00032 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00033 * 00034 * */ 00035 00036 #ifndef eman__gatan2io_h__ 00037 #define eman__gatan2io_h__ 1 00038 00039 #include "imageio.h" 00040 00041 namespace EMAN 00042 { 00043 00049 class Gatan2IO:public ImageIO 00050 { 00051 public: 00052 explicit Gatan2IO(const string & filename, IOMode rw_mode = READ_ONLY); 00053 ~Gatan2IO(); 00054 00055 DEFINE_IMAGEIO_FUNC; 00056 static bool is_valid(const void *first_block); 00057 private: 00058 enum DataType 00059 { 00060 GATAN2_SHORT = 1, 00061 GATAN2_FLOAT = 2, 00062 GATAN2_COMPLEX = 3, 00063 GATAN2_PACKED_COMPLEX = 5, 00064 GATAN2_CHAR = 6, 00065 GATAN2_INT = 7, 00066 GATAN2_INVALID 00067 }; 00068 00069 struct Gatan2Header 00070 { 00071 short version; 00072 short un1; 00073 short un2; 00074 short nx; 00075 short ny; 00076 short len; 00077 short type; 00078 }; 00079 00080 int to_em_datatype(int gatan_type); 00081 00082 private: 00083 string filename; 00084 IOMode rw_mode; 00085 FILE *gatan2_file; 00086 Gatan2Header gatanh; 00087 00088 bool is_big_endian; 00089 bool initialized; 00090 }; 00091 00092 } 00093 00094 00095 #endif //eman__gatan2io_h__