PDA

View Full Version : using saveToFileJPEG() on outside of void CListener::frameReady()



selvanathan
July 4, 2007, 07:40:55
Dear Sir,

I am using running image process & saveToFileBMP() with following code

void CListener::frameReady( Grabber& caller, smart_ptr<MemBuffer> pBuffer, DWORD currFrame)
{
//std::cout << "Buffer " << currFrame << " processed in CListener::frameReady()." << std::endl;

char filename[MAX_PATH];
BYTE *p = pBuffer->getPtr();

width = 640;
height = 480;

k=0;
for(i=0; i<height; i++)
for(j=0; j<width; j++)
{
bv = p[k];
k++;
gv = p[k];
k++;
rv = p[k];
k++;
k++;

*(*(imagearr1+i) + j) = RGB(bv,gv,rv);
}


k=0;

for(i=0; i<height; i++)
for(j=0; j<width; j++)
{
p[k] = GetBValue(imagearr1[i][j]);
k++;
p[k] = GetGValue(imagearr1[i][j]);
k++;
p[k] = GetRValue(imagearr1[i][j]);
k++;
p[k] = 0;
k++;
}

dwNum++;
sprintf(filename, "%s%02i.bmp", FILENAME_TEMPLATE, dwNum );
saveToFileBMP( *pBuffer, filename );
}

it works fine...........,

But..... if i have some values in imagearr1 , now i need to save that to bmp file by using saveToFileBMP(), is it possible????????

for example........

void Test_Dlg::OnButtonClick()
{
m_pSink->setSinkMode( GrabberSinkType::eRUN);
Sleep(200);
m_pSink->setSinkMode( GrabberSinkType::ePAUSE );

////// Now I get Some values in imagearr1

saveToFileBMP( *pBuffer, filename ); //////// This line not works here////////////
}

How i do this......

plz help me.....




}

Stefan Geissler
July 4, 2007, 17:17:32
Hi

In following part of your code:

void Test_Dlg::OnButtonClick()
{
m_pSink->setSinkMode( GrabberSinkType::eRUN);
Sleep(200);
m_pSink->setSinkMode( GrabberSinkType::ePAUSE );

////// Now I get Some values in imagearr1

saveToFileBMP( *pBuffer, filename ); //////// This line not works here////////////
}
you use *pBuffer. From where does *pBuffer come from? You may use getActiveMemBuffer() to retrieve the last grabbed imagebuffer:
http://www.imagingcontrol.com/support/documentation/class/meth_descGrabber_getActiveMemBuffer.htm

selvanathan
July 5, 2007, 15:10:43
Dear Sir,
Thank u for u r reply.......:)