createWindowsDIB changed the width of the image

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
hmmr
Posts: 5
Joined: Tue, 2012-11-27, 09:11

createWindowsDIB changed the width of the image

#1 Post by hmmr »

Could you explain why after calling createWindowsDIB been allocated another number of bytes and was changed width of the image?

Code: Select all

m_spOriginalImage->getDepth();	// 8
m_spOriginalImage->getWidth();	// 1024
m_spOriginalImage->getHeight();	// 1024

const unsigned long nNewWidth = 942;
const unsigned long nNewHeight = 942;

std::shared_ptr<DicomImage> spScaledImage( 
	m_spOriginalImage->createScaledImage(nNewWidth, nNewHeight, 0, 0) );

// 942*942 = 887364
unsigned long nSize = spScaledImage->getWidth() * spScaledImage->getHeight();	

unsigned char * pBuffer = nullptr;
unsigned long  nNewSize = spScaledImage->createWindowsDIB((void*&)pBuffer, nSize, 0, 
	spScaledImage->getDepth(), 1, 1);

// nNewSize = 889248 (!!!)

J. Riesmeier
DCMTK Developer
Posts: 2503
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: createWindowsDIB changed the width of the image

#2 Post by J. Riesmeier »

Reading the documentation (or knowing how the Window DIB format is defined), it should be obvious that the call to createWindowsDIB(..., 1) aligns each line to a 32-bit address. This is what's usually called "padding".

Why don't you just specify a value of 0 for the "size" parameter?

hmmr
Posts: 5
Joined: Tue, 2012-11-27, 09:11

Re: createWindowsDIB changed the width of the image

#3 Post by hmmr »

J. Riesmeier wrote:Why don't you just specify a value of 0 for the "size" parameter?
Thanks, that's clear. Then I'll take this into account when creating images.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest