A question about createWindowsDIB and BITMAPINFO

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Wenhui Wang
Posts: 6
Joined: Tue, 2006-07-04, 09:22

A question about createWindowsDIB and BITMAPINFO

#1 Post by Wenhui Wang »

my code :
unsingned bufsize =0;
void * buffer;
bufsize=image->createWindowsDIB(buffer,bufsize,1,8,1)
BITMAPINFO* pDIBInfo = (BITMAPINFO*)buffer;

but the content of pDIBInfo->bmiHeader->biSize ect. are zeros,so i can't display a dicom image. :( :( :evil: :evil:

jayition
Posts: 18
Joined: Thu, 2005-04-21, 04:23
Location: China
Contact:

you haven't malloc memory!

#2 Post by jayition »

unsingned bufsize =0;
void * buffer;
bufsize=image->createWindowsDIB(buffer,bufsize,1,8,1)

To use the CreateWindowsDIB function , the buffer must to malloc memory first , like this :
const int gap = (4 - image->getWidth() & 0x3) & 0x3 ;
const unsigned long bufsize = OFstatic_cast(unsigned long, image->getWidth() + gap) * OFstatic_cast(unsigned long, image->getHeight());
void * buffer=malloc(bufsize );

bufsize=image->createWindowsDIB(buffer,bufsize,1,8,1)

It will work!
Love programming!
My Blog is:
http://pacs.coocn.org

Markus Sabin
Posts: 99
Joined: Tue, 2005-07-12, 13:50
Location: Erlangen, Germany

#3 Post by Markus Sabin »

The name of the method might be confusing. createWindowsDIB does not create a BITMAPINFO header structure. It just renders the DICOM image to a buffer that can be referenced from a BITMAPINFO. In other words: Just the raw buffer is created. You have to build the BITMAPINFO structure yourself.

Wenhui Wang
Posts: 6
Joined: Tue, 2006-07-04, 09:22

#4 Post by Wenhui Wang »

thank you answer very much.would you like take an example of display ing a dicom image. :oops: :oops:

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest