DicomImage::createWindowsDIB的用法

unsigned long DicomImage::createWindowsDIBvoid *& data,
  const unsigned long size,
  const unsigned long frame = 0,
  const int bits = 24,
  const int upsideDown = 0,
  const int padding = 1
 [inline]

 

create true color (24/32 bit) or palette (8 bit) bitmap for MS Windows.

8 bit images require an appropriate color palette (256 entries, values: 0 to 255) and are only applicable to monochrome images, the beginning of a each line starts on a 32-bit address (if 'padding' is true); 24 bit images store 24 bits per pixel (RGB) and do align each line to a 32-bit address (if 'padding' is true); 32 bit images store 32 bits per pixel (RGB), but only use the upper 24 bits. The sample order for color images is (i.e. reverse): Blue, Green, Red. The memory buffer can be allocated both externally (from the calling program) and internally (inside this class/module). If the 'data' parameter is not NULL and the 'size' parameter, which describes the size (in bytes) of the allocated buffer, is suffiently large, the bitmap is stored in this buffer. Otherwise (i.e. 'data' is NULL) the memory is allocated internally. Please note that in both cases the memory is not handled internally after this method has finished and, therefore, must be deleted from the calling program. This method does not work if original YCbCr color model is retained (see CIF_KeepYCbCrColorModel).

Parameters:
 data untyped pointer memory buffer (set to NULL if not allocated externally)
 size size of the memory buffer in bytes (if 0 'data' is set to NULL)
 frame index of frame to be converted (default: 0 = first frame)
 bits number of bits per pixel used for the output bitmap (8, 24 or 32, default: 24)
 upsideDown flag indicating whether the first line stored is the top-most (default: 0) or the bottom-most of the source image (as required by the BMP file format)
 padding align each line to a 32-bit address if true (default)
Returns:
number of bytes allocated by the bitmap, or 0 if an error occured

这个函数生成DIB结构的数据区,不包括位图文件头(BITMAPFILEHEADER),位图信息头(BITMAPINFOHEADER),调色板(RGBQUAD[256])

data指向生成的数据区,若调用函数前,程序员为data分配了足够空间,则size为data的大小,DIB图像数据放在该空间内

若没有为data分配空间,size应设为0,在函数内部为data分配空间,并返回DIB图像数据的大小。

需要注意的是在这两种情况下,函数调用完后都没有释放data所指向的空间,需要程序员自己删除。

 

若想显示DIB位图有两种方法:

首先要生成DIB位图信息,

对于8位的DIB来说,需要添加位图信息头(BITMAPINFOHEADER),调色板(RGBQUAD[256])

  在C*view::onDraw()中

::StretchDIBits(pDC->GetSafeHdc(),
// destination rectangle
0,
0, 512, 512,
// source rectangle
0, 0, 512, 512,
((BYTE*)m_pImage+sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQUAD)),  //位图数据
(BITMAPINFO*)m_pImage, //位图信息
DIB_RGB_COLORS, SRCCOPY);

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值