PDA

View Full Version : doubts in converting image buffer into image?



akfromvizzitec
June 28, 2007, 04:48:54
hi!

i have linked following code in my MFC dialog application...

class CListener2 : public GrabberListener
{
public:
virtual void frameReady( Grabber& caller, smart_ptr<DShowLib::MemBuffer> pBuffer, DWORD FrameNumber );
};
//

void CListener2::frameReady( Grabber& caller, smart_ptr<MemBuffer> pBuffer, DWORD currFrame)
{
COLORREF **p_pic_Array1;
int t_Y,t_X,t_padd=0,t_rv,t_gv,t_bv, t_width,t_height;
BYTE *p;
p = pBuffer->getPtr();

t_width = 640;
t_height = 480;

// Converting From Buffer into Array
for(t_Y=0; t_Y<t_height; t_Y++)
{
for(t_X=0; t_X<t_width; t_X++)
{
t_bv = p[t_padd];
t_padd++;
t_gv = p[t_padd];
t_padd++;
t_rv = p[t_padd];
t_padd++;
t_padd++;

*(*(p_pic_Array1+t_Y) + t_X) = RGB(t_bv,t_gv,t_rv);
}
}
}

i need to transfer the array into jpeg file format. is it possible to use saveToFileJPEG() function? if yes how?

please help me...


thanks in advance...


AK

Stefan Geissler
June 28, 2007, 09:40:37
Hello,

Yes, you can use the "saveToFileJPEG" function:




void CListener2::frameReady( Grabber& caller, smart_ptr<MemBuffer> pBuffer, DWORD currFrame)
{
saveToFileJPEG(*(pBuffer),"Testimage.jpg",90);
}


(You may should generate new filenames for each image :-) )