Re: [Gdcm2] Buffer problem in Qt environment
Cross-platform DICOM implementation
Brought to you by:
malat
|
From: Sylvain A. <syl...@ho...> - 2009-06-02 14:54:57
|
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.
By the way, does everyone know if there's a way to access the dicom pixel information for a known location (i, j) ?
Thank you again, and sorry for double email.
Scorpe51
From: syl...@ho...
To: gdc...@li...
Subject: Buffer problem in Qt environment
Date: Tue, 2 Jun 2009 14:29:22 +0000
Hi everyone,
I'm fairly new to this (GDCM, GUI developing), and haven't been hard coding for a while.
Here's my problem. I finally managed to add GDCM librairies to Qt Creator (the Qt IDE), in which I'm developing my program.
I need to open DICOM images, display them and access to pixel informations (and some tags such as pixel size in mm, this kinda stuff).
To do so, I want to open DICOM images with GDCM, get the buffer in a unsigned char and build a Qt-owned image class with this buffer.
The thing is that, opening an image using ImageReader is working well, but getting the buffer is crashing the program (Memory cannot be "written").
Here's the code:
------------------------------------------------------------
gdcm::ImageReader ir;
ir.SetFileName("dicom.ima");
if(!ir.Read())
{
//Read failed
}
gdcm::Image &gimage = ir.GetImage();
const unsigned int* dimension = gimage.GetDimensions();
int dimX = int(dimension[0]);
int dimY = int(dimension[1]);
unsigned long bufLength = gimage.GetBufferLength();
long *buffer = new long(bufLength);
gimage.GetBuffer((char *)buffer);
const unsigned char *buffer2 = (const unsigned char *)buffer;
QImage *imageQt = new QImage(buffer2, dimX, dimY, QImage::Format_Indexed8);
------------------------------------------------------------
The class QImage allows me to access pixels and display the image.
I've also tried a
char *buffer = new char(dimX*dimY);
But it doesn't work. When debugging, it stops at the function GetBuffer().
Does anyone have an idea?
Thank you,
Scorpe51
Souhaitez vous « être au bureau sans y être » ? Oui je le veux !
_________________________________________________________________
Découvrez toutes les possibilités de communication avec vos proches
http://www.microsoft.com/windows/windowslive/default.aspx |