Спасибо! =) Оказалось, все вообще элементарно! И, главное, работает просто молниеносно, что мне и было необходимо!
IplImage * TBitmapToIplImage(Graphics::TBitmap *src)
{
int _h = src->Height;
int _w = src->Width;
if (!src || _w==0)
return NULL;
IplImage* dest = cvCreateImage(cvSize(_w,_h),IPL_DEPTH_8U,3);
try
{
unsigned char *pLine;
for(int y=0; y<_h; y++)
{
pLine = (unsigned char *)src->ScanLine[y];
memcpy(dest->imageData+_w*3*y, pLine, _w*3);
}
}
catch(...)
{
MessageBox(0,"Exception when get data ","Error", MB_OK );
}
return dest;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap* Bitmap = new Graphics::TBitmap;
HDC DC=GetDC(0); // Делаем снимок экрана для примера, тут можно использовать любой DC
try{
Bitmap->Height=Screen->Height;
Bitmap->Width=Screen->Width;
Bitmap->PixelFormat=pf24bit; // Обязательно нужно перевести в 24 бита
// Копируем DC в битмап
BitBlt(Bitmap->Canvas->Handle, 0, 0, Screen->Width, Screen->Height,DC, 0, 0, SRCCOPY);
IplImage* TestImage = TBitmapToIplImage(Bitmap);
APIDrawIpl(0,0,TestImage,Form1->Handle);
}
__finally
{
delete Bitmap;
ReleaseDC(0,DC);
}
}