Hi
i run into this code.. :
void CVidTestDlg::OnCapture()
{
CString Filter;
CString Filename;
CRect Rect;
Filter = "Bitmap Files (*.bmp)|*.bmp|AVI Files (*.avi)|*.avi||";
CFileDialog FileDlg(FALSE, "BMP", NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
Filter,
this);
if (FileDlg.DoModal() == IDOK)
{
RedrawWindow();
Filename = FileDlg.GetPathName();
Capture(m_VFWImageProc, Filename);
m_VideoDisplay.GetWindowRect(Rect);
ScreenToClient(Rect);
m_VFWImageProc.EnablePreviewVideo(*this, Rect.TopLeft().x,Rect.TopLeft().y);
}
}
BOOL Capture(CVFWImageProcessor &ImageProc, LPCTSTR Filename)
{
ULONG Length = 0;
CFile File;
BOOL Ret = FALSE;
CHAR Ext[_MAX_EXT];
_splitpath(Filename,NULL,NULL,NULL,Ext);
if (stricmp(Ext,".avi") == 0)
{
Ret = ImageProc.CaptureAVI(Filename,4.0,10,10);
}
else if (stricmp(Ext,".bmp") == 0)
{
BITMAPINFO *Bitmap = NULL;
BITMAPFILEHEADER bfh;
ImageProc.CaptureDIB(&Bitmap,0,&Length);
if (Bitmap)
{
File.Open(Filename,CFile::modeCreate |
CFile::modeWrite |
CFile::shareDenyNone |
CFile::typeBinary);
bfh.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M"
bfh.bfSize = (DWORD) Length + sizeof(BITMAPFILEHEADER);
bfh.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) +
sizeof(BITMAPINFOHEADER) +
Bitmap->bmiHeader.biClrUsed * sizeof (RGBQUAD);
bfh.bfReserved1 = 0;
bfh.bfReserved2 = 0;
File.Write(&bfh,sizeof(bfh));
File.Write(Bitmap,Length);
File.Close();
Ret = TRUE;
delete Bitmap;
}
this is the code that is resposible for capturing a image from usb webcam and saving to hard driver
Function : CaptureDIB
Arguments : Bitmap (output) - Pointer to bitmap to receive image.
If *Bitmap = NULL, then allocation will
be performed automatically.
BitmapLength (input) - Size of Bitmap if *Bitmap is not NULL.
RetBitmapLength (output) - Actual size of image.
Return : TRUE Success, FALSE Failed.
Description: Captures a DIB image from video capture device.
As you see he uses some structs BITMAPINFO BITMAPFILEHEADER wihich togheter is the bitmap file. and writes it down to file.
now my problem...
i must make a dll wich exports symbols and a function within it , lets call it Capture that will return a bitmap (whole bitmap including header)
but i dont know how to copy the both struct within a buffer or something and return it.
can someone help. does someone get me..
sorry for bad explanation . i`m not champion at c++
i run into this code.. :
void CVidTestDlg::OnCapture()
{
CString Filter;
CString Filename;
CRect Rect;
Filter = "Bitmap Files (*.bmp)|*.bmp|AVI Files (*.avi)|*.avi||";
CFileDialog FileDlg(FALSE, "BMP", NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
Filter,
this);
if (FileDlg.DoModal() == IDOK)
{
RedrawWindow();
Filename = FileDlg.GetPathName();
Capture(m_VFWImageProc, Filename);
m_VideoDisplay.GetWindowRect(Rect);
ScreenToClient(Rect);
m_VFWImageProc.EnablePreviewVideo(*this, Rect.TopLeft().x,Rect.TopLeft().y);
}
}
BOOL Capture(CVFWImageProcessor &ImageProc, LPCTSTR Filename)
{
ULONG Length = 0;
CFile File;
BOOL Ret = FALSE;
CHAR Ext[_MAX_EXT];
_splitpath(Filename,NULL,NULL,NULL,Ext);
if (stricmp(Ext,".avi") == 0)
{
Ret = ImageProc.CaptureAVI(Filename,4.0,10,10);
}
else if (stricmp(Ext,".bmp") == 0)
{
BITMAPINFO *Bitmap = NULL;
BITMAPFILEHEADER bfh;
ImageProc.CaptureDIB(&Bitmap,0,&Length);
if (Bitmap)
{
File.Open(Filename,CFile::modeCreate |
CFile::modeWrite |
CFile::shareDenyNone |
CFile::typeBinary);
bfh.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M"
bfh.bfSize = (DWORD) Length + sizeof(BITMAPFILEHEADER);
bfh.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) +
sizeof(BITMAPINFOHEADER) +
Bitmap->bmiHeader.biClrUsed * sizeof (RGBQUAD);
bfh.bfReserved1 = 0;
bfh.bfReserved2 = 0;
File.Write(&bfh,sizeof(bfh));
File.Write(Bitmap,Length);
File.Close();
Ret = TRUE;
delete Bitmap;
}
this is the code that is resposible for capturing a image from usb webcam and saving to hard driver
Function : CaptureDIB
Arguments : Bitmap (output) - Pointer to bitmap to receive image.
If *Bitmap = NULL, then allocation will
be performed automatically.
BitmapLength (input) - Size of Bitmap if *Bitmap is not NULL.
RetBitmapLength (output) - Actual size of image.
Return : TRUE Success, FALSE Failed.
Description: Captures a DIB image from video capture device.
As you see he uses some structs BITMAPINFO BITMAPFILEHEADER wihich togheter is the bitmap file. and writes it down to file.
now my problem...
i must make a dll wich exports symbols and a function within it , lets call it Capture that will return a bitmap (whole bitmap including header)
but i dont know how to copy the both struct within a buffer or something and return it.
can someone help. does someone get me..
sorry for bad explanation . i`m not champion at c++