Page 1 of 2
Getting flash bitmap without window
Posted: Thu Oct 06, 2005 12:36 pm
by chossette
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,
Posted: Thu Oct 06, 2005 3:03 pm
by Softanics
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.
Getting flash bitmap without window
Posted: Thu Oct 13, 2005 12:33 pm
by chossette
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>
Re: Getting flash bitmap without window
Posted: Thu Oct 13, 2005 1:16 pm
by Softanics
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);
Posted: Thu Oct 13, 2005 1:30 pm
by chossette
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 !
Posted: Thu Oct 13, 2005 1:33 pm
by Softanics
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.
Posted: Thu Oct 13, 2005 1:34 pm
by chossette
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
Posted: Thu Oct 13, 2005 1:50 pm
by Softanics
I think GetDIBits is the best way for your task.
Posted: Fri Oct 14, 2005 8:49 am
by chossette
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;
Posted: Fri Oct 14, 2005 9:16 am
by Softanics
Dexy- wrote:got just a problem of quality...
Very low frame rate? Or quality of the bitmaps?
Posted: Fri Oct 14, 2005 9:32 am
by chossette
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)
Posted: Fri Oct 14, 2005 9:54 am
by Softanics
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)
Posted: Fri Oct 14, 2005 10:06 am
by chossette
Mail send,
It's a test code, so it's pretty ugly and not optimised at all !
nico,
Posted: Fri Oct 14, 2005 10:29 am
by Softanics
Thank you!
Need a little help maybe...
Posted: Tue Oct 25, 2005 3:49 pm
by chossette
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...