🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #683

Re: TMediaPlayer and TImage

#683
From: Marcelo R. Lopez, Jr.
Date: Tue, 15 Apr 2003 18:18
72 lines
3682 bytes
Mike,

Here's a bit of code to exactly what you want to do...it's not pretty....but
it will capture what you want...
Essentially, you have two panels, a mediaplayer with it's display property
set to the first panel. On the second panel, you
put a TIMAGE ( Image1 goes on Panel2 ). Put a button ( button1 ) and have
code like below to capture that snapshot.
You'll probably want to play with the SRC and DEST rectangles, and you could
also use StretchBlt() to size the source image to your destination, etc,
etc. Once the TImage has the snapshot, you can save the resultant bitmap out
to whatever file you'd like...
There's your snapshot....as a matter of fact, you can even feed that TImage
to your printer....and there's your snapshot on paper...

Enjoy..

Marcelo


void __fastcall TForm1::Button1Click(TObject *Sender)
{
    if ( MediaPlayer1->Mode == mpPlaying ) {
        MediaPlayer1->Pause();
        HDC dcSrc,dcDst;
        Image1->Canvas->Lock();
        dcDst = Image1->Canvas->Handle;
        dcSrc = ::GetWindowDC(Panel1->Handle);
        RECT rcSrc;
        RECT rcDst;
        ::GetWindowRect( Panel1->Handle, &rcSrc );

        DWORD dwErr =
        ::BitBlt( dcDst, // handle to destination device context
                0, // x-coordinate of destination rectangle's upper-left
corner
                0, // y-coordinate of destination rectangle's upper-left
corner
                Image1->Width, // width of destination rectangle
                Image1->Height, // height of destination rectangle
                dcSrc, // handle to source device context
                0, // x-coordinate of source rectangle's upper-left corner
                0, // y-coordinate of source rectangle's upper-left corner
                SRCCOPY  // raster operation code
              );

        if ( dwErr == 0 ) {
         // Error occurred
            dwErr = ::GetLastError();
            AnsiString msg;
            msg.sprintf( "BitBlt returned Error = %i", dwErr );
            Application->MessageBox( msg.c_str(), "BitBlt Error", MB_OK );
        }
        Image1->Canvas->Unlock();
        ::ReleaseDC(Panel1->Handle, dcSrc);
        MediaPlayer1->Resume();

        // Do whatever you're going to do with the image at this point...

    }

}



"MikeS" <mps1ect@bolton.ac.uk> wrote in message
news:3e76d7c5$1@newsgroups.borland.com...
>
> I am trying to capture a still image from the display of a TMediaPlayer
Component and put it onto a TImage Canvas but all i seem to be able to get
is the image of the object TMedia is displaying on or if i take a screenshot
it comes out black i would be very greatfull if someone could help me
Technical Details
Message-ID: <3e9c4b72@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3e76d7c5$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d0fc,411a7c99ebfe84e4
X-Google-Attributes: gid10d0fc,public
X-Google-ArrivalTime: 2003-04-15 11:22:19 PST
Reply-To: "Marcelo R. Lopez, Jr." <marcelol@directvinternet.com>
From: "Marcelo R. Lopez, Jr." <marcelol@directvinternet.com>
Newsgroups: borland.public.cppbuilder.multimedia
References: <3e76d7c5$1@newsgroups.borland.com>
Subject: Re: TMediaPlayer and TImage
Date: Tue, 15 Apr 2003 14:18:11 -0400
Lines: 74
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 64.221.40.13
Message-ID: <3e9c4b72@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1050430322 64.221.40.13 (15 Apr 2003 11:12:02 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail