/** * @brief Draws a bitmap picture loaded in the STM32 MCU internal memory. * @param Xpos: Bmp X position in the LCD * @param Ypos: Bmp Y position in the LCD * @param pBmp: Pointer to Bmp picture address * @retval None */ void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pBmp) { uint32_t height = 0, width = 0; /* Read bitmap width */ width = *(uint16_t *) (pBmp + 18); width |= (*(uint16_t *) (pBmp + 20)) << 16; /* Read bitmap height */ height = *(uint16_t *) (pBmp + 22); height |= (*(uint16_t *) (pBmp + 24)) << 16; /* Remap Ypos, st7735 works with inverted X in case of bitmap */ /* X = 0, cursor is on Top corner */ if(lcd_drv == &st7735_drv) { Ypos = BSP_LCD_GetYSize() - Ypos - height; } SetDisplayWindow(Xpos, Ypos, width, height); if(lcd_drv->DrawBitmap != NULL) { lcd_drv->DrawBitmap(Xpos, Ypos, pBmp); } SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); }
/** * @brief Draws RGB Image (16 bpp). * @param Xpos: X position in the LCD * @param Ypos: Y position in the LCD * @param Xsize: X size in the LCD * @param Ysize: Y size in the LCD * @param pdata: Pointer to the RGB Image address. * @retval None */ void BSP_LCD_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata) { SetDisplayWindow(Xpos, Ypos, Xsize, Ysize); LCD_DrawRGBImage(Xpos, Ypos, Xsize, Ysize, pdata); SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); }
/** * @brief Draws RGB Image (16 bpp). * @param Xpos: X position in the LCD * @param Ypos: Y position in the LCD * @param Xsize: X size in the LCD * @param Ysize: Y size in the LCD * @param pdata: Pointer to the RGB Image address. * @retval None */ void BSP_LCD_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata) { SetDisplayWindow(Xpos, Ypos, Xsize, Ysize); if(lcd_drv->DrawRGBImage != NULL) { lcd_drv->DrawRGBImage(Xpos, Ypos, Xsize, Ysize, pdata); } SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); }
/** * @brief Draws a bitmap picture (16 bpp). * @param Xpos: Bmp X position in the LCD * @param Ypos: Bmp Y position in the LCD * @param pbmp: Pointer to Bmp picture address. * @retval None */ void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp) { uint32_t height = 0; uint32_t width = 0; /* Read bitmap width */ width = *(uint16_t *) (pbmp + 18); width |= (*(uint16_t *) (pbmp + 20)) << 16; /* Read bitmap height */ height = *(uint16_t *) (pbmp + 22); height |= (*(uint16_t *) (pbmp + 24)) << 16; SetDisplayWindow(Xpos, Ypos, width, height); LCD_WriteBMP(Xpos, Ypos, pbmp); SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); }
BOOL CDXVideoGrabber::PlayFile(const char* inFile, HWND hWnd) { RemoveAllFilters(); HRESULT hr = m_pGrabber.CoCreateInstance( CLSID_SampleGrabber ); if( !m_pGrabber ) return FALSE; CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber ); // force it to connect to video, 24 bit // CMediaType VideoType; VideoType.SetType( &MEDIATYPE_Video ); VideoType.SetSubtype( &MEDIASUBTYPE_RGB24 ); hr = m_pGrabber->SetMediaType( &VideoType ); // shouldn't fail if( FAILED( hr ) ) return FALSE; // add the grabber to the graph // hr = m_pIGraphBuilder->AddFilter( pGrabBase, L"Grabber" ); if( FAILED( hr ) ) return FALSE; RenderFile(inFile); AM_MEDIA_TYPE mt; hr = m_pGrabber->GetConnectedMediaType( &mt ); if ( FAILED( hr) ) { return FALSE; } VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat; if(m_pSGCB) { // m_pSGCB->SetOwner(GetParent(hWnd)); m_pSGCB->SetWidth(vih->bmiHeader.biWidth); m_pSGCB->SetHeight(vih->bmiHeader.biHeight); } FreeMediaType( mt ); // don't buffer the samples as they pass through // hr = m_pGrabber->SetBufferSamples( FALSE ); // only grab one at a time, stop stream after // grabbing one sample // hr = m_pGrabber->SetOneShot( FALSE ); // set the callback, so we can grab the one sample // hr = m_pGrabber->SetCallback( m_pSGCB, 1 ); if(!SetDisplayWindow(hWnd)) { return FALSE; } return Run(); }
BOOL CDXCamara::PlayFile(const char* inFile, HWND hWnd) { HRESULT hr; RemoveAllFilters(); // get whatever capture device exists // CComPtr< IBaseFilter > pCap; GetDefaultCapDevice( &pCap ); if( !pCap ) return FALSE; // add the capture filter to the graph // hr = m_pIGraphBuilder->AddFilter( pCap, L"Cap" ); if( FAILED( hr ) ) return FALSE; hr = m_pGrabber.CoCreateInstance( CLSID_SampleGrabber ); if( !m_pGrabber ) return FALSE; CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber ); // force it to connect to video, 24 bit // CMediaType VideoType; VideoType.SetType( &MEDIATYPE_Video ); VideoType.SetSubtype( &MEDIASUBTYPE_RGB24 ); hr = m_pGrabber->SetMediaType( &VideoType ); // shouldn't fail if( FAILED( hr ) ) return FALSE; // add the grabber to the graph // hr = m_pIGraphBuilder->AddFilter( pGrabBase, L"Grabber" ); if( FAILED( hr ) ) return FALSE; // make a capture builder graph (for connecting help) // CComPtr< ICaptureGraphBuilder2 > pBuilder; hr = pBuilder.CoCreateInstance( CLSID_CaptureGraphBuilder2 ); if( !pBuilder ) return FALSE; hr = pBuilder->SetFiltergraph( m_pIGraphBuilder ); if( FAILED( hr ) ) return FALSE; // If there is a VP pin present on the video device, then put the // renderer on CLSID_NullRenderer CComPtr<IPin> pVPPin; hr = pBuilder->FindPin( pCap, PINDIR_OUTPUT, &PIN_CATEGORY_VIDEOPORT, NULL, FALSE, 0, &pVPPin); // If there is a VP pin, put the renderer on NULL Renderer CComPtr<IBaseFilter> pRenderer; if (S_OK == hr) { hr = pRenderer.CoCreateInstance(CLSID_NullRenderer); if (FAILED (hr)) { return FALSE; } hr = m_pIGraphBuilder->AddFilter(pRenderer, L"NULL renderer"); if (FAILED (hr)) { return FALSE; } } hr = pBuilder->RenderStream( &PIN_CATEGORY_PREVIEW, &MEDIATYPE_Interleaved, pCap, pGrabBase, pRenderer); if (FAILED (hr)) { // try to render preview pin hr = pBuilder->RenderStream( &PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pCap, pGrabBase, pRenderer); // try to render capture pin if( FAILED( hr ) ) { hr = pBuilder->RenderStream( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pCap, pGrabBase, pRenderer); } } if( FAILED( hr ) ) { return FALSE; } // ask for the connection media type so we know how big // it is, so we can write out bitmaps // AM_MEDIA_TYPE mt; hr = m_pGrabber->GetConnectedMediaType( &mt ); if ( FAILED( hr) ) { return FALSE; } VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat; if(m_pSGCB) { // m_pSGCB->SetOwner(GetParent(hWnd)); m_pSGCB->SetWidth(vih->bmiHeader.biWidth); m_pSGCB->SetHeight(vih->bmiHeader.biHeight); } FreeMediaType( mt ); // don't buffer the samples as they pass through // hr = m_pGrabber->SetBufferSamples( FALSE ); // only grab one at a time, stop stream after // grabbing one sample // hr = m_pGrabber->SetOneShot( FALSE ); // set the callback, so we can grab the one sample // hr = m_pGrabber->SetCallback( m_pSGCB, 1 ); // CComPtr< IBaseFilter > pMux; // CComPtr< IFileSinkFilter > pSink; // USES_CONVERSION; // // hr = pBuilder->SetOutputFileName( &MEDIASUBTYPE_Avi, T2W( inFile ), // &pMux, &pSink ); // if( FAILED( hr ) ) // return FALSE; // // hr = pBuilder->RenderStream( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, // pCap, NULL,pMux ); // if( FAILED( hr ) ) // return FALSE; // hr = pBuilder->RenderStream( &PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, // pCap, NULL, NULL ); // if( FAILED( hr ) ) // return FALSE; if(!SetDisplayWindow(hWnd)) { return FALSE; } return Run(); }