Zdravim,
zasekol som sa na jednom probleme, s ktorym si neviem dat rady a chcel by som Vas poprosim o rady. Moja aplikacia v podstate zachytava obraz z kamery a rendruje ho na obrazovku do PictureBox-u (o to sa stara API vyrobcu kamery, neviem ako tie metody vo vnutri funguju). Ja potrebujem zachyteni obraz zanalyzovat a po analyze ho vykreslit do dalsieho PictureBox-u. GUI mam pisane v C#, ale vsetko ostatne riesim v C++ pokial mozno s pouzitim WIN32 API. Skusim Vam podrobne popisat dany problem ktory mam.
HANDLE PictureBoxu predam z C# do C++
adapter.Init(0, analyzeBox.Handle.ToInt32());
int Device::Init(int phf, int handleWindow)
{
HWND analyzeWindowHandle = (HWND) handleWindow;
...
}
Analyzu volam hned po vyrendrovani zachyteneho obrazu z kamery do prveho PixtureBoxu, takze tie obrazove data sa stale nachadzaju v pamati. Na vyber dat z pamate pouzivam zase API funkciu kamery. Pre lepsie pochopenie prilozim popis tejto funkcie.
Syntax
INT is_InquireImageMem (HIDS hCam,
char* pcMem, int nID,
int* pnX, int* pnY,
int* pnBits, int* pnPitch);
Description
is_InquireImageMem() reads out the properties of an allocated image memory.
Input Parameters
hCam - Camera handle
pMem - Pointer to the starting address of the image memory as allocated by is_AllocImageMem()
NID - ID of the image memory as allocated by is_AllocImageMem()
pnX - Returns the width used to define the image memory (can be 0).
pnY - Returns the height used to define the image memory (can be 0).
pnBits - Returns the bit width used to define the image memory (can be 0).
pnPitch - Returns the line increment of the image memory (can be 0).
Takze v metode Analyze nacitam data z pamate, prebehnem to dakym tym algoritmom a chcem ich vykrelist do pripraveneho PictureBoxu. A to je ten problem. Neviem ako na to. Z debugu sa zda ze cez CreateBitmap sa Bitmapa v pohode vytvori, problem je, ze neviem ako ju zobrazit do PictureBox-u s vyuzitim HWND. Momentalne to skusam pomocou SendMessage, ale to mi tiez nefunguje.
int Device::Analyze()
{
int width, height, bits, pitch;
char* tempBitmap;
int rValue;
if(is_InquireImageMem (*this->cameraHandlePointer, this->imgMemory, this->imgMemoryID, &width ,&height, &bits, &pitch) != IS_SUCCESS)
return rValue;
else
{
tempBitmap = imgMemory;
HBITMAP hBmp = CreateBitmap(width,height,1,bits,tempBitmap);
LRESULT lr = SendMessage( this->analyzeWindowHandle, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmp);
}
return 0;
}
Vopred dakujem za napady, rady, tipy, triky, alebo myslienky