Angel Martinez Gonzalvo
asked on
Copy output image from TWindowsMediaPlayer
Hello,
I am trying to copy output image from a TWindowsMediaPlayer activeX component imported in C++ Builder (RAD Studio 10.1 Berlin).
I need to copy content of Windows Media Player to a Panel, Image or another component for giving customer a Preview of Player. I was trying to copy with BitBlt function, copying canvas of TPanel that contains Player, but result was always a black rect. I was supposing that Windows Media Player maybe shows output pictures in video memory and I do not know how can I copy this output.
I put a fragment of my code where I try to copy the panel containing the Player to another panel:
HDC destino = GetDC( Panel1->Handle );
HDC origen = GetDC( pnlInformacion->Handle );
BitBlt(destino, 0, 0, Panel1->Width, Panel1->Height, origen, 0,0, SRCCOPY);
ReleaseDC( Panel1->Handle, destino );
ReleaseDC( pnlInformacion->Handle, origen );
pnlInformation contains TWindowsMediaPlayer ActiveX control.
Can you help me?
Thanks.
I am trying to copy output image from a TWindowsMediaPlayer activeX component imported in C++ Builder (RAD Studio 10.1 Berlin).
I need to copy content of Windows Media Player to a Panel, Image or another component for giving customer a Preview of Player. I was trying to copy with BitBlt function, copying canvas of TPanel that contains Player, but result was always a black rect. I was supposing that Windows Media Player maybe shows output pictures in video memory and I do not know how can I copy this output.
I put a fragment of my code where I try to copy the panel containing the Player to another panel:
HDC destino = GetDC( Panel1->Handle );
HDC origen = GetDC( pnlInformacion->Handle );
BitBlt(destino, 0, 0, Panel1->Width, Panel1->Height, origen, 0,0, SRCCOPY);
ReleaseDC( Panel1->Handle, destino );
ReleaseDC( pnlInformacion->Handle, origen );
pnlInformation contains TWindowsMediaPlayer ActiveX control.
Can you help me?
Thanks.
ASKER
Hi Merete,
I know how to use the Windows snipping tool but I want to do the same with C++ code inside my program. When I try to do this by code obtains a black rectangle where player was.
Thanks and regards.
I know how to use the Windows snipping tool but I want to do the same with C++ code inside my program. When I try to do this by code obtains a black rectangle where player was.
Thanks and regards.
if you want to copy a bitmap from screen to destination device context (dc), the DC should be a Memory DC where a HBITMAP was selected into. after BitBlt copy you then could use the bitmap of the Memory DC to create a DIB (a device-independent bitmap) or to draw it into another window or even a printer.
see http://www.winprog.org/tutorial/bitmaps.html
for more information.
Sara
see http://www.winprog.org/tutorial/bitmaps.html
for more information.
Sara
ASKER
Hi sarabande,
first of all thanks for the info.
I have tried what you said but same result. All components were copied but TWindowsMediaPlayer:
Code used:
Panel1->Width = pnlInformacion->Width;
Panel1->Height = pnlInformacion->Height;
HDC capture = GetDC( pnlInformacion->Handle );
HDC target = CreateCompatibleDC( capture );
int width = pnlInformacion->Width;
int height = pnlInformacion->Height;
HBITMAP hBitmap = CreateCompatibleBitmap( capture, width, height );
HBITMAP hOldBitmap = (HBITMAP)SelectObject( target, hBitmap );
BitBlt(target, 0, 0, width, height, capture, 0,0, SRCCOPY);
hBitmap = (HBITMAP)SelectObject( target, hOldBitmap );
Image1->Picture->Bitmap->H andle = hBitmap;
ReleaseDC( pnlInformacion->Handle, target );
DeleteDC( capture );
DeleteDC( target );
As you can see I can copy all content but player.
Any idea?
Thanks.
first of all thanks for the info.
I have tried what you said but same result. All components were copied but TWindowsMediaPlayer:
Code used:
Panel1->Width = pnlInformacion->Width;
Panel1->Height = pnlInformacion->Height;
HDC capture = GetDC( pnlInformacion->Handle );
HDC target = CreateCompatibleDC( capture );
int width = pnlInformacion->Width;
int height = pnlInformacion->Height;
HBITMAP hBitmap = CreateCompatibleBitmap( capture, width, height );
HBITMAP hOldBitmap = (HBITMAP)SelectObject( target, hBitmap );
BitBlt(target, 0, 0, width, height, capture, 0,0, SRCCOPY);
hBitmap = (HBITMAP)SelectObject( target, hOldBitmap );
Image1->Picture->Bitmap->H
ReleaseDC( pnlInformacion->Handle, target );
DeleteDC( capture );
DeleteDC( target );
As you can see I can copy all content but player.
Any idea?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It works!
Thank you so much sarabande!
Final code:
Regards.
Thank you so much sarabande!
Final code:
Panel1->Width = pnlReproduccion->Width;
Panel1->Height = pnlReproduccion->Height;
HDC capture = GetDC( NULL );
HDC target = CreateCompatibleDC( capture );
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
HBITMAP hBitmap = CreateCompatibleBitmap( capture, width, height );
HBITMAP hOldBitmap = (HBITMAP)SelectObject( target, hBitmap );
BitBlt(target, 0, 0, pnlReproduccion->Width, pnlReproduccion->Height, capture, pnlReproduccion->Left , pnlReproduccion->Top, SRCCOPY);
hBitmap = (HBITMAP)SelectObject( target, hOldBitmap );
Image1->Picture->Bitmap->Handle = hBitmap;
ReleaseDC( NULL, capture );
ReleaseDC( NULL, target );
DeleteDC( capture );
DeleteDC( target );
Regards.
I have no ideas on what you are referring to pnlInformation contains TWindowsMediaPlayer ActiveX control. and TWindowsMediaPlayer
so in my layman terms if you can see a video/image in this media player yu can use the snipping tool in windows 7 and windows 8 and windows 10.
It is located in your system tools> start menu> accessories
It can be used to grab a screenshot of whatever is on your desktop. The snipping tool has the options to grab a screenshot of a rectangle ( drag the curser around the area you want) that area will go grey and clear inside the area you highlight, then use the floppy to save it as??
or a full screen , or free style, if you change your mind just click new to start a new again.
snipping tool save and options
If my comment is right off or away from your more complex method hopefully my comment will bring in others.
Back to you.