Speed up bitmap getting

DLL Edition of the F-IN-BOX
Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Tue Apr 11, 2006 10:41 am

Zeratul wrote:Well. It is working good now. Thanks! But about new version of control ? I mean in download section it is still old. When new one will be added ?


Today.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

Zeratul
Posts: 24
Joined: Sat Apr 01, 2006 8:19 am

Postby Zeratul » Tue Apr 11, 2006 10:51 am

Ok.

Zeratul
Posts: 24
Joined: Sat Apr 01, 2006 8:19 am

Postby Zeratul » Tue Apr 11, 2006 11:36 am

And also, what about function for getting last rendered frame pixel buffer ?
I wrote about this earlier.

Zeratul
Posts: 24
Joined: Sat Apr 01, 2006 8:19 am

Postby Zeratul » Tue Apr 11, 2006 11:49 am

It seems that this callback method is working bad with large flash movies, for example 800x600. It is working fine with small flash movies, 200x200 for example. My application freezes when I am trying to play a big movie.

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

Postby Softanics » Tue Apr 11, 2006 11:57 am

Simple example is GetImagePixels() in the Sample5_SWF2BitmapDlg.cpp.

Zeratul wrote:And also, what about function for getting last rendered frame pixel buffer ?
I wrote about this earlier.
Best regards, Artem A. Razin,

F-IN-BOX support

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

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

Postby Softanics » Tue Apr 11, 2006 11:59 am

Zeratul wrote:It seems that this callback method is working bad with large flash movies, for example 800x600. It is working fine with small flash movies, 200x200 for example. My application freezes when I am trying to play a big movie.


I've just tested with 800 x 600. It works properly.
Does your application freeze with any movie with such size?
Best regards, Artem A. Razin,

F-IN-BOX support

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

Zeratul
Posts: 24
Joined: Sat Apr 01, 2006 8:19 am

Postby Zeratul » Tue Apr 11, 2006 12:07 pm

Yes, I tested 3 different movies. One of them was working a bit better then 2 others. One is almost fully freezes application and the other one, freeze application at all.

My application is working properyl, if I don't update frames.
May be you have an ICQ or AIM account to talk about this problem ?

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

Postby Softanics » Tue Apr 11, 2006 12:11 pm

Zeratul wrote:Yes, I tested 3 different movies. One of them was working a bit better then 2 others. One is almost fully freezes application and the other one, freeze application at all.


Could I see this movies?

Zeratul wrote:May be you have an ICQ or AIM account to talk about this problem ?


Please see private messages.
Best regards, Artem A. Razin,

F-IN-BOX support

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

Zeratul
Posts: 24
Joined: Sat Apr 01, 2006 8:19 am

Postby Zeratul » Tue Apr 11, 2006 12:12 pm

Softanics wrote:Simple example is GetImagePixels() in the Sample5_SWF2BitmapDlg.cpp.

Zeratul wrote:And also, what about function for getting last rendered frame pixel buffer ?
I wrote about this earlier.


I don't found function GetImagePixels in that file. Are you talking about the function, when OLE is used ?

Zeratul
Posts: 24
Joined: Sat Apr 01, 2006 8:19 am

Postby Zeratul » Tue Apr 11, 2006 12:39 pm

Thanks a lot. It is working now very fast. I got about 500% tune up. Thanks again. Good work guys!

tconkling
Posts: 4
Joined: Tue Jan 10, 2006 12:27 am

Postby tconkling » Tue Apr 18, 2006 5:39 pm

Is there any way you could post a simplified code snippet that better explains how to do this (like the sample code that appears on the Features page of the main website)? I'm not much of a Windows programmer, and I have a hard time pulling the important bits of code out of the example programs, which contain a lot of superfluous stuff about setting up windows and dialogs, and drawing icons and whatnot. The example provided (FPCNPaint1) compiles and runs for me, but nothing ever appears on the screen (no window, nothing) -- this makes it difficult for me to figure out which bits of code are important to the problem being solved.

I need this fast bitmap-getting code for a program that my company is about to ship. We added Flash movies at the last minute using FlashPlayerControl, and we've discovered that the ActiveX control isn't drawn properly when the app is in fullscreen mode (we use DirectX to capture the display). I made another forum post about this a few days ago, but I'm pretty sure this is a problem with controls being drawn while the screen is captured, and not with FlashPlayerControl itself.

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

Postby Softanics » Tue Apr 18, 2006 6:02 pm

tconkling wrote:The example provided (FPCNPaint1) compiles and runs for me, but nothing ever appears on the screen (no window, nothing) -- this makes it difficult for me to figure out which bits of code are important to the problem being solved.


Just replace this code:

Code: Select all

   CSample5_SWF2BitmapDlg* pDlg = new CSample5_SWF2BitmapDlg;
   m_pMainWnd = pDlg;
   pDlg->Create(CSample5_SWF2BitmapDlg::IDD);
   pDlg->ShowWindow(SW_HIDE);
   return TRUE;

/*
   CSample5_SWF2BitmapDlg dlg;
   m_pMainWnd = &dlg;
   INT_PTR nResponse = dlg.DoModal();
   if (nResponse == IDOK)
   {
      // TODO: Place code here to handle when the dialog is
      //  dismissed with OK
   }
   else if (nResponse == IDCANCEL)
   {
      // TODO: Place code here to handle when the dialog is
      //  dismissed with Cancel
   }

    //Since the dialog has been closed, return FALSE so that we exit the
    // application, rather than start the application's message pump.
   return FALSE;
*/


with:

Code: Select all

/*
   CSample5_SWF2BitmapDlg* pDlg = new CSample5_SWF2BitmapDlg;
   m_pMainWnd = pDlg;
   pDlg->Create(CSample5_SWF2BitmapDlg::IDD);
   pDlg->ShowWindow(SW_HIDE);
   return TRUE;
*/

   CSample5_SWF2BitmapDlg dlg;
   m_pMainWnd = &dlg;
   INT_PTR nResponse = dlg.DoModal();
   if (nResponse == IDOK)
   {
      // TODO: Place code here to handle when the dialog is
      //  dismissed with OK
   }
   else if (nResponse == IDCANCEL)
   {
      // TODO: Place code here to handle when the dialog is
      //  dismissed with Cancel
   }

    //Since the dialog has been closed, return FALSE so that we exit the
    // application, rather than start the application's message pump.
   return FALSE;


It makes the main window visible.

The main part of the code is:

Code: Select all

static
void WINAPI FPCListener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR)
{
   if (FPCN_UPDATE_RECT == pNMHDR->code)
   {
      // This causes FPCN_PAINT will be sent
      SendMessage(hwndFlashPlayerControl, WM_PAINT, 0, 0);
   }
   else if (FPCN_PAINT == pNMHDR->code)
   {
      SFPCNPaint* pFPCNPaint = (SFPCNPaint*)pNMHDR;
      LPDWORD lpPixels = pFPCNPaint->lpPixels; // <-- pixels buffer
      ATLTRACE(_T("FPCN_PAINT: 0x%.8x\n"), (DWORD)lpPixels);

      RECT rc;
      GetClientRect(hwndFlashPlayerControl, &rc);

      if (g_size.cx != rc.right || g_size.cy != rc.bottom)
      {
         if (NULL != g_lpPixels)
            delete[] g_lpPixels;

         g_size.cx = rc.right;
         g_size.cy = rc.bottom;

         g_lpPixels = new DWORD[g_size.cx * g_size.cy];
      }

      CopyMemory(g_lpPixels, lpPixels, g_size.cx * g_size.cy * sizeof(DWORD));

      // You can copy lpPixels into internal buffer or create what you want from this buffer (bitmaps, textures, etc.)
      // Note that lpPixels is temporary and you shouldn't save this pointer for futher using
   }
}


If you need visible window, you should comment

Code: Select all

SendMessage(hwndFlashPlayerControl, WM_PAINT, 0, 0)


Hope it helps.
Best regards, Artem A. Razin,

F-IN-BOX support

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

cvoid
Posts: 2
Joined: Thu Jun 22, 2006 1:20 pm

Postby cvoid » Thu Jun 22, 2006 2:27 pm

Softanics wrote:Yes. The problem is to get a bitmap with alpha channel, we need to paint a flash movie twice. And then calculate alpha component of the color. The problem is to do it quickly.


Hi there.

I assume that the reason you're doing this is because Flash
does not give you a full 32 bit bitmap ? ( Otherwise you would
already have the alpha )

Im just wondering how you would go about doing this.

Im trying to work out a similar problem using a Flash 8 ActionScript
and the new BitmapData class and since you guys are experts
and all, can you please post a basic exemple ( pseudo code )
on how to compare the pixels and calculate the alpha ?

Thanks a bunch !

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

Postby Softanics » Thu Jun 22, 2006 2:51 pm

cvoid wrote:can you please post a basic exemple ( pseudo code )
on how to compare the pixels and calculate the alpha ?


I'm sorry but I can't post this code because it is a part of library.
Best regards, Artem A. Razin,

F-IN-BOX support

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

cvoid
Posts: 2
Joined: Thu Jun 22, 2006 1:20 pm

Postby cvoid » Thu Jun 22, 2006 7:44 pm

Softanics wrote:
cvoid wrote:can you please post a basic exemple ( pseudo code )
on how to compare the pixels and calculate the alpha ?


I'm sorry but I can't post this code because it is a part of library.


Well i know that's why i said "pseudo" code.. as in just words
to relate generaly to the idea but, it's ok, at least you responded
and that's all that matters, so thanks anyways :)


Return to “DLL Edition”

Who is online

Users browsing this forum: No registered users and 16 guests

cron