Page 1 of 1

how to get pixels of every frame of a swf with high speed

Posted: Wed Mar 30, 2011 3:24 pm
by rocky
I want to use this dll to get pixels of every frame for real-time processing.I have developed a simple application for playing swf file.some code as follows:

-------------------------------------------------------------------
g_hwndFlashPlayerControl =
CreateWindowEx(WS_EX_LAYERED,
(LPCTSTR)FPC_GetClassAtom(g_hFPC),
NULL,
FPCS_TRANSPARENT,//WS_POPUP | WS_VISIBLE,
0,
0,
600,
600,
NULL,
NULL,
NULL,
NULL);

LPSTR pszFileName = "D:\\mywork\\Flash\\Ripples.swf";

if(FAILED(FPC_LoadMovieA(g_hwndFlashPlayerControl,0,pszFileName)))
{
return;
}

FPC_Play(g_hwndFlashPlayerControl);

FPCSetEventListener(g_hwndFlashPlayerControl, &FPCListener, 0);

-------------------------------------

static
void WINAPI FPCListener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR)
{
if (FPCN_UPDATE_RECT == pNMHDR->code)
{
if (true)
{
SFPCGetFrameBitmap FPCGetFrameBitmap = { 0 };
::SendMessage(g_hwndFlashPlayerControl, FPCM_GET_FRAME_BITMAP, 0, (LPARAM)&FPCGetFrameBitmap);
...
CopyMemory(g_lpPixels, bmp_info.bmBits, g_size.cx * g_size.cy * 4);
...

}


void testApp::draw(){

ofSetColor(0xFFFFFF);


ofImage a;
a.allocate(g_size.cx,g_size.cy,OF_IMAGE_COLOR_ALPHA);
a.setFromPixels((unsigned char *)g_lpPixels,g_size.cx,g_size.cy,OF_IMAGE_COLOR_ALPHA);
a.draw(0,0,600,300);
}

After testing several swf files,I met two problems.
1.speed is slow.Is there a way to speed up getting data from swf?
2.the display image from my application is different from your demo. Can you tell me why? And teach me how to solve it.

Thank you!



Image
Image[/url]

Posted: Thu Mar 31, 2011 11:26 am
by Softanics
Hello,

Did you check sample from DirectX directory in the demo version?

Thank you.

Posted: Thu Mar 31, 2011 1:53 pm
by rocky
Hi.
Yes.After checking DirectX sample and OpenGL sample,I got the method for getting pixels from swf file.
You can see two images from my topic for comparing my application and your demo.
Can you help me and point out the error?