Re: [Gdcm2] Buffer problem in Qt environment
Cross-platform DICOM implementation
Brought to you by:
malat
|
From: Mathieu M. <mat...@gm...> - 2009-06-05 14:55:29
|
Sylvain, On Tue, Jun 2, 2009 at 4:54 PM, Sylvain ADAM<syl...@ho...> wrote: > Okay... My mistake... I haven't quite looked at what I've done. > > Actually the code is working when I'm instanciating a char* like this: > > char *buffer = new char[gimage.GetBufferLength()]; > > I'm still trying to find the right format for my QImage, though, 'cause I've > token an RGB16 format, I can see my dicom image but it's weird. Everything is fine since you are passing the *whole* buffer. You can see the 'char*' as if it was simply a generic void* pointer in C. GetBufferLength (see documentation) will return the size of dimX*dimY*sizeof(pixel=)*numberofpixel So simply do: QImage *imageQt = new QImage(buffer2, dimX, dimY, QImage::Format_RGB888); You should be extremely careful on how you write this code, as it is the most error-prone part. You absolutely need to check the value from image.GetPixelFormat().GetNumberOfSamples and image.GetPhotometricInterpretation to avoid doing any kind of mistake. > By the way, does everyone know if there's a way to access the dicom pixel > information for a known location (i, j) ? Yes, build a QImage and use the API :) HTH -- Mathieu |