📄 exdiag.c
字号:
/*===========================================================================
FILE: ExDiag.c
===========================================================================*/
/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "ExDiag.bid"
#include "ExDiag_res.h"
#include "AEEMenu.h"
#include "AEETransform.h"
#include "AEEText.h"
#include "AEEMenu.h"
#include "AEEStdLib.h"
#include "ExDiag.bid"
/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "pMe->"
-------------------------------------------------------------------*/
typedef struct _ExDiag {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
IDisplay *pIDisplay; // give a standard way to access the Display interface
IShell *pIShell; // give a standard way to access the Shell interface
// add your own variables here...
IDialog *pIDiag;
IMenuCtl *pIMenuCtl;
ITextCtl *pITextCtl;
IStatic *pIStatic;
} ExDiag;
/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean ExDiag_HandleEvent(ExDiag* pMe,
AEEEvent eCode, uint16 wParam,
uint32 dwParam);
boolean ExDiag_InitAppData(ExDiag* pMe);
void ExDiag_FreeAppData(ExDiag* pMe);
/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */
/*===========================================================================
FUNCTION: AEEClsCreateInstance
===========================================================================*/
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_EXDIAG )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(ExDiag),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)ExDiag_HandleEvent,
(PFNFREEAPPDATA)ExDiag_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(ExDiag_InitAppData((ExDiag*)*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);
}
void ConvertPic(IBitmap *pbm)
{
IDIB *pDib;
int i = 0, j = 0;
int src1,des1,src2,des2,src3,des3;
byte byTemp1,byTemp2,byTemp3;
int picWidth;
int picHeight;
AEEBitmapInfo info;
IBITMAP_GetInfo(pbm,&info,sizeof(info));
picWidth = info.cx;
picHeight = info.cy;
IBITMAP_QueryInterface(pbm, AEECLSID_DIB, (void**)&pDib);
if (pDib->nDepth == 8)
{
for (i = 0; i < picHeight; i++)
{
for (j = 0; j < picWidth / 2; j++)
{
src1 = pDib->nPitch * i + j;
des1 = pDib->nPitch * i + (picWidth - 1 - j);
byTemp1 = pDib->pBmp[src1];
pDib->pBmp[src1] = pDib->pBmp[des1];
pDib->pBmp[des1] = byTemp1;
}
}
}
else if(pDib->nDepth == 4)
{
for(i = 0; i < picHeight; i ++)
{
for(j = 0; j < picWidth / 4; j ++)
{
src1 = pDib->nPitch * i + j;
des1 = pDib->nPitch * i + (picWidth / 2 - 1 - j);
byTemp1 = pDib->pBmp[src1];
pDib->pBmp[src1] = pDib->pBmp[des1];
pDib->pBmp[des1] = byTemp1;
byTemp1 = pDib->pBmp[src1];
pDib->pBmp[src1] = ((byTemp1 & 0xF) << 4) | ((byTemp1 & 0xF0) >> 4);
byTemp1 = pDib->pBmp[des1];
pDib->pBmp[des1] = ((byTemp1 & 0xF) << 4) | ((byTemp1 & 0xF0) >> 4);
}
}
}
else if (pDib->nDepth == 16)
{
for (i = 0; i < picHeight; i++)
{
for (j = 0; j < picWidth / 2; j++)
{
src1 = pDib->nPitch * i + j * 2;
src2 = pDib->nPitch * i + j * 2 + 1;
des1 = pDib->nPitch * i + (picWidth - 1 - j) * 2;
des2 = pDib->nPitch * i + (picWidth - 1 - j) * 2 + 1;
byTemp1 = pDib->pBmp[src1];
byTemp2 = pDib->pBmp[src2];
pDib->pBmp[src1] = pDib->pBmp[des1];
pDib->pBmp[src2] = pDib->pBmp[des2];
pDib->pBmp[des1] = byTemp1;
pDib->pBmp[des2] = byTemp2;
}
}
}
else if (pDib->nDepth == 24)
{
for (i = 0; i < picHeight; i++)
{
for (j = 0; j < picWidth / 2; j++)
{
src1 = pDib->nPitch * i + j * 3;
src2 = pDib->nPitch * i + j * 3 + 1;
src3 = pDib->nPitch * i + j * 3 + 2;
des1 = pDib->nPitch * i + (picWidth - 1 - j) * 3;
des2 = pDib->nPitch * i + (picWidth - 1 - j) * 3 + 1;
des3 = pDib->nPitch * i + (picWidth - 1 - j) * 3 + 2;
byTemp1 = pDib->pBmp[src1];
byTemp2 = pDib->pBmp[src2];
byTemp3 = pDib->pBmp[src3];
pDib->pBmp[src1] = pDib->pBmp[des1];
pDib->pBmp[src2] = pDib->pBmp[des2];
pDib->pBmp[src3] = pDib->pBmp[des3];
pDib->pBmp[des1] = byTemp1;
pDib->pBmp[des2] = byTemp2;
pDib->pBmp[des3] = byTemp3;
}
}
}
//pbm = IDIB_TO_IBITMAP(pDib);
IDIB_Release(pDib);
}
/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent
===========================================================================*/
static boolean ExDiag_HandleEvent(ExDiag* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
//IMENUCTL_HandleEvent(pMe->pIMenuCtl,eCode,wParam,dwParam);
if(pMe->pITextCtl)
{
ITEXTCTL_HandleEvent(pMe->pITextCtl,eCode,wParam,dwParam);
}
if(pMe->pIStatic)
{
ISTATIC_HandleEvent(pMe->pIStatic,eCode,wParam,dwParam);
}
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
{
int res;
IMenuCtl *pList;
res = ISHELL_CreateDialog(pMe->pIShell,EXDIAG_RES_FILE,IDD_DEMO,NULL);
pMe->pIDiag = ISHELL_GetActiveDialog(pMe->pIShell);
IDIALOG_SetFocus(pMe->pIDiag,IDD_LIST);
pList = (IMenuCtl*)IDIALOG_GetControl(pMe->pIDiag,IDD_LIST);
{
AEERect rect;
rect.x = 0;
rect.y = 20;
rect.dx = pMe->DeviceInfo.cxScreen;
rect.dy = 20;
IMENUCTL_SetRect(pList,&rect);
}
IDIALOG_Redraw(pMe->pIDiag);
/*
//b
/*IImage *pImage;
AEEImageInfo imageInfo;
pImage = ISHELL_LoadImage(pMe->pIShell,"demo.bmp");
IIMAGE_GetInfo(pImage,&imageInfo);
//IIMAGE_SetParm(pImage,IPARM_ROP,AEE_RO_TRANSPARENT,0);
//IIMAGE_
//png,图片的透明不好用,
IIMAGE_Draw(pImage,0,0);
//IIMAGE_SetFrameSize(pImage,20);
//IIMAGE_Start(pImage,0,0);
IDISPLAY_Update(pMe->pIDisplay);
IIMAGE_Release(pImage);
//IBitmap *pIBmp = ISHELL_LoadBitmap(pMe->pIShell,"demo.bmp");
//IDISPLAY_Update(pMe->pIDisplay);
IBitmap *pScreen;
IBitmap *pBitmap;
IBitmap *pBmp2;
IBitmap *pImage;
AEEBitmapInfo Info;
NativeColor color;
ITransform *pITransform;
AEETransformMatrix matrix;
pScreen = IDISPLAY_GetDestination(pMe->pIDisplay);
pImage = ISHELL_LoadBitmap(pMe->pIShell,"demo.bmp");
if(pImage==NULL)
{
IBITMAP_Release(pScreen);
}
IBITMAP_GetInfo(pImage, &Info,sizeof(Info));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -