Getting flash bitmap without window

DLL Edition of the F-IN-BOX
chossette
Posts: 14
Joined: Fri Sep 23, 2005 12:56 pm
Contact:

Getting flash bitmap without window

Postby chossette » Thu Oct 06, 2005 12:36 pm

I admit i've not search and test,

I've seen that we can grab frame from flash with FlashPlayerControl. I have not test this feature and so the perf.

I would like to use those frame, to display flash in a 3D environnement (using directx). So my question is : what are the perf (meaning time for capturing a frame), and can we use it without a window.
So must I have to create a container to render my Flash to grab frame ? Can't I do a renderless like ?

Tx by advance,

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Thu Oct 06, 2005 3:03 pm

Thank you for your questions.

Yes, you need to create FlashPlayerControl window before grabbing frames. Perfomance depends on the size of a movie and some others factors, so the best way is just to try FlashPlayerControl in your task.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

chossette
Posts: 14
Joined: Fri Sep 23, 2005 12:56 pm
Contact:

Getting flash bitmap without window

Postby chossette » Thu Oct 13, 2005 12:33 pm

Okay,

I have a little time today to have a look again. So, again, I did not push my investigation so far away. So my question is maybe little dumb.

All GET_FRAME_BITMAP return me an handle on a bitmap which has dimension [0;0]...

<code>
SFPCGetFrameBitmap FPCGetFrameBitmap = { 0 };
LRESULT lr = ::SendMessage(m_hwndFlashPlayerControl, FPCM_GET_FRAME_BITMAP, 0, (LPARAM)&FPCGetFrameBitmap);

HBITMAP hBitmap = FPCGetFrameBitmap.hBitmap;
// start copie
SIZE bitmapSize;
GetBitmapDimensionEx( hBitmap, &bitmapSize );

DeleteObject(hBitmap);
</code>

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Re: Getting flash bitmap without window

Postby Softanics » Thu Oct 13, 2005 1:16 pm

Use

Code: Select all

HBITMAP hBitmap = FPCGetFrameBitmap.hBitmap;

BITMAP bmp_info = { 0 };
GetObject(hBitmap, sizeof(bmp_info), &bmp_info);

SIZE bitmapSize;

bitmapSize.cx = bmp_info.bmWidth;
bitmapSize.cy = bmp_info.bmHeight;

DeleteObject(hBitmap);


instead of

Code: Select all

HBITMAP hBitmap = FPCGetFrameBitmap.hBitmap;
// start copie
   SIZE bitmapSize;
   GetBitmapDimensionEx(  hBitmap, &bitmapSize );

DeleteObject(hBitmap);
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

chossette
Posts: 14
Joined: Fri Sep 23, 2005 12:56 pm
Contact:

Postby chossette » Thu Oct 13, 2005 1:30 pm

First of all, tx again for your fast answer

Hum, using getObject give me result... but why does GetBitmapDimensionEx does not ?

More, why is the bmBits from the BITMAP struct I get from GetObject stay to a 0x00000000 ptr ?

tx !

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Thu Oct 13, 2005 1:33 pm

No problem :)

See MSDN.

http://msdn.microsoft.com/library/defau ... s_1l4o.asp

GetBitmapDimensionEx

The GetBitmapDimensionEx function retrieves the dimensions of a compatible bitmap. The retrieved dimensions must have been set by the SetBitmapDimensionEx function.

BOOL GetBitmapDimensionEx(
HBITMAP hBitmap, // handle to bitmap
LPSIZE lpDimension // dimensions
);


To get bytes of the bitmap use GetDIBits.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

chossette
Posts: 14
Joined: Fri Sep 23, 2005 12:56 pm
Contact:

Postby chossette » Thu Oct 13, 2005 1:34 pm

In fact, I've seen the sample using

Code: Select all

pictdesc.cbSizeofstruct = sizeof(pictdesc);
   pictdesc.picType = PICTYPE_BITMAP;
   pictdesc.bmp.hbitmap = FPCGetFrameBitmap.hBitmap;

   IPicture* pPicture = NULL;
   OleCreatePictureIndirect(&pictdesc, IID_IPicture, FALSE, (void**)&pPicture);


But I just wan't to have access to bytes without passing through x interface.

tx

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Thu Oct 13, 2005 1:50 pm

I think GetDIBits is the best way for your task.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

chossette
Posts: 14
Joined: Fri Sep 23, 2005 12:56 pm
Contact:

Postby chossette » Fri Oct 14, 2005 8:49 am

Tx for help,
if code can help. I don't use memcpy to inverse the texture.

Tx again for help, got just a problem of quality... will have a look on that

Nico,

Code: Select all

BITMAPINFO bmpInfoHeader;
               int octetSize =  bmp_info.bmWidthBytes * bmp_info.bmHeight * bmp_info.bmBitsPixel / 8;
               BYTE *lpvBytes = new BYTE[ octetSize ];

               ZeroMemory( &bmpInfoHeader, sizeof(BITMAPINFO) );
               bmpInfoHeader.bmiHeader.biSize = sizeof(BITMAPINFO);
               bmpInfoHeader.bmiHeader.biWidth = bmp_info.bmWidth;
               bmpInfoHeader.bmiHeader.biHeight = bmp_info.bmHeight;
               bmpInfoHeader.bmiHeader.biPlanes = 1;
               bmpInfoHeader.bmiHeader.biBitCount = bmp_info.bmBitsPixel;
               bmpInfoHeader.bmiHeader.biCompression = BI_RGB;

               HDC flashDc = GetDC( g_hwndFlashPlayerControl );
               int nbScanLines = GetDIBits( flashDc, hBitmap, 0, bmp_info.bmHeight, lpvBytes, &bmpInfoHeader, DIB_RGB_COLORS );
            
            if ( lpvBytes == NULL )   return FALSE;
            if ( nbScanLines = 0 ) return FALSE;
            

            HRESULT hr = S_OK;
            if ( g_pTexture9 ) {
               D3DLOCKED_RECT lockedRect;

               hr = g_pTexture9->LockRect( 0, &lockedRect, NULL, D3DLOCK_DISCARD );
               
               BYTE *texBytes = (BYTE*)lockedRect.pBits;
               BYTE *bmpBytes = lpvBytes;
               int texPitch = lockedRect.Pitch;
               int bmpPitch = bmpInfoHeader.bmiHeader.biWidth * bmpInfoHeader.bmiHeader.biBitCount / 8;

               for ( LONG i = 0; i < bmpInfoHeader.bmiHeader.biHeight; i++ ) {
                  // copie du contenu
                  DWORD *bmpDWORD = (DWORD*)bmpBytes;
                  DWORD *texDWORD = (DWORD*)texBytes;

                  for ( LONG j = 0; j < bmpInfoHeader.bmiHeader.biWidth; j++ )
                     texDWORD[j] = bmpDWORD[(bmpInfoHeader.bmiHeader.biWidth - 1) - j];

                  bmpBytes += bmpPitch;
                  texBytes += texPitch;
               }

               hr = g_pTexture9->UnlockRect( 0 );
            }
            DeleteObject(hBitmap);
            int res = ReleaseDC( g_hwndFlashPlayerControl, flashDc );
            delete[] lpvBytes;

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Oct 14, 2005 9:16 am

Dexy- wrote:got just a problem of quality...


Very low frame rate? Or quality of the bitmaps?
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

chossette
Posts: 14
Joined: Fri Sep 23, 2005 12:56 pm
Contact:

Postby chossette » Fri Oct 14, 2005 9:32 am

Okay, it was my fault, creating the 3d device too fast, I was specifing a small render buffer.

So it works 'niquel'

Good framerate, good visual quality, Great lib ! tx

(wan't to see the sample ?)

Nico, (tx again)

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Oct 14, 2005 9:54 am

Yes, of course! And... if you can send me also the code, it would be great :)
My e-mail: support (at) flashplayercontrol.com

Dexy- wrote:Okay, it was my fault, creating the 3d device too fast, I was specifing a small render buffer.

So it works 'niquel'

Good framerate, good visual quality, Great lib ! tx

(wan't to see the sample ?)

Nico, (tx again)
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

chossette
Posts: 14
Joined: Fri Sep 23, 2005 12:56 pm
Contact:

Postby chossette » Fri Oct 14, 2005 10:06 am

Mail send,

It's a test code, so it's pretty ugly and not optimised at all !

nico,

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Oct 14, 2005 10:29 am

Thank you!
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

chossette
Posts: 14
Joined: Fri Sep 23, 2005 12:56 pm
Contact:

Need a little help maybe...

Postby chossette » Tue Oct 25, 2005 3:49 pm

Hello, I need a little of help to understand a thing maybe evident...

So, i explain myself, I'm always trying to have a FlashRenderToTexture lib. I did a C version which works great (...).

I take the same application and put it into a C++ class. It works until the 390'th frame in general. From where the FPCM_GET_FRAME_BITMAP give me a NULL hBitmap...

So if you have an idea ?

tx,
I will look further...


Return to “DLL Edition”

Who is online

Users browsing this forum: Bing [Bot] and 18 guests

cron