将Bayer数据转换成彩色的显示

Tody Guo 2012-07-26 09:39:24
请问各位大侠,我下面的代码怎么总是不能将图像彩色输出呀?目前输出的全是黑白的
目前,我用的SDK是西安方诚的摄像头

//消息处理函数
procedure TForm1.MyTransMsgProc(var msg: TMessage);
var
bChange: Boolean;
pRGB : PRGBTRIPLE;
begin

//成功取到一帧图像数据的消息
if (msg.WParam = WM_FCAM_ONE_RSVD) then
begin
//获得传入的数据信息结构体指针
pCommuInfo := Pointer(msg.LParam); //msg.LParam的值就是信息结构体地址

bChange := False;
if m_lShowWidth <> pCommuInfo.ulFrameWidth then bChange := True;
if m_lShowHeight <> pCommuInfo.ulFrameHeight then bChange := True;
if m_lBitCnt <> pCommuInfo.ulFramePixelBits then bChange := True;

//图像大小有变动,应重新创建绘图资源
if bChange = True then
begin
m_lShowWidth := pCommuInfo.ulFrameWidth;
m_lShowHeight := pCommuInfo.ulFrameHeight;
m_lBitCnt := pCommuInfo.ulFramePixelBits;
//重新创建绘图资源
PrepareForDraw();
//重新设置显示区域位置和大小,居中显示
SetShowZone();
end;

//显示图像, 用户也可使用自己的显示函数
//若需要缩放图像,可调用DrawUtil的缩放显示函数
GetMem(pRGB, 3*pCommuInfo.ulFrameWidth*pCommuInfo.ulFrameHeight); // apply for memory
if FC_Raw2Rgb(pRGB, pCommuInfo.pDataBuffer, pCommuInfo.ulFrameWidth, pCommuInfo.ulFrameHeight
, BAYER_GB, ARITH_COLOR_CORRELATION) = 0 then
begin
StatusBar1.Panels.Items[0].Text := 'BW Format';
end;

//FC_ColorEnhance(pRGB, 3*pCommuInfo.ulFrameWidth*pCommuInfo.ulFrameHeight);

// FD_DrawActualImage(m_hDraw, pCommuInfo.pDataBuffer, pCommuInfo.ulFrameAvaliableSizes, 0, 0);
FD_DrawActualImage(m_hDraw, pRGB, 3*pCommuInfo.ulFrameWidth*pCommuInfo.ulFrameHeight, 0, 0);
// Check this function for screenshot.
// FD_DrawImage(m_hDraw, pRGB, 3*pCommuInfo.ulFrameWidth*pCommuInfo.ulFrameHeight, 0, 0, 0, 0);


freeMem(pRGB); // destory memory

// FD_DrawImage(m_hDraw, pCommuInfo.pDataBuffer, pCommuInfo.ulFrameAvaliableSizes, 0, 0, 0, 0);
// FD_StretchDrawImage(m_hDraw, pCommuInfo.pDataBuffer, pCommuInfo.ulFrameAvaliableSizes, src1,dst1);

//注:传入的pCommuInfo结构体中的数据缓冲区指针pDataBuffer只在消息处理函数中有效,
//故关于图像数据的任何算法应在消息处理函数中进行,如果需要在消息处理函数外使用该指针指向的缓冲
//区内的图像数据,必须自己创建一数据缓冲区,在消息处理函数中将图像数据拷贝到创建的缓冲区中,
//使用自己创建的缓冲区中的数据。
end;

end;
...全文
262 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tody Guo 2012-07-29
  • 打赏
  • 举报
回复
if m_lBitCnt <> pCommuInfo.ulFramePixelBits then bChange := True;

要将m_lBitCnt设置成24,即可有彩色图像显示了。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧