本文介绍了Setpixel slow,替代setpixel。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将16位dicom数据转换为8位图像。我已将16位数据转换为8位数据。现在我想从这些数据创建位图。我正在使用setpixel这个目的,但似乎要慢得多。任何人都可以建议任何替代方案。我使用的代码如下:
I was trying to convert 16 bit dicom data to 8 bit image. I had converted the 16 bit data to 8 bit data. Now i want to create bitmap from this data. I was using setpixel for this purpose but it seems to be much slower. Can anyone pls suggest any alternative for this. The code i used is as below:
CImage img;
img.Create(m_nWidth, m_nHeight, 32);
for(int i = 0; i < m_nHeight; i++)
{
for(int j = 0; j < m_nWidth; j++)
{
int nPixel = 0;
nPixel = (Input[j][i] - nMinPixel) * fOffset; //conversion to 8bit data
COLORREF clr(RGB(nPixel, nPixel, nPixel)); //nPixel is converted data
img->SetPixel(j, i, clr);
}
}
推荐答案
CImage img;
img.Create(m_nWidth, m_nHeigt, 32);
COLORREF* dib=(COLORREF*)img.GetBits();
for(int i=0; i<m_nheight;i++)>
{
for(int j=0; j<m_nwidth;j++)>
{
int nPixel = 0;
nPixel = (Input[j][i] - nMinPixel)* fOffset;
dib[j+i*m_nWidth]=RGB(nPixel,nPixel,nPixel);
}
}
这篇关于Setpixel slow,替代setpixel。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!