可変スライスの長さ、画像の高さが640、画像の幅が512のボリュームファイルがあります。高さが620、幅がファイルに変換したい420のファイルを作成し、新しいファイルに書き込みます。私は、高さの上から20ピクセルを取り除き、このサイズ変更を行うために幅の各辺を46から取り除きたいと思います。各ピクセルは符号なし16ビットです。私は実際の操作をどうやって行うのか分かりません。ボリュームファイルの長さと幅をC++でサイズ変更
これは私が私のメインに持っているものです。
FILE* pfile = NULL;
FILE* pfile2 = NULL;
pFile = fopen("test.vol", "rb");
fseek (pFile , 0 , SEEK_END);
int fileData = ftell(pFile);
rewind(pFile);
char* FileBuffer = new char[fileData];
fread(FileBuffer, fileData, 1, pFile);
int height = 640;
int width = 512;
int slizeSize = height * width * 2;
int sliceCount = fileData/sliceSize;
uint16_t pixels;
int newHeight = height - 20;
int newWidth = width - 92;
int newSliceSize = newHeight * newWidth * 2;
int newImageSize = newSliceSize * sliceCount;
char* NewFileBuffer = new char[newImageSize];
for (int i = 0; i < newHeight; i++) {
for (int i = 0; i < newWidth; i++) {
}
// need help in these for loops and after
}
fclose (pFile);
free (FileBuffer);
pFile2 = fopen("test2.vol", "wb");
fwrite(NewFileBuffer, NewImageSize, 1, pFile2);
を。エラー: 'data_type'の前に予想されるネストされた名前指定子がエラーの連鎖反応を引き起こしたようです – user1984300
私はC++ 11と98でコンパイルを試みましたが、まだエラーがあります – user1984300
問題を修正しました。現在、私は "std :: bad_cast"のインスタンスをスローした後に呼び出されて終了しています。 何():std :: bad_cast アボート(コアダンプ) – user1984300