一. 如下图: Dicom数据集结构
示例使用: (1)开发工具: qt5.14.2; 注意代码中的日志打印qDebug,(2)代码本身与QT无关方便移植
DicomFile *pData = new DicomFile;
pData->read_diconde("D://10_work//09_nengyu//20_DICONDE//w001.DICONDE");
//1280: dicode文件宽, 1024是行,注意log日志有
QImage image = QImage(pData->m_p_buf_pixel_data,1280,1024,QImage::Format_Grayscale16);
二.编码:常量部份
#ifndef GLOBAL_CONST_H
#define GLOBAL_CONST_H
///常量↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
#define DATA_LENGTH_256 256
#define BOOL_FALSE 0
#define BOOL_TRUE 1
#define INT_0 0
#define INT_1 1
#define INT_16 16
#define INT_30 30
#define INT_100 100
#define INT_255 255
#define INT_256 256
#define INT_700 700
#define INT_1000 1000
#define INT_1024 1024
#define STRING_EMPTY ""
#define PATH_D "D:\\DIYE\\"
///常量↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
///协议文档:<<DICOM Part 5 Data Structures and Encoding.pdf & DICOM Part 6 Data Dictionary.pdf>>↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
#define DICOM_D_0x44 0x44 //D:DICOM文件格式是以DICM打头的
#define DICOM_I_0x49 0x49 //I:DICOM文件格式是以DICM打头的
#define DICOM_C_0x43 0x43 //C:DICOM文件格式是以DICM打头的
#define DICOM_M_0x4D 0x4D //M:DICOM文件格式是以DICM打头的
#define DICOM_TAG_0200_0000 "dicom_tag_0200_0000"
#define DICOM_KEYWORD_0200_0000 "file_meta_information_group_length"
#define DICOM_TAG_0200_0001 "dicom_tag_0200_0001"
#define DICOM_KEYWORD_0200_0001 "private_information_creator_uid"
#define DICOM_TAG_0200_0100 "dicom_tag_0200_0100"
#define DICOM_KEYWORD_0200_0100 "file_meta_information_version"
#define DICOM_TAG_0200_0200 "dicom_tag_0200_0200"
#define DICOM_KEYWORD_0200_0200 "media_storage_sop_class_uid"
#define DICOM_TAG_0200_0201 "dicom_tag_0200_0201"
#define DICOM_KEYWORD_0200_0201 "private_information"
#define DICOM_TAG_0200_0300 "dicom_tag_0200_0300"
#define DICOM_KEYWORD_0200_0300 "media_storage_sop_instance_uid"
#define DICOM_TAG_0200_1000 "dicom_tag_0200_1000"
#define DICOM_KEYWORD_0200_1000 "transfer_syntax_uid"
#define DICOM_TAG_0200_1200 "dicom_tag_0200_1200"
#define DICOM_KEYWORD_0200_1200 "implementation_class_uid"
#define DICOM_TAG_0200_1300 "dicom_tag_0200_1300"
#define DICOM_KEYWORD_0200_1300 "implementation_version_name"
#define DICOM_TAG_0200_1600 "dicom_tag_0200_1600"
#define DICOM_KEYWORD_0200_1600 "source_application_entity_title"
#define DICOM_TAG_0800_0000 "dicom_tag_0800_0000"
#define DICOM_KEYWORD_0800_0000 "" //空注释
#define DICOM_TAG_0800_0500 "dicom_tag_0800_0500"
#define DICOM_KEYWORD_0800_0500 "specific_character_set"
#define DICOM_TAG_0800_0800 "dicom_tag_0800_0800"
#define DICOM_KEYWORD_0800_0800 "image_type"
#define DICOM_TAG_0800_1200 "dicom_tag_0800_1200"
#define DICOM_KEYWORD_0800_1200 "instance_creation_date"
#define DICOM_TAG_0800_1300 "dicom_tag_0800_1300"
#define DICOM_KEYWORD_0800_1300 "instance_creation_time"
#define DICOM_TAG_0800_1600 "dicom_tag_0800_1600"
#define DICOM_KEYWORD_0800_1600 "sop_class_uid"
#define DICOM_TAG_0800_1800 "dicom_tag_0800_1800"
#define DICOM_KEYWORD_0800_1800 "sop_instance_uid"
#define DICOM_TAG_0800_2000 "dicom_tag_0800_2000"
#define DICOM_KEYWORD_0800_2000 "study_date"
#define DICOM_TAG_0800_2100 "dicom_tag_0800_2100"
#define DICOM_KEYWORD_0800_2100 "series_date"
#define DICOM_TAG_0800_2200 "dicom_tag_0800_2200"
#define DICOM_KEYWORD_0800_2200 "acquisition_date"
#define DICOM_TAG_0800_2300 "dicom_tag_0800_2300"
#define DICOM_KEYWORD_0800_2300 "content_date"
#define DICOM_TAG_0800_2A00 "dicom_tag_0800_2A00"
#define DICOM_KEYWORD_0800_2A00 "acquisition_dateTime"
#define DICOM_TAG_0800_3000 "dicom_tag_0800_3000"
#define DICOM_KEYWORD_0800_3000 "study_time"
#define DICOM_TAG_0800_3100 "dicom_tag_0800_3100"
#define DICOM_KEYWORD_0800_3100 "series_time"
#define DICOM_TAG_0800_3200 "dicom_tag_0800_3200"
#define DICOM_KEYWORD_0800_3200 "acquisition_time"
#define DICOM_TAG_0800_3300 "dicom_tag_0800_3300"
#define DICOM_KEYWORD_0800_3300 "content_time"
#define DICOM_TAG_0800_6000 "dicom_tag_0800_6000"
#define DICOM_KEYWORD_0800_6000 "modality"
#define DICOM_TAG_0800_6100 "dicom_tag_0800_6100"
#define DICOM_KEYWORD_0800_6100 "modality_in_study"
#define DICOM_TAG_0800_6400 "dicom_tag_0800_6400"
#define DICOM_KEYWORD_0800_6400 "conversion_type"
#define DICOM_TAG_0800_0102 "dicom_tag_0800_0102"
#define DICOM_KEYWORD_0800_0102 "timezone_offset_from_utc"
#define DICOM_TAG_0800_3E10 "dicom_tag_0800_3E10"
#define DICOM_KEYWORD_0800_3E10 "" //空注释
#define DICOM_TAG_1000_1000 "dicom_tag_1000_1000"
#define DICOM_KEYWORD_1000_1000 "patient_name"
#define DICOM_TAG_1000_2000 "dicom_tag_1000_2000"
#define DICOM_KEYWORD_1000_2000 "patient_id"
#define DICOM_TAG_1800_1410 "dicom_tag_1800_1410"
#define DICOM_KEYWORD_1800_1410 "time_of_secondary_capture"
#define DICOM_TAG_1800_5010 "dicom_tag_1800_5010"
#define DICOM_KEYWORD_1800_5010 "spatial_resolution"
#define DICOM_TAG_1800_0213 "dicom_tag_1800_0213"
#define DICOM_KEYWORD_1800_0213 "scan_length"
#define DICOM_TAG_2000_0D00 "dicom_tag_2000_0D00"
#define DICOM_KEYWORD_2000_0D00 "study_instance_uid"
#define DICOM_TAG_2000_0E00 "dicom_tag_2000_0E00"
#define DICOM_KEYWORD_2000_0E00 "series_instance_uid"
#define DICOM_TAG_2000_1000 "dicom_tag_2000_1000"
#define DICOM_KEYWORD_2000_1000 "study_id"
#define DICOM_TAG_2000_1100 "dicom_tag_2000_1100"
#define DICOM_KEYWORD_2000_1100 "series_number"
#define DICOM_TAG_2000_1300 "dicom_tag_2000_1300"
#define DICOM_KEYWORD_2000_1300 "instance_number"
#define DICOM_TAG_2800_0200 "dicom_tag_2800_0200"
#define DICOM_KEYWORD_2800_0200 "samples_per_pixel"
#define DICOM_TAG_2800_0400 "dicom_tag_2800_0400"
#define DICOM_KEYWORD_2800_0400 "photometric_interpretation"
#define DICOM_TAG_2800_0800 "dicom_tag_2800_0800"
#define DICOM_KEYWORD_2800_0800 "number_of_frames"
#define DICOM_TAG_2800_0600 "dicom_tag_2800_0600"
#define DICOM_KEYWORD_2800_0600 "planar_configuration"
#define DICOM_TAG_2800_1000 "dicom_tag_2800_1000"
#define DICOM_KEYWORD_2800_1000 "rows"
#define DICOM_TAG_2800_1100 "dicom_tag_2800_1100"
#define DICOM_KEYWORD_2800_1100 "columns"
#define DICOM_TAG_2800_3000 "dicom_tag_2800_3000"
#define DICOM_KEYWORD_2800_3000 "pixel_spacing"
#define DICOM_TAG_2800_0001 "dicom_tag_2800_0001"
#define DICOM_KEYWORD_2800_0001 "" //空注释
#define DICOM_TAG_2800_0101 "dicom_tag_2800_0101"
#define DICOM_KEYWORD_2800_0101 "" //空注释
#define DICOM_TAG_2800_0201 "dicom_tag_2800_0201"
#define DICOM_KEYWORD_2800_0201 "high_bit"
#define DICOM_TAG_2800_0301 "dicom_tag_2800_0301"
#define DICOM_KEYWORD_2800_0301 "pixel_representation"
#define DICOM_TAG_2800_5010 "dicom_tag_2800_5010"
#define DICOM_KEYWORD_2800_5010 "window_center"
#define DICOM_TAG_2800_5110 "dicom_tag_2800_5110"
#define DICOM_KEYWORD_2800_5110 "window_width"
#define DICOM_TAG_2800_1221 "dicom_tag_2800_1221"
#define DICOM_KEYWORD_2800_1221 "lossy_image_compression_radio"
#define DICOM_TAG_2900_1010 "dicom_tag_2900_1010" //整个文档没有找到0029组号
#define DICOM_KEYWORD_2900_1010 ""
#define DICOM_TAG_2900_1110 "dicom_tag_2900_1110" //整个文档没有找到0029组号
#define DICOM_KEYWORD_2900_1110 ""
#define DICOM_TAG_2900_1210 "dicom_tag_2900_1210" //整个文档没有找到0029组号
#define DICOM_KEYWORD_2900_1210 ""
#define DICOM_TAG_2900_1310 "dicom_tag_2900_1310" //整个文档没有找到0029组号
#define DICOM_KEYWORD_2900_1310 ""
#define DICOM_TAG_2900_1410 "dicom_tag_2900_1410" //整个文档没有找到0029组号
#define DICOM_KEYWORD_2900_1410 ""
#define DICOM_TAG_2900_2410 "dicom_tag_2900_2410" //整个文档没有找到0029组号
#define DICOM_KEYWORD_2900_2410 ""
#define DICOM_TAG_2900_2510 "dicom_tag_2900_2510" //整个文档没有找到0029组号
#define DICOM_KEYWORD_2900_2510 ""
#define DICOM_TAG_7000_1A03 "dicom_tag_7000_1A03"
#define DICOM_KEYWORD_7000_1A03 "Fiducial_uid"
#define DICOM_TAG_0A30_2B02 "dicom_tag_0A30_2B02"
#define DICOM_KEYWORD_0A30_2B02 "source_strength"
#define DICOM_TAG_0050_1000 "dicom_tag_0050_1000" //整个文档没有找到0029组号
#define DICOM_KEYWORD_0050_1000 ""
#define DICOM_TAG_0050_0030 "dicom_tag_0050_0030" //整个文档没有找到0029组号
#define DICOM_KEYWORD_0050_0030 ""
#define DICOM_TAG_E07F_1000 "dicom_tag_E07F_1000"
#define DICOM_KEYWORD_E07F_1000 "pixel_data"
///协议文档:<<DICOM Part 5 Data Structures and Encoding.pdf & DICOM Part 6 Data Dictionary.pdf>>↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
#endif // GLOBAL_CONST_H
三.编码:DicomFile.h
#ifndef DICOMFILE_H
#define DICOMFILE_H
#include <QObject>
#include <QFile>
#include <map>
extern "C"{
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <unistd.h>
}
#include "global_const.h"
#include "global_struct.h"
using namespace std;
typedef bool (*f_group_element)(void*);
class DicomFile : public QObject
{
Q_OBJECT
public:
explicit DicomFile(QObject *parent = nullptr);
static bool dicom_tag_E07F_1000(void*);
static bool dicom_tag_0050_0030(void*);
static bool dicom_tag_0050_1000(void*);
static bool dicom_tag_0A30_2B02(void*);
static bool dicom_tag_7000_1A03(void*);
static bool dicom_tag_2900_2510(void*);
static bool dicom_tag_2900_2410(void*);
static bool dicom_tag_2900_1410(void*);
static bool dicom_tag_2900_1310(void*);
static bool dicom_tag_2900_1210(void*);
static bool dicom_tag_2900_1110(void*);
static bool dicom_tag_2900_1010(void*);
static bool dicom_tag_2800_1221(void*);
static bool dicom_tag_2800_5110(void*);
static bool dicom_tag_2800_5010(void*);
static bool dicom_tag_2800_0301(void*);
static bool dicom_tag_2800_0201(void*);
static bool dicom_tag_2800_0101(void*);
static bool dicom_tag_2800_0001(void*);
static bool dicom_tag_2800_3000(void*);
static bool dicom_tag_2800_1100(void*);
static bool dicom_tag_2800_1000(void*);
static bool dicom_tag_2800_0800(void*);
static bool dicom_tag_2800_0600(void*);
static bool dicom_tag_2800_0400(void*);
static bool dicom_tag_2800_0200(void*);
static bool dicom_tag_2000_1300(void*);
static bool dicom_tag_2000_1100(void*);
static bool dicom_tag_2000_1000(void*);
static bool dicom_tag_2000_0E00(void*);
static bool dicom_tag_2000_0D00(void*);
static bool dicom_tag_1800_0213(void*);
static bool dicom_tag_1800_5010(void*);
static bool dicom_tag_1800_1410(void*);
static bool dicom_tag_1000_2000(void*);
static bool dicom_tag_1000_1000(void*);
static bool dicom_tag_0800_3E10(void*);
static bool dicom_tag_0800_0102(void*);
static bool dicom_tag_0800_6400(void*);
static bool dicom_tag_0800_6100(void*);
static bool dicom_tag_0800_6000(void*);
static bool dicom_tag_0800_3300(void*);
static bool dicom_tag_0800_3200(void*);
static bool dicom_tag_0800_3100(void*);
static bool dicom_tag_0800_3000(void*);
static bool dicom_tag_0800_2A00(void*);
static bool dicom_tag_0800_2300(void*);
static bool dicom_tag_0800_2200(void*);
static bool dicom_tag_0800_2100(void*);
static bool dicom_tag_0800_2000(void*);
static bool dicom_tag_0800_1800(void*);
static bool dicom_tag_0800_1600(void*);
static bool dicom_tag_0800_1300(void*);
static bool dicom_tag_0800_1200(void*);
static bool dicom_tag_0800_0800(void*);
static bool dicom_tag_0800_0500(void*);
static bool dicom_tag_0800_0000(void*);
static bool dicom_tag_0200_1600(void*);
static bool dicom_tag_0200_1300(void*);
static bool dicom_tag_0200_1200(void*);
static bool dicom_tag_0200_1000(void*);
static bool dicom_tag_0200_0300(void*);
static bool dicom_tag_0200_0201(void*);
static bool dicom_tag_0200_0200(void*);
static bool dicom_tag_0200_0100(void*);
static bool dicom_tag_0200_0001(void*);
static bool dicom_tag_0200_0000(void*);
void read_diconde(QString);
/**
* @brief 当前文件有效性标记位一定是在文件的index=128,129,130,131处
* @param p_file_diconde
* @return true; 文件有效
*/
bool get_is_valid_diconde_file(FILE *p_file_diconde);
inline bool parse_dicom_file_data_vr(const unsigned char*);
inline bool parse_value_lenght(const unsigned char*,FILE *p_file_diconde);
inline bool parse_value_byte_lenght(FILE *p_file_diconde);
inline bool parse_value_field(FILE *p_file_diconde);
bool get_pixel_data(FILE *p_file_diconde);
/**
* @brief 将16进制字节串转换成ASCII码表示的16进制字符串
* @param buf:16进制字节串 Demo: 0x22 0x23
* @param length Demo: 2
* @param out Demo: 2233
* @return 字符串长度 Demo: 4
*/
inline int hex_to_string(unsigned char *buf, int length, char *out);
inline int hex_to_int_little_endian(unsigned char* src, int offset);
signals:
private:
int m_diconde_file_byte_count; //DICOM文件字节总数
GlobalStruct::DICOM_FILE_META_ELEMENTS_LIST m_dicm_file_meta_elements_list; //DICOM的单个数据元数
GlobalStruct::DICOM_FILE_META_ELEMENTS m_dicom_file_meta_elements; //DICOM的所有数据元数集
std::map<string,f_group_element> m_f_map; //DICOM的Dataset的TAG
bool m_is_tag_e07f_1000;int m_pixel_data_length; //图像数据标志位
bool m_is_tag_rows; int m_rows; //图像的行像素
bool m_is_tag_columns; int m_columns; //图像的列像素
public:
unsigned char *m_p_buf_pixel_data;
};
#endif // DICOMFILE_H
四.编码DicomFile.cpp
#include "dicomfile.h"
DicomFile::DicomFile(QObject *parent) : QObject(parent),m_diconde_file_byte_count(0)
,m_is_tag_e07f_1000(false),m_pixel_data_length(0),m_is_tag_rows(false),m_rows(0)
,m_is_tag_columns(false),m_columns(0),m_p_buf_pixel_data(nullptr)
{
m_f_map.clear();
m_f_map.insert(std::make_pair(DICOM_TAG_0200_0000,dicom_tag_0200_0000));
m_f_map.insert(std::make_pair(DICOM_TAG_0200_0001,dicom_tag_0200_0001));
m_f_map.insert(std::make_pair(DICOM_TAG_0200_0100,dicom_tag_0200_0100));
m_f_map.insert(std::make_pair(DICOM_TAG_0200_0200,dicom_tag_0200_0200));
m_f_map.insert(std::make_pair(DICOM_TAG_0200_0201,dicom_tag_0200_0201));
m_f_map.insert(std::make_pair(DICOM_TAG_0200_0300,dicom_tag_0200_0300));
m_f_map.insert(std::make_pair(DICOM_TAG_0200_1000,dicom_tag_0200_1000));
m_f_map.insert(std::make_pair(DICOM_TAG_0200_1200,dicom_tag_0200_1200));
m_f_map.insert(std::make_pair(DICOM_TAG_0200_1300,dicom_tag_0200_1300));
m_f_map.insert(std::make_pair(DICOM_TAG_0200_1600,dicom_tag_0200_1600));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_0000,dicom_tag_0800_0000));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_0500,dicom_tag_0800_0500));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_0800,dicom_tag_0800_0800));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_1200,dicom_tag_0800_1200));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_1300,dicom_tag_0800_1300));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_1600,dicom_tag_0800_1600));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_1800,dicom_tag_0800_1800));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_2000,dicom_tag_0800_2000));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_2100,dicom_tag_0800_2100));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_2200,dicom_tag_0800_2200));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_2300,dicom_tag_0800_2300));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_2A00,dicom_tag_0800_2A00));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_3000,dicom_tag_0800_3000));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_3100,dicom_tag_0800_3100));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_3200,dicom_tag_0800_3200));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_3300,dicom_tag_0800_3300));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_6000,dicom_tag_0800_6000));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_6100,dicom_tag_0800_6100));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_6400,dicom_tag_0800_6400));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_0102,dicom_tag_0800_0102));
m_f_map.insert(std::make_pair(DICOM_TAG_0800_3E10,dicom_tag_0800_3E10));
m_f_map.insert(std::make_pair(DICOM_TAG_1000_1000,dicom_tag_1000_1000));
m_f_map.insert(std::make_pair(DICOM_TAG_1000_2000,dicom_tag_1000_2000));
m_f_map.insert(std::make_pair(DICOM_TAG_1800_1410,dicom_tag_1800_1410));
m_f_map.insert(std::make_pair(DICOM_TAG_1800_5010,dicom_tag_1800_5010));
m_f_map.insert(std::make_pair(DICOM_TAG_1800_0213,dicom_tag_1800_0213));
m_f_map.insert(std::make_pair(DICOM_TAG_2000_0D00,dicom_tag_2000_0D00));
m_f_map.insert(std::make_pair(DICOM_TAG_2000_0E00,dicom_tag_2000_0E00));
m_f_map.insert(std::make_pair(DICOM_TAG_2000_1000,dicom_tag_2000_1000));
m_f_map.insert(std::make_pair(DICOM_TAG_2000_1100,dicom_tag_2000_1100));
m_f_map.insert(std::make_pair(DICOM_TAG_2000_1300,dicom_tag_2000_1300));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_0200,dicom_tag_2800_0200));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_0400,dicom_tag_2800_0400));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_0600,dicom_tag_2800_0600));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_0800,dicom_tag_2800_0800));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_1000,dicom_tag_2800_1000));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_1100,dicom_tag_2800_1100));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_3000,dicom_tag_2800_3000));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_0001,dicom_tag_2800_0001));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_0101,dicom_tag_2800_0101));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_0201,dicom_tag_2800_0201));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_0301,dicom_tag_2800_0301));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_5010,dicom_tag_2800_5010));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_5110,dicom_tag_2800_5110));
m_f_map.insert(std::make_pair(DICOM_TAG_2800_1221,dicom_tag_2800_1221));
m_f_map.insert(std::make_pair(DICOM_TAG_2900_1010,dicom_tag_2900_1010)); //???
m_f_map.insert(std::make_pair(DICOM_TAG_2900_1110,dicom_tag_2900_1110));
m_f_map.insert(std::make_pair(DICOM_TAG_2900_1210,dicom_tag_2900_1210));
m_f_map.insert(std::make_pair(DICOM_TAG_2900_1310,dicom_tag_2900_1310));
m_f_map.insert(std::make_pair(DICOM_TAG_2900_1410,dicom_tag_2900_1410));
m_f_map.insert(std::make_pair(DICOM_TAG_2900_2410,dicom_tag_2900_2410));
m_f_map.insert(std::make_pair(DICOM_TAG_2900_2510,dicom_tag_2900_2510));
m_f_map.insert(std::make_pair(DICOM_TAG_7000_1A03,dicom_tag_7000_1A03));
m_f_map.insert(std::make_pair(DICOM_TAG_0A30_2B02,dicom_tag_0A30_2B02));
m_f_map.insert(std::make_pair(DICOM_TAG_0050_1000,dicom_tag_0050_1000));
m_f_map.insert(std::make_pair(DICOM_TAG_0050_0030,dicom_tag_0050_0030));
m_f_map.insert(std::make_pair(DICOM_TAG_E07F_1000,dicom_tag_E07F_1000)); //图像数据TAG
}
bool DicomFile::dicom_tag_E07F_1000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
p_dicom_file->m_is_tag_e07f_1000 = true;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_E07F_1000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_E07F_1000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0050_0030(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0050_0030);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0050_0030=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0050_1000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0050_1000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0050_1000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0A30_2B02(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0A30_2B02);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0A30_2B02=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_7000_1A03(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_7000_1A03);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_7000_1A03=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2900_2510(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2900_2510);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2900_2510=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2900_2410(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2900_2410);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2900_2410=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2900_1410(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2900_1410);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2900_1410=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2900_1310(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2900_1310);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2900_1310=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2900_1210(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2900_1210);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2900_1210=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2900_1110(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2900_1110);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2900_1110=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2900_1010(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2900_1010);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2900_1010=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_1221(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_1221);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_1221=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_5110(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_5110);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_5110=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_5010(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_5010);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_5010=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_0301(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_0301);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_0301=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_0201(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_0201);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_0201=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_0101(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_0101);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_0101=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_0001(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_0001);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_0100=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_3000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_3000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_3000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_1100(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
p_dicom_file->m_is_tag_columns=true;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_1100);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_1100=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_1000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
p_dicom_file->m_is_tag_rows=true;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_1000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_1000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_0800(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_0800);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_0800=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_0600(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_0600);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_0600=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_0400(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_0400);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_0400=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2800_0200(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2800_0200);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2800_0200=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2000_1300(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2000_1300);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2000_1300=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2000_1100(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2000_1100);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2000_1100=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2000_1000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2000_1000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2000_1000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2000_0E00(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2000_0E00);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2000_0E00=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_2000_0D00(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_2000_0D00);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_2000_0D00=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_1800_0213(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_1800_0213);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_1800_0213=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_1800_5010(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_1800_5010);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_1800_5010=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_1800_1410(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_1800_1410);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_1800_1410=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_1000_2000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_1000_2000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_1000_2000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_1000_1000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_1000_1000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_1000_1000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_3E10(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_3E10);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_3E10=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_0102(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_0102);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_0102=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_6400(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_6400);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_6400=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_6100(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_6100);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_6100=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_6000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_6000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_6000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_3300(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_3300);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_3300=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_3200(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_3200);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_3200=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_3100(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_3100);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_3100=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_3000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_3000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_3000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_2A00(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_2A00);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_2A00=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_2300(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_2300);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_2300=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_2200(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_2200);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_2200=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_2100(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_2100);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_2100=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_2000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_2000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_2000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_1800(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_1800);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_1800=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_1600(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_1600);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_1600=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_1300(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_1300);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_1300=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_1200(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_1200);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_1200=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_0800(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_0800);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_0800=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_0000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_0000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_0000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0800_0500(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0800_0500);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0800_0500=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_1600(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_1600);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_1600=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_1300(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_1300);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_1300=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_1200(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_1200);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_1200=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_1000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_1000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_1000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_0300(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_0300);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_0300=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_0201(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_0201);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_0201=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_0200(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_0200);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_0200=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_0100(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_0100);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_0100=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_0001(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_0001);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_0001=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
bool DicomFile::dicom_tag_0200_0000(void* arg)
{
char c_keyword[128]; memset(c_keyword,0x00,sizeof(c_keyword));
DicomFile* p_dicom_file = (DicomFile*)arg;
snprintf(c_keyword,sizeof(c_keyword),"%s",DICOM_KEYWORD_0200_0000);
memcpy(p_dicom_file->m_dicom_file_meta_elements.keyword,c_keyword,sizeof(c_keyword));
qDebug("step 2:DICOM_KEYWORD_0200_0000=%s",p_dicom_file->m_dicom_file_meta_elements.keyword);
return true;
}
void DicomFile::read_diconde(QString e)
{
m_diconde_file_byte_count = 0;
m_is_tag_e07f_1000 =false; m_pixel_data_length=0;
m_is_tag_rows=false; m_rows=0;
m_is_tag_columns=false; m_columns=0;
m_p_buf_pixel_data=nullptr;
FILE *p_file_diconde = fopen(e.toLatin1().data(), "rb");
if (nullptr == p_file_diconde)
{
qDebug("read_diconde nullptr == p_file_diconde error file=%s.",e.toLatin1().data());return;
}
if(false == get_is_valid_diconde_file(p_file_diconde))
{
qDebug("step 1 : dicom file error!"); return;
}
memset(&m_dicm_file_meta_elements_list,0x00,sizeof(m_dicm_file_meta_elements_list));
size_t count = 0; int circulation = -1;
int fixed_length = 4; unsigned char buf[fixed_length];
char tag[32]; string key;
do{
qDebug("---------------------------------------------------------------------------------------circulation=%d",++circulation);
memset(&m_dicom_file_meta_elements,0x00,sizeof(m_dicom_file_meta_elements));
fixed_length = 4; buf[fixed_length]; memset(buf,0x00,sizeof(buf));
if(fixed_length == (int)(count = fread(buf, 1, fixed_length, p_file_diconde))) //tag: Registry of DICOM File Meta Elements
{
m_diconde_file_byte_count = m_diconde_file_byte_count + count;
memset(tag,0x00,sizeof(tag));
hex_to_string(buf,fixed_length,tag);
key = (string)tag;
if(m_f_map.find(key) == m_f_map.end()){ goto END_CIRCULATION;}
if(!m_f_map[key](this)){ goto END_CIRCULATION;}
m_dicom_file_meta_elements.group[0]=buf[0];
m_dicom_file_meta_elements.group[1]=buf[1];
m_dicom_file_meta_elements.element[0]=buf[2];
m_dicom_file_meta_elements.element[1]=buf[3];
}
fixed_length = 2; buf[fixed_length]; memset(buf,0x00,sizeof(buf));
if(fixed_length == (int)(count = fread(buf, 1, fixed_length, p_file_diconde))) //vr: Value Representation
{
m_diconde_file_byte_count = m_diconde_file_byte_count + count;
if(!parse_dicom_file_data_vr(buf)){ goto END_CIRCULATION;}
}
if(!parse_value_lenght(buf,p_file_diconde)){goto END_CIRCULATION;} //value_lenght
if(!parse_value_byte_lenght(p_file_diconde)){goto END_CIRCULATION;}; //value_byte_lenght:实际值的长度:小端模式
if(!parse_value_field(p_file_diconde)){goto END_CIRCULATION;}
m_dicm_file_meta_elements_list.elements_length = m_dicm_file_meta_elements_list.elements_length+1;
m_dicm_file_meta_elements_list.elements[circulation]=m_dicom_file_meta_elements;
if(m_is_tag_e07f_1000)
{
get_pixel_data(p_file_diconde);
goto END_CIRCULATION;
}
}while(0 < (int)count);
END_CIRCULATION:
qDebug("-------------------------------------------------------------------------------------end circulation");
for(int i= 0 ; i <m_dicm_file_meta_elements_list.elements_length;i++)
{
qDebug("i=%d, group[%02x%02x], element[%02x%02x], vr[%02x%02x] ,value_lenght=%d"
",value_byte_lenght[%02x%02x%02x%02x], value_field=%s"
,i,m_dicm_file_meta_elements_list.elements[i].group[0]
,m_dicm_file_meta_elements_list.elements[i].group[1]
,m_dicm_file_meta_elements_list.elements[i].element[0]
,m_dicm_file_meta_elements_list.elements[i].element[1]
,m_dicm_file_meta_elements_list.elements[i].vr[0]
,m_dicm_file_meta_elements_list.elements[i].vr[1]
,m_dicm_file_meta_elements_list.elements[i].value_lenght
,m_dicm_file_meta_elements_list.elements[i].value_byte_lenght[0]
,m_dicm_file_meta_elements_list.elements[i].value_byte_lenght[1]
,m_dicm_file_meta_elements_list.elements[i].value_byte_lenght[2]
,m_dicm_file_meta_elements_list.elements[i].value_byte_lenght[3]
,m_dicm_file_meta_elements_list.elements[i].value_field);
}
clearerr(p_file_diconde);
fclose(p_file_diconde);
qDebug("p_file_diconde=%s; byte count=%d.",e.toLatin1().data(),m_diconde_file_byte_count);
}
bool DicomFile::parse_dicom_file_data_vr(const unsigned char* p_vr)
{
bool ret_val = false;
if((0x55 == p_vr[0] && 0x4C == p_vr[1]) //VR:UL
|| (0x4F == p_vr[0] && 0x42 == p_vr[1]) //VR:OB
|| (0x55 == p_vr[0] && 0x49 == p_vr[1]) //VR:UI
|| (0x53 == p_vr[0] && 0x48 == p_vr[1]) //VR:SH
|| (0x41 == p_vr[0] && 0x45 == p_vr[1]) //VR:AE
|| (0x43 == p_vr[0] && 0x53 == p_vr[1]) //VR:CS
|| (0x44 == p_vr[0] && 0x41 == p_vr[1]) //VR:DA
|| (0x54 == p_vr[0] && 0x4D == p_vr[1]) //VR:TM
|| (0x44 == p_vr[0] && 0x54 == p_vr[1]) //VR:DT
|| (0x4C == p_vr[0] && 0x4F == p_vr[1]) //VR:LO
|| (0x50 == p_vr[0] && 0x4E == p_vr[1]) //VR:PN
|| (0x44 == p_vr[0] && 0x53 == p_vr[1]) //VR:DS
|| (0x49 == p_vr[0] && 0x53 == p_vr[1]) //VR:IS
|| (0x55 == p_vr[0] && 0x53 == p_vr[1]) //VR:US
|| (0x4F == p_vr[0] && 0x57 == p_vr[1]) //VR:OW
){ ret_val = true; }
if(ret_val)
{
m_dicom_file_meta_elements.vr[0]=p_vr[0];
m_dicom_file_meta_elements.vr[1]=p_vr[1];
qDebug("step 3:vr[0]=0x%02x, vr[1]=0x%02x; m_diconde_file_byte_count=%d"
,m_dicom_file_meta_elements.vr[0], m_dicom_file_meta_elements.vr[1],m_diconde_file_byte_count);
}
return ret_val;
}
bool DicomFile::parse_value_lenght(const unsigned char*p_vr,FILE *p_file_diconde)
{
if((0x4F == p_vr[0] && 0x42 == p_vr[1]) //OB
|| (0x4F == p_vr[0] && 0x44 == p_vr[1]) //OD
|| (0x4F == p_vr[0] && 0x46 == p_vr[1]) //OF
|| (0x4F == p_vr[0] && 0x4C == p_vr[1]) //OL
|| (0x4F == p_vr[0] && 0x56 == p_vr[1]) //OV
|| (0x4F == p_vr[0] && 0x57 == p_vr[1]) //OW
|| (0x53 == p_vr[0] && 0x51 == p_vr[1]) //SQ
|| (0x55 == p_vr[0] && 0x43 == p_vr[1]) //UC
|| (0x55 == p_vr[0] && 0x52 == p_vr[1]) //UR
|| (0x55 == p_vr[0] && 0x54 == p_vr[1]) //UT
|| (0x55 == p_vr[0] && 0x4E == p_vr[1])) //UN
{
m_dicom_file_meta_elements.value_lenght = 4;
//参见<<DICOM Part 5 Data Structures and Encoding.pdf>>Page53
//表<Table 7.1-1. Data Element with Explicit VR other than as shown in Table 7.1-2>中字段VR保留
int fixed_length = 2; size_t count = 0;
unsigned char buf[fixed_length]; memset(buf,0x00,sizeof(buf));
count = fread(buf, 1, fixed_length, p_file_diconde);
m_diconde_file_byte_count = m_diconde_file_byte_count + count;
}
else //0x55 == p_vr[0] && 0x4C == p_vr[1] //UL
{ //
m_dicom_file_meta_elements.value_lenght = 2;
}
return true;
}
bool DicomFile::parse_value_byte_lenght(FILE *p_file_diconde)
{
bool ret_val = false;
size_t count = 0;
int fixed_length = m_dicom_file_meta_elements.value_lenght;
unsigned char buf[fixed_length]; memset(buf,0x00,sizeof(buf));
if(fixed_length == (int)(count = fread(buf, 1, fixed_length, p_file_diconde))) //vr: value_byte_lenght
{
ret_val = true;
m_diconde_file_byte_count = m_diconde_file_byte_count + count;
for(int i = 0 ; i<fixed_length;i++)
{
m_dicom_file_meta_elements.value_byte_lenght[i]=buf[i];
qDebug("step 4:0x%02x; m_diconde_file_byte_count=%d",buf[i],m_diconde_file_byte_count);
}
}
return ret_val;
}
bool DicomFile::parse_value_field(FILE *p_file_diconde)
{
bool ret_val = false;
size_t count = 0;
int fixed_length = 0;
if(2 == m_dicom_file_meta_elements.value_lenght)
{
fixed_length = (int)((m_dicom_file_meta_elements.value_byte_lenght[0] & 0xFF)
| ((m_dicom_file_meta_elements.value_byte_lenght[1] & 0xFF) << 8));
}
else if(4 == m_dicom_file_meta_elements.value_lenght)
{
fixed_length = (int)((m_dicom_file_meta_elements.value_byte_lenght[0] & 0xFF)
| ((m_dicom_file_meta_elements.value_byte_lenght[1] & 0xFF) << 8)
| ((m_dicom_file_meta_elements.value_byte_lenght[2] & 0xFF) << 16)
| ((m_dicom_file_meta_elements.value_byte_lenght[3] & 0xFF) << 24));
}
qDebug("step 5:value_field_lenght=%d",fixed_length);
if(m_is_tag_e07f_1000){ m_pixel_data_length = fixed_length; ret_val = true; return ret_val;}
unsigned char buf[fixed_length]; memset(buf,0x00,sizeof(buf));
if(fixed_length == (int)(count = fread(buf, 1, fixed_length, p_file_diconde)))
{
ret_val = true;
m_diconde_file_byte_count = m_diconde_file_byte_count + count;
for(int i = 0 ; i<fixed_length;i++)
{
m_dicom_file_meta_elements.value_field[i]=buf[i];
qDebug("step 5:0x%02x; m_diconde_file_byte_count=%d",buf[i],m_diconde_file_byte_count);
}
qDebug("step 5:value_field=%s", m_dicom_file_meta_elements.value_field);
if(m_is_tag_rows)
{
m_is_tag_rows=false; m_rows= hex_to_int_little_endian(buf,0);
qDebug("step 5:m_rows=%d", m_rows);
}
else if(m_is_tag_columns)
{
m_is_tag_columns=false; m_columns= hex_to_int_little_endian(buf,0);
qDebug("step 5:m_columns=%d", m_columns);
}
}
return ret_val;
}
bool DicomFile::get_pixel_data(FILE *p_file_diconde)
{
bool ret_val = false;
size_t count = 0;
m_p_buf_pixel_data = (unsigned char*)malloc(sizeof(unsigned char) * m_pixel_data_length);
if(m_pixel_data_length == (int)(count = fread(m_p_buf_pixel_data, 1, m_pixel_data_length, p_file_diconde)))
{ ret_val =true; qDebug("step 6:get pixel data successful."); }
else{ qDebug("step 6:get pixel data fail."); }
return ret_val;
}
/**
* @brief 当前文件有效性标记位一定是在文件的index=128,129,130,131处
* @param p_file_diconde
* @return
*/
bool DicomFile::get_is_valid_diconde_file(FILE *p_file_diconde)
{
bool ret_val = false;
size_t count = 0;
int fixed_length = 4;
unsigned char buf[fixed_length]; memset(buf,0x00,sizeof(buf));
while((fixed_length == (int)(count = fread(buf, 1, fixed_length, p_file_diconde)))
&& 132 >= m_diconde_file_byte_count)
{
m_diconde_file_byte_count = m_diconde_file_byte_count + count;
if(buf[0] == DICOM_D_0x44 && buf[1] == DICOM_I_0x49
&& buf[2] == DICOM_C_0x43 && buf[3] == DICOM_M_0x4D)
{
qDebug("step 1:dicom file OK!");
ret_val = true; break;
}
memset(buf,0x00,sizeof(buf));
}
return ret_val;
}
/**
* @brief 将16进制字节串转换成ASCII码表示的16进制字符串
* @param buf:16进制字节串 Demo: 0x22 0x23
* @param length Demo: 2
* @param out Demo: dicom_tag_0200_0000
* @return 字符串长度 Demo: 4
*/
int DicomFile::hex_to_string(unsigned char *buf, int length, char *out)
{
strcat(out,"dicom_tag_");
char tmp[8];
for(int i= 0 ;i < length; i++)
{
memset(tmp,0x00,sizeof(tmp));
if(2==i){ sprintf(tmp, "_%02X", buf[i]);}
else{sprintf(tmp, "%02X", buf[i]);}
strcat(out, tmp);
}
qDebug("%s",out);
return length * 2;
}
/**
* @brief DicomFile::bytes_to_int_little_endian
* @param src
* @param offset
* @return
*/
int DicomFile::hex_to_int_little_endian(unsigned char* src, int offset)
{
int value;
value = (int) ((src[offset] & 0xFF)
| ((src[offset + 1] & 0xFF) << 8));
return value;
}
IT交流