dcmtk 라이브러리를 사용하여 다중 프레임 압축 dicom 이미지의 픽셀 데이터를 수정하고 있습니다. 그래서, for
루프의 한 단계에서 나는 각 압축 해제 된 프레임의 픽셀 데이터를 가져 와서 내 소원에 따라 수정하고 각각의 프레임 데이터를 대용량 메모리 버퍼의 각 픽셀 데이터를 연결하려고 시도합니다. for
루프의 핵심 프로세스는 다음과 같습니다.memcpy를 사용하는 중 메모리 오류가 발생 했습니까?
문제는 첫 번째 반복 후 함수의 코드 행에 메모리를 부여하는 것입니다. getUncompressedFrame
. 나는 그 줄을 제거 할 때 그 때 오류가없고 전체 for 루프가 절대적으로 잘 작동하는 것처럼 줄이 memcpy(fullBuffer+(i*sizeF),newBuffer,sizeF);
때문에 발생한다고 생각합니다.
memcpy로 작업 할 때 실수를 저에게 해 주시겠습니까? 감사.
Uint32 sizeF=828072;// I just wrote it to show what is the data type.
Uint8 * fullBuffer = new Uint8(int(sizeF*numOfFrames));//The big memory buffer
for(int i=0;i<numOfFrames;i++)
{
Uint8 * buffer = new Uint8[int(sizeF)];//Buffer for each frame
Uint8 * newBuffer = new Uint8[int(sizeF)];//Buffer in which the modified frame data is stored
DcmFileCache * cache=NULL;
OFCondition cond=element->getUncompressedFrame(dataset,i,startFragment,buffer,sizeF,decompressedColorModel,cache);
//I get the uncompressed individual frame pixel data
if(buffer != NULL)
{
for(unsigned long y = 0; y < rows; y++)
{
for(unsigned long x = 0; x < cols; x++)
{
if(planarConfiguration==0)
{
if(x>xmin && x<xmax && y>ymin && y<ymax)
{
index=(x + y + y*(cols-1))*samplePerPixel;
if(index<sizeF-2)
{
newBuffer[index] = 0;
newBuffer[index + 1] = 0;
newBuffer[index +2] = 0;
}
}
else
{
index=(x + y + y*(cols-1))*samplePerPixel;
if(index<sizeF-2)
{
newBuffer[index] = buffer[index];
newBuffer[index + 1] = buffer[index + 1];
newBuffer[index + 2] = buffer[index + 2];
}
}
}
}
}
memcpy(fullBuffer+(i*sizeF),newBuffer,sizeF);
//concatenate the modified frame by frame pixel data
}
실행이 경우 거기서 멈추고'i'와'sizeF'의 값을 검사하여 그들이 괜찮아 보이는지 살펴 봅니다. 중지되지 않으면 중단 점을 설정하십시오. –
나는 디버거를 실행했고, sizeF는 적절한 숫자를 제공한다. 이 프로그램은 잘 작동하지만 memcpy와 함께 코드 라인을 사용하지는 않는다.하지만 그것을 사용하면 프로그램이 중단된다. –
sizeF의 데이터 유형 ?? –