Low speed in bitmap getting

DLL Edition of the F-IN-BOX
stark
Posts: 13
Joined: Tue May 11, 2010 11:18 am

Low speed in bitmap getting

Postby stark » Sat Dec 18, 2010 7:39 am

Hi :)

i'm using [DLL edition] to get movie frame's and creat texture
& finaly draw and paly it with directx9 in full screen or window mode

i do this....

but speed is very low cpu usge is over 50% with an simple flash...
i need to creat a texture with RGB and Alpha chanel

i do with this ways :
but speed...

SendMessage(g_hwndFlashPlayerControl, FPCM_GET_FRAME_BITMAP, 0, (LPARAM)&FPCGetFrameBitmap);

CopyMemory(g_lpPixels,..............................

OR

SendMessage(hwndFlashPlayerControl, WM_PAINT, 0, 0);

CopyMemory(g_lpPixels,..............................

:(

i need a Fast way to doing this...
when i use a big resulation like : 800x600 speed drawing is very low....

plz help me with code or give me a way ,,,,


Thank you very much....

stark
Posts: 13
Joined: Tue May 11, 2010 11:18 am

Postby stark » Sat Dec 18, 2010 10:28 am

hi again...

i read full this topic :

http://www.f-in-box.com/forum/viewtopic ... ht=directx

in page 3 mr "Zeratul" say :
"Thanks a lot. It is working now very fast. I got about 500% tune up. Thanks again. Good work guys!"


i think my problem is same.
but i can't underestand how to make it faster
please help me to speed up ...

Thank You.

c0mas
Posts: 20
Joined: Sat Nov 27, 2010 5:01 pm

Postby c0mas » Sat Dec 18, 2010 4:17 pm

Are you using the callback ? (like in the provided demo that does the same thing ... FlashTexture is called) it seems ok for me.

stark
Posts: 13
Joined: Tue May 11, 2010 11:18 am

Postby stark » Sat Dec 18, 2010 5:02 pm

hi
thank you for reading my topic
what's your mind about callback?

i just used


LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);




LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}

return DefWindowProc(hWnd, uMsg, wParam, lParam);
}



for close window in exit event.




i used

void WINAPI FPCListener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR)
.
.
.
.
SendMessage(hwndFlashPlayerControl, WM_PAINT, 0, 0);
.
.
CopyMemory(g_lpPixels, lpPixels, g_size.cx * g_size.cy * sizeof(DWORD));
.
.
.
Then create Texture..
.
.
.
and Then Draw with directx


but cpu usage is over 50% in a dual core cpu..
can u help me with a lite sample or a way....

thank you

stark
Posts: 13
Joined: Tue May 11, 2010 11:18 am

Postby stark » Sun Dec 19, 2010 4:57 am

this command is very slow....

SendMessage(hwndFlashPlayerControl, WM_PAINT, 0, 0);

is there any way to draw in buffer?

c0mas
Posts: 20
Joined: Sat Nov 27, 2010 5:01 pm

Postby c0mas » Sun Dec 19, 2010 2:21 pm

Are you creating the DX texture every time ? and also the buffer ?

stark
Posts: 13
Joined: Tue May 11, 2010 11:18 am

Postby stark » Sun Dec 19, 2010 3:00 pm

No i'm not make every time Texture my friend....
This is my code's
show
how to i make a Texture...
i cut d3d codes for DECREASE code's.....

i set g_pd3dDevice->SetTexture( 0, g_pTexture );
in render Sub()...


Thank You "c0mas"








/////////////////////////BASE DEFINE///////////////////////////////////////
// Headers
#include <tchar.h>
#define _WIN32_WINNT 0x0500

#include "../f_in_box/include/f_in_box.h"
#pragma comment(lib, "../f_in_box/lib/f_in_box.lib")

// Direct 3D
#include <d3dx9math.h>
#include <d3d9types.h>


#define DEF_WIDTH (480)
#define DEF_HEIGHT (480)


#define DEF_MAIN_WND_WIDTH (480)
#define DEF_MAIN_WND_HEIGHT (480)

static HFPC g_hFPC = NULL;
static HWND g_hwndFlashPlayerControl = NULL;
static BOOL g_bTransparent;
static LPDWORD g_lpPixels = NULL;
static SIZE g_size = { 0 };
static RECT g_rcUpdate = { 0 };


D3DSURFACE_DESC d3dsd;


static void WINAPI FPCListener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR);















/////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )



g_hFPC = FPC_LoadRegisteredOCX();




g_hwndFlashPlayerControl =
FPC_CreateWindow(g_hFPC,
g_bTransparent ? WS_EX_LAYERED : 0,
NULL,
g_bTransparent ? WS_POPUP : WS_CHILD | WS_CLIPSIBLINGS | FPCS_TRANSPARENT,
0,
0,
DEF_WIDTH,
DEF_HEIGHT,
g_hWnd,
NULL,
NULL,
NULL);



FPC_PutMovie (g_hwndFlashPlayerControl,"c:\\5MOVIE.SWF");


FPC_Play(g_hwndFlashPlayerControl);

FPCSetEventListener(g_hwndFlashPlayerControl, &FPCListener, 0);












////////////////////////////////////////////////////////////////////////////////////////////////////initial Application
void init( void )
{


//Creat Texture;

D3DXCreateTexture(g_pd3dDevice,
DEF_WIDTH,
DEF_HEIGHT,
1,
0,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
&g_pTexture);


g_pTexture->GetLevelDesc(0, &d3dsd);















/////////////////////////////////////////void UpdateTexture()..........

// Size
SIZE size = { d3dsd.Width, d3dsd.Height };

D3DLOCKED_RECT rcLockedRect = { 0 };
RECT rc = g_rcUpdate;

g_pTexture->LockRect(0, &rcLockedRect, &rc, D3DLOCK_DISCARD);
{
if (NULL != g_lpPixels)
{
BYTE* pTextureBits = (BYTE*)rcLockedRect.pBits;

DWORD dwSizeOfLineInDWORDs = DEF_WIDTH;

DWORD* pBitmapBitsStart = g_lpPixels + (DEF_HEIGHT - rc.bottom) * dwSizeOfLineInDWORDs + rc.left;

BYTE* pLineTextureBits = pTextureBits + rcLockedRect.Pitch * (rc.bottom - rc.top - 1);

for (int j = rc.top; j < rc.bottom; j++)
{
DWORD* pPixels = (DWORD*)pLineTextureBits;

DWORD* pBitmapBits = pBitmapBitsStart;

/*
for (int i = rc.left; i < rc.right; i++)
{
*pPixels = *pBitmapBits;

pPixels++;
pBitmapBits++;
}
*/
CopyMemory(pPixels, pBitmapBits, (rc.right - rc.left) * sizeof(DWORD));

pLineTextureBits -= rcLockedRect.Pitch;
pBitmapBitsStart += dwSizeOfLineInDWORDs;
}
}
}
g_pTexture->UnlockRect(0);


}











//////////////////////////////////////////void WINAPI FPCListener....

static
void WINAPI FPCListener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR)
{




if (FPCN_UPDATE_RECT == pNMHDR->code)
{
g_rcUpdate = ((SFPCNUpdateRect*)pNMHDR)->rc;

if (g_rcUpdate.right > DEF_WIDTH)
g_rcUpdate.right = DEF_WIDTH;
if (g_rcUpdate.bottom > DEF_HEIGHT)
g_rcUpdate.bottom = DEF_HEIGHT;





// 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

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));



UpdateTexture();


render();












}






any thing's need ?
just tell me....
Thank You Very Much

c0mas
Posts: 20
Joined: Sat Nov 27, 2010 5:01 pm

Postby c0mas » Mon Dec 20, 2010 6:34 pm

I'm doing something similar (it seems we both have based our code on the FlashTexture sample). but I'm using the version with transparency and I'm not using that WM_PAINT message.

You can try that if the SendMessage shows up in a profiler.

Also you can try the Code Analyzer from AMD ... it might show you some weak spots in your code.

Cheers,
/C0mas

stark
Posts: 13
Joined: Tue May 11, 2010 11:18 am

t

Postby stark » Tue Dec 21, 2010 6:35 am

hi
Thank's a lot for your help's C0mas

u say :
" but I'm using the version with transparency and I'm not using that WM_PAINT message. "

Great !

i need to this...
i want to use Transparent but how to?

importing a window with flash transparented in front another d3d window?
it's a easy but..
this not work when i swich d3dwindow in full screen render
flash transparented window will going to back automatically

but how to do this and solve it u ?
can u insert code's?
or example.zip

Best Regard's.

stark
Posts: 13
Joined: Tue May 11, 2010 11:18 am

Postby stark » Tue Dec 21, 2010 8:05 am

do you used Sample09_TransparentControl for Transparent ?

is this possible to render both [TransparentControl & d3d] in one window?

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

Re: Low speed in bitmap getting

Postby Softanics » Tue Dec 21, 2010 4:15 pm

Hello,

stark wrote:but speed is very low cpu usge is over 50% with an simple flash...
i need to creat a texture with RGB and Alpha chanel


Just to clarify. If you start the DX sample without changes, does it work well?

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

stark
Posts: 13
Joined: Tue May 11, 2010 11:18 am

Postby stark » Wed Dec 22, 2010 8:14 am

the DX sample without changes, does'not it work well.....

http://stark.persiangig.com/A.JPG
:(

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

Postby Softanics » Wed Dec 22, 2010 12:20 pm

In both modes?...
Best regards, Artem A. Razin,

F-IN-BOX support

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

stark
Posts: 13
Joined: Tue May 11, 2010 11:18 am

Postby stark » Thu Dec 23, 2010 6:20 am

Yes,In both modes .....
:(

c0mas
Posts: 20
Joined: Sat Nov 27, 2010 5:01 pm

Postby c0mas » Thu Dec 23, 2010 8:38 pm

In the demo, there is a D3DXCreateTexture call.

Try to use D3DPOOL_DEFAULT and USAGE_DYNAMIC, also check if your directX is set up for release.


Return to “DLL Edition”

Who is online

Users browsing this forum: No registered users and 11 guests

cron