Dcmkによるdcmファイルの生成 2401 ワード c++ #include #include //stringstream #include #include #include #include "dcmtk/config/osconfig.h" #include "dcmtk/dcmdata/dctk.h" #include "dcmtk/dcmdata/dcistrmf.h" #include "dcmtk/dcmdata/libi2d/i2dbmps.h" #pragma comment(lib, "i2d.lib") #pragma comment(lib, "Iphlpapi.lib") using namespace std; int main() { DcmFileFormat fileformat; OFCondition status; DcmDataset* mydatasete = fileformat.getDataset(); Uint16 rows, cols, samplePerPixel, bitsAlloc, bitsStored, highBit, pixelRpr, planConf, pixAspectH, pixAspectV; OFString photoMetrInt; Uint32 length; E_TransferSyntax ts; char* mydata = new char[1024 * 1024 * 10]; memset(mydata, 0, sizeof(char) * 1024 * 1024 * 10); char* tmpData = mydata; char curDir[100]; getcwd(curDir, 100); OFString num; char numtmp[100]; memset(numtmp, 0, sizeof(char) * 100); sprintf(numtmp, "%s\\test\\%d.bmp", curDir, 1); OFString filename = OFString(numtmp); I2DBmpSource* bmpSource = new I2DBmpSource(); bmpSource->setImageFile(filename); char* pixData = NULL; //E_TransferSyntax ts; bmpSource->readPixelData(rows, cols, samplePerPixel, photoMetrInt, bitsAlloc, bitsStored, highBit, pixelRpr, planConf, pixAspectH, pixAspectV, pixData, length, ts); memcpy(tmpData, pixData, length); tmpData += length; delete bmpSource; mydatasete->putAndInsertUint16(DCM_SamplesPerPixel, samplePerPixel); mydatasete->putAndInsertString(DCM_NumberOfFrames, "4"); mydatasete->putAndInsertUint16(DCM_Rows, rows); mydatasete->putAndInsertUint16(DCM_Columns, cols); mydatasete->putAndInsertUint16(DCM_BitsAllocated, bitsAlloc); mydatasete->putAndInsertUint16(DCM_BitsStored, bitsStored); mydatasete->putAndInsertUint16(DCM_HighBit, highBit); mydatasete->putAndInsertUint8Array(DCM_PixelData, (Uint8*)mydata, 4 * length); //mydatasete->putAndInsertUint8Array(DCM_PixelData,(Uint8*)pixData,length); mydatasete->putAndInsertOFStringArray(DCM_PhotometricInterpretation, photoMetrInt); status = fileformat.saveFile("c:\\Multibmp2dcmtest.dcm", ts); if (status.bad()) { std::cout << "Error:(" << status.text() << ")"; } cout << numtmp << endl; system("pause"); } jQueryしか書けなかった自分がVueを使えるようになるまでの話と同じような環境の人たちへ pythonクラスメソッド/インスタンスメソッド/静的メソッド