DirectX Transform Sample application
CoInitialize(NULL);
CoUnitialize();
IDXTransformFactory* g_pTransFact;
IDXSurfaceFactory* g_pSurfFact;
IDXTransform* g_pWipeTrans;
IDXSurface* g_pInSurfA;
IDXSurface* g_pInSurfB;
IDXEffect* g_pEffect;
BOOL ReadImageFile (IDXSurface **lplpDXSurf, PTSTR pstrFileName)
{
WCHAR pwcsBuffer[256] ;
HRESULT hr;
char szString[256];
#ifndef UNICODE
mbstowcs( pwcsBuffer, pstrFileName, strlen(pstrFileName)+1 );
#endif
// Load Input surfaces
hr = g_pSurfFact->LoadImage( pwcsBuffer, NULL, NULL,
&DDPF_PMARGB32, IID_IDXSurface, (void**)lplpDXSurf );
if (FAILED(hr))
{
wsprintf(szString, "Couldn't load image! hr=0x%08x", hr);
MessageBox(g_hDlg, szString, _T("Error Loading"), MB_ICONERROR );
}
return SUCCEEDED( hr );
}
//Create the transform factory
hr = CoCreateInstance( CLSID_DXTransformFactory,
NULL,
CLSCTX_INPROC,
IID_IDXTransformFactory,
(void**) &g_pTransFact );
_ASSERTE( g_pTransFact != NULL);
if(SUCCEEDED(hr))
{
//--- Get the surface factory interface
hr = g_pTransFact->QueryService( SID_SDXSurfaceFactory,
IID_IDXSurfaceFactory,
(void**) & g_pSurfFact
);
_ASSERTE ( g_pSurfFact != NULL);
}
//Create the Wipe transform and set it up...
if(SUCCEEDED(hr))
{
hr = g_pTransFact->CreateTransform( NULL,
0,
NULL,
0,
NULL,
NULL,
CLSID_DXTWipe,
IID_IDXTransform,
(void**)&g_pWipeTrans
);
_ASSERTE( g_pWipeTrans != NULL);
}
// Get the Effect interface. We'll use this to set
// execution properties for the effect (ie PercentComplete, Duration)
if( SUCCEEDED(hr))
{
hr = g_pWipeTrans ->QueryInterface( IID_IDXEffect,
(void**) &g_pEffect
);
_ASSERTE( g_pEffect != NULL);
}
int width = 400;
int height = 400;
CDXDBnds bnds;
bnds.SetXYSize( width, height);
hr = g_pSurfFact->CreateSurface( NULL,
NULL,
&DDPF_PMARGB32,
&bnds,
0,
NULL,
IID_IDXSurface,
(void**) g_pSurfFact );
ReadImageFile(g_pInSurf1,"test.png");
ReadImageFile(g_pInSurf2,"test2.png");
void HandlePlayForward()
{
float PercentComplete = 0;
do
{
g_pEffect->put_progress(PercentComplete);
PercentComplete = PercentComplete + 0.1f;
}
while( PercentComplete <= 1.0);
}
CoUnitialize();
IDXTransformFactory* g_pTransFact;
IDXSurfaceFactory* g_pSurfFact;
IDXTransform* g_pWipeTrans;
IDXSurface* g_pInSurfA;
IDXSurface* g_pInSurfB;
IDXEffect* g_pEffect;
BOOL ReadImageFile (IDXSurface **lplpDXSurf, PTSTR pstrFileName)
{
WCHAR pwcsBuffer[256] ;
HRESULT hr;
char szString[256];
#ifndef UNICODE
mbstowcs( pwcsBuffer, pstrFileName, strlen(pstrFileName)+1 );
#endif
// Load Input surfaces
hr = g_pSurfFact->LoadImage( pwcsBuffer, NULL, NULL,
&DDPF_PMARGB32, IID_IDXSurface, (void**)lplpDXSurf );
if (FAILED(hr))
{
wsprintf(szString, "Couldn't load image! hr=0x%08x", hr);
MessageBox(g_hDlg, szString, _T("Error Loading"), MB_ICONERROR );
}
return SUCCEEDED( hr );
}
//Create the transform factory
hr = CoCreateInstance( CLSID_DXTransformFactory,
NULL,
CLSCTX_INPROC,
IID_IDXTransformFactory,
(void**) &g_pTransFact );
_ASSERTE( g_pTransFact != NULL);
if(SUCCEEDED(hr))
{
//--- Get the surface factory interface
hr = g_pTransFact->QueryService( SID_SDXSurfaceFactory,
IID_IDXSurfaceFactory,
(void**) & g_pSurfFact
);
_ASSERTE ( g_pSurfFact != NULL);
}
//Create the Wipe transform and set it up...
if(SUCCEEDED(hr))
{
hr = g_pTransFact->CreateTransform( NULL,
0,
NULL,
0,
NULL,
NULL,
CLSID_DXTWipe,
IID_IDXTransform,
(void**)&g_pWipeTrans
);
_ASSERTE( g_pWipeTrans != NULL);
}
// Get the Effect interface. We'll use this to set
// execution properties for the effect (ie PercentComplete, Duration)
if( SUCCEEDED(hr))
{
hr = g_pWipeTrans ->QueryInterface( IID_IDXEffect,
(void**) &g_pEffect
);
_ASSERTE( g_pEffect != NULL);
}
int width = 400;
int height = 400;
CDXDBnds bnds;
bnds.SetXYSize( width, height);
hr = g_pSurfFact->CreateSurface( NULL,
NULL,
&DDPF_PMARGB32,
&bnds,
0,
NULL,
IID_IDXSurface,
(void**) g_pSurfFact );
ReadImageFile(g_pInSurf1,"test.png");
ReadImageFile(g_pInSurf2,"test2.png");
void HandlePlayForward()
{
float PercentComplete = 0;
do
{
g_pEffect->put_progress(PercentComplete);
PercentComplete = PercentComplete + 0.1f;
}
while( PercentComplete <= 1.0);
}
Labels: Directshow Editing Services
0 Comments:
Post a Comment
<< Home