使用Brew 2.1 版本的sdk实现一个图片的任意角度旋转

linyd 2010-11-15 11:25:13
以下网上找的图片任意角度旋转的实现代码
void PaintTransform(IBitmap * pBitMap, int nAngle, int nX, int nY)
{
AEEBitmapInfo BitmapInfo;

IBITMAP_GetInfo(pBitMap, &BitmapInfo, sizeof(AEEBitmapInfo));

AEETransformMatrix pMatrixTransform;

pMatrixTransform.A = 256;
pMatrixTransform.B = 0;
pMatrixTransform.C = 0;
pMatrixTransform.D = 256;

IBitmap* dst = NULL;
ITransform* pTransform = NULL;

IBITMAP_CreateCompatibleBitmap(pBitMap,&dst,BitmapInfo.cx,BitmapInfo.cy);

int neeor = IBITMAP_QueryInterface(dst,AEECLSID_TRANSFORM,(void**)&pTransform);

if ( pTransform )
{
ITRANSFORM_TransformBltComplex(pTransform, nX, nY, pBitMap, 0, 0, BitmapInfo.cx, BitmapInfo.cy, &pMatrixTransform, COMPOSITE_OPAQUE);
IDISPLAY_BitBlt(gpDC->getIDisplay(),nX, nY, BitmapInfo.cx, BitmapInfo.cy, dst,0,0,AEE_RO_COPY);
}

IBITMAP_Release(dst);
ITRANSFORM_Release(pTransform);
}


int neeor = IBITMAP_QueryInterface(dst,AEECLSID_TRANSFORM,(void**)&pTransform);
这个返回1,pTransform为空,初学brew,请高手帮忙看看怎么回事


...全文
2939 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
strayedbird 2012-05-22
  • 打赏
  • 举报
回复
参考下面的图像旋转的介绍
https://developer.brewmp.com/cn/forum/%E5%9B%BE%E5%83%8F%E6%97%8B%E8%BD%AC%E6%8E%A5%E5%8F%A3itransform%E4%BB%8B%E7%BB%8D
吉祥衰宝 2012-05-18
  • 打赏
  • 举报
回复
在旋转时对于左上角的点不是(0,0)的旋转表示很纠结,
wishifef 2010-11-16
  • 打赏
  • 举报
回复

这是用你的代码写的例子,垂直翻转图片,效果出来了,你看看对你有帮助没

/*===========================================================================

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

raingo11 2010-11-15
  • 打赏
  • 举报
回复
创建实例应该用ISHELL_CreateInstance
int ISHELL_CreateInstance
(
IShell * pIShell,
AEECLSID cls,
void * * ppobj
)

参见API
linyd 2010-11-15
  • 打赏
  • 举报
回复
up,没人回答吗

2,851

社区成员

发帖
与我相关
我的任务
社区描述
本论坛以AI、WoS 、XR、IoT、Auto、生成式AI等核心板块组成,为开发者提供便捷及高效的学习和交流平台。 高通开发者专区主页:https://qualcomm.csdn.net/
人工智能物联网机器学习 技术论坛(原bbs) 北京·东城区
社区管理员
  • csdnsqst0050
  • chipseeker
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧