-
fopen
FILE *pf = fopen(fn_license.c_str(),"w");
fprintf(pf, "%s\n", msg.c_str());
fclose(pf);
vector<double> orientation = { 1,0,0,0,1,0,0,0,1 };
memcpy(&cbct_volume->get_orientation()[0], orientation.data(), sizeof(double) * 9);
//orientation的内容拷贝到cbct_volume中
//读取图片像素
FILE *pf = fopen(cbct_file.c_str(), "rb");
PTR<vector<short>> tmp_volume_data(new vector<short>(size[0] * size[1] * size[2], 0));
fread(tmp_volume_data->data(), sizeof(short), size[0] * size[1] * size[2], pf);
cbct_volume->set_pixel(tmp_volume_data);
fclose(pf);
std::string ct_path = patient_dir + "\\ct\\" + ct_id + ".bin";
FILE *pf = fopen(ct_path.c_str(), "rb");
if (pf == NULL)
{
LOGE(_("Load CT is failed!"))
return false;
}
auto&& tmp_volume_data = vol->get_pixel();
if (!tmp_volume_data)
tmp_volume_data = PTR_NEW(std::vector<short>);
tmp_volume_data->assign(size[0] * size[1] * size[2],0);
fread(tmp_volume_data->data(), sizeof(short), size[0] * size[1] * size[2], pf);
fclose(pf);
PTR<std::vector<short>> vol_data;
std::string file_path = save_path + "\\" + file_name + ".bin";
FILE* pf = fopen(file_path.c_str(), "wb");
fwrite(vol_data->data(), sizeof(short), vol_data->size(), pf);
fclose(pf);
std::vector<short> data;
std::string file_path = save_path + "\\" + file_name + ".raw";
FILE* pf = fopen(file_path.c_str(), "wb");
fwrite(&data[0], sizeof(short), data.size(), pf);
fclose(pf);
参考网址;https://blog.csdn.net/qq_34097715/article/details/79970860
https://www.cnblogs.com/zhengfa-af/p/8145443.html
https://blog.csdn.net/weixin_30800807/article/details/97188984