请问各位大侠,我下面的代码怎么总是不能将图像彩色输出呀?目前输出的全是黑白的
目前,我用的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;
目前,我用的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;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货