2,851
社区成员




/*===========================================================================
FILE: testbmp.c
===========================================================================*/
/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "AEETransform.h"
#include "AEEBitmap.h"
#include "AEEGraphics.h"
#include "testbmp.bid"
/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "pMe->"
-------------------------------------------------------------------*/
// create an applet structure that's passed around. All variables in
// here will be able to be referenced as static.
typedef struct _testbmp {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
// add your own variables here...
IShell *pIShell;
IDisplay *pIDisplay;
IGraphics *piGraphic;
IBitmap *srcBmp;
IBitmap *newBmp;
} testbmp;
/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean testbmp_HandleEvent(testbmp* pMe, AEEEvent eCode,
uint16 wParam, uint32 dwParam);
boolean testbmp_InitAppData(testbmp* pMe);
void testbmp_FreeAppData(testbmp* pMe);
void Start(testbmp* pMe);
/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */
/*===========================================================================
===========================================================================*/
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_TESTBMP )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(testbmp),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)testbmp_HandleEvent,
(PFNFREEAPPDATA)testbmp_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(testbmp_InitAppData((testbmp*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}
return(EFAILED);
}
/*===========================================================================
===========================================================================*/
static boolean testbmp_HandleEvent(testbmp* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
Start(pMe);
return(TRUE);
// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...
return(TRUE);
// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...
return(TRUE);
// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
return(TRUE);
// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...
return(TRUE);
// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
// Add your code here...
return(TRUE);
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;
}
// this function is called when your application is starting up
boolean testbmp_InitAppData(testbmp* pMe)
{
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// Insert your code here for initializing or allocating resources...
pMe->pIShell=pMe->a.m_pIShell;
pMe->pIDisplay=pMe->a.m_pIDisplay;
ISHELL_CreateInstance( pMe->pIShell, AEECLSID_GRAPHICS, (void **)&pMe->piGraphic );
// if there have been no failures up to this point then return success
return TRUE;
}
void testbmp_FreeAppData(testbmp* pMe)
{
}
IBitmap* PaintTransform(testbmp* pMe,IBitmap * pBitMap, int nAngle, int nX, int nY)
{
AEEBitmapInfo BitmapInfo;
AEETransformMatrix pMatrixTransform;
IBitmap* dst = NULL;
ITransform* pTransform ;//= NULL;
int neeor;
IBITMAP_GetInfo(pBitMap, &BitmapInfo, sizeof(AEEBitmapInfo));
pMatrixTransform.A = -256;
pMatrixTransform.B = 0;
pMatrixTransform.C = 0;
pMatrixTransform.D = -256;
neeor = IBITMAP_CreateCompatibleBitmap(pBitMap,&dst,BitmapInfo.cx,BitmapInfo.cy);
neeor = IBITMAP_QueryInterface(dst,AEECLSID_TRANSFORM,(void**)&pTransform);
if ( pTransform )
{
ITRANSFORM_TransformBltComplex(pTransform, 0, 0, pBitMap, 0, 0, BitmapInfo.cx, BitmapInfo.cy, &pMatrixTransform, COMPOSITE_OPAQUE);
IDISPLAY_BitBlt(pMe->pIDisplay,nX, nY, BitmapInfo.cx, BitmapInfo.cy, dst,0,0,AEE_RO_COPY);
}
IBITMAP_Release(dst);
ITRANSFORM_Release(pTransform);
}
void Start(testbmp* pMe)
{
IBitmap *pbmScreen = NULL;
IBitmap *pbmDib = NULL;
NativeColor color;
AEEBitmapInfo bi;
pbmScreen = IDISPLAY_GetDestination(pMe->a.m_pIDisplay);
IDISPLAY_ClearScreen(pMe->pIDisplay);
pbmDib = ISHELL_LoadBitmap(pMe->a.m_pIShell,"123.bmp");
IBITMAP_GetInfo(pbmDib, &bi, sizeof(bi));
IBITMAP_CreateCompatibleBitmap(pbmScreen, &pMe->srcBmp, (uint16)bi.cx, (uint16)bi.cy);
IBITMAP_BltIn(pMe->srcBmp, 0, 0, (uint16)bi.cx, (uint16)bi.cy, pbmDib, 0, 0, AEE_RO_COPY);
IBITMAP_Release(pbmDib);
PaintTransform(pMe,pMe->srcBmp,20,0,50);
IDISPLAY_BitBlt(pMe->pIDisplay, 0, 0, 58, 26, pMe->srcBmp, 0, 0, AEE_RO_TRANSPARENT);
IDISPLAY_Update(pMe->pIDisplay);
}