⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 brew_lib.txt

📁 自己开发的brew 程序库
💻 TXT
📖 第 1 页 / 共 3 页
字号:
 
 if ( pIImg )
 {
  // GET Display Destination
  pDes = IDISPLAY_GetDestination( m_pIDisplay );
  if ( pDes )
  {
   IIMAGE_GetInfo( pIImg, &imginfo );
   if( IBITMAP_CreateCompatibleBitmap( pDes, &ret, imginfo.cx, imginfo.cy ) == SUCCESS )
   {
    // SET Display Destination
    IDISPLAY_SetDestination( m_pIDisplay, ret );

    // DRAW At ret Bitmap
    IIMAGE_Draw( pIImg, 0, 0 );

    // RESTORE Display Destination
    IDISPLAY_SetDestination( m_pIDisplay, pDes );
   }
   
   IBITMAP_Release( pDes );
  }
 }

 return ret;
}


/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
IBitmap* CApp::getBitmap( IImage* pIImg, RGBVAL transCol )
{
 IBitmap* ret = NULL;
 IBitmap* pDes = NULL;
 AEEImageInfo imginfo;
 
 if ( pIImg )
 {
  // GET Display Destination
  pDes = IDISPLAY_GetDestination( m_pIDisplay );
  if ( pDes )
  {
   IIMAGE_GetInfo( pIImg, &imginfo );
   if( IBITMAP_CreateCompatibleBitmap( pDes, &ret, imginfo.cx, imginfo.cy ) == SUCCESS )
   {
    // SET Display Destination
    IDISPLAY_SetDestination( m_pIDisplay, ret );
    
    // FILL ret with transparent color
    AEERect rect;
    SETAEERECT( &rect, 0, 0, imginfo.cx, imginfo.cy );
    IDISPLAY_FillRect( m_pIDisplay, &rect, transCol );

    // DRAW At ret Bitmap
    IIMAGE_Draw( pIImg, 0, 0 );

    // SET ret transparent color
    IBITMAP_SetTransparencyColor( ret, IBITMAP_RGBToNative( ret, transCol ) );

    // RESTORE Display Destination
    IDISPLAY_SetDestination( m_pIDisplay, pDes );
   }
   
   IBITMAP_Release( pDes );
  }
 }

 return ret;
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
IBitmap* CApp::createPNGBitmap( uint8* data, int dataSz )
{
 IBitmap* ret = NULL;
 IMemAStream* p_memStream = NULL;
 IImage* pIImg = NULL;
 
 if ( data != NULL && dataSz > 0 )
 {
  if ( ISHELL_CreateInstance( m_pIShell, AEECLSID_MEMASTREAM, (void**)&p_memStream ) == SUCCESS )
  {
   // IMemAStream Instance CREATED
   byte* p_memData = (uint8*)MALLOC(dataSz);
   if( p_memData )
   {
    MEMMOVE( p_memData, data, dataSz );
    IMEMASTREAM_Set( p_memStream, p_memData, dataSz, 0, FALSE );

    ret = createPNGBitmap( p_memStream );
   }

   // RLEASE IMemAStream
   if( p_memStream )
    IMEMASTREAM_Release( p_memStream );
  }
 }

 return ret;
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
IBitmap* CApp::createPNGBitmap( IMemAStream* pMemStream )
{
 IBitmap* ret = NULL;
 IImage* pIImg = NULL;
 
 if ( ISHELL_CreateInstance( m_pIShell, AEECLSID_PNG, (void**)&pIImg ) == SUCCESS )
 {
  // IImage-PNG CREATED.
  // SET MEM_STREAM
  IIMAGE_SetStream( pIImg, (IAStream*)pMemStream );

  // CREATE ret
  ret = getBitmap( pIImg );

  // RELEASE IImage_PNG
  IIMAGE_Release( pIImg );
  //p_memStream = NULL;
 }

 return ret;
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
IBitmap* CApp::createPNGBitmap( IMemAStream* pMemStream, RGBVAL transCol )
{
 IBitmap* ret = NULL;
 IImage* pIImg = NULL;
 
 if ( ISHELL_CreateInstance( m_pIShell, AEECLSID_PNG, (void**)&pIImg ) == SUCCESS )
 {
  // IImage-PNG CREATED.
  // SET MEM_STREAM
  IIMAGE_SetStream( pIImg, (IAStream*)pMemStream );

  // CREATE ret
  ret = getBitmap( pIImg, transCol );

  // RELEASE IImage_PNG
  IIMAGE_Release( pIImg );
  //p_memStream = NULL;
 }

 return ret;
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
int CApp::GetImageW( IBitmap* pbmp )
{
 if ( pbmp == NULL ) return 0;

 AEEBitmapInfo bi;
 IBITMAP_GetInfo( pbmp, &bi, sizeof(bi) );
 return bi.cx;
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
int CApp::GetImageH( IBitmap* pbmp )
{
 if ( pbmp == NULL ) return 0;

 AEEBitmapInfo bi;
 IBITMAP_GetInfo( pbmp, &bi, sizeof(bi) );
 return bi.cy;
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
void CApp::drawRegion( IBitmap* pSrc, int xSrc, int ySrc, int w, int h, int transform, int xDes, int yDes )
{
 if ( transform != TRANS_MIRROR )
 {
  // NO Transform
  IDISPLAY_BitBlt( m_pIDisplay, xDes, yDes, w, h, pSrc, xSrc, ySrc, AEE_RO_TRANSPARENT );
 }
 else
 {
  // MIRROR Transform
  ITRANSFORM_TransformBltSimple( pTransform, xDes, yDes, pSrc, xSrc, ySrc, w, h, TRANSFORM_FLIP_X | TRANSFORM_ROTATE_180, COMPOSITE_KEYCOLOR );
 }
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
void CApp::setColor( int color )
{
 IGRAPHICS_SetColor( pGraphics, GET_R(color), GET_G(color), GET_B(color), 0 );
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
RGBVAL CApp::getColor()
{
 uint8 r,g,b,alpha;
 IGRAPHICS_GetColor( pGraphics, &r, &g, &b, &alpha );
 return MAKE_RGB( r, g, b );
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
void CApp::drawRect( int x, int y, int w, int h )
{
 AEERect rect;
 SETAEERECT( &rect, x, y, w, h );
 IDISPLAY_DrawRect( m_pIDisplay, &rect, getColor(), RGB_NONE, IDF_RECT_FRAME );
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
void CApp::drawRect( int x, int y, int w, int h, RGBVAL color )
{
 AEERect rect;
 SETAEERECT( &rect, x, y, w, h );
 IDISPLAY_DrawRect( m_pIDisplay, &rect, color, RGB_NONE, IDF_RECT_FRAME );
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
void CApp::fillRect( int x, int y, int w, int h )
{
 AEERect rect;
 SETAEERECT( &rect, x, y, w, h );
 IDISPLAY_FillRect( m_pIDisplay, &rect, getColor() );
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
void CApp::fillRect( int x, int y, int w, int h, RGBVAL color )
{
 AEERect rect;
 SETAEERECT( &rect, x, y, w, h );
 IDISPLAY_FillRect( m_pIDisplay, &rect, color );
}

/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
void CApp::drawLine( int x1, int y1, int x2, int y2 )
{
 AEELine line;
 line.sx = x1; line.sy = y1;
 line.ex = x2; line.ey = y2;
 IGRAPHICS_DrawLine( pGraphics, &line );
}
/*******************************************************************************************************************************************
* FUNCTION      : 
* DESCRIPTION   : 
* RETURN        : 
*******************************************************************************************************************************************/
IBitmap* CApp::createImage( int w, int h )
{
 IBitmap* ret = NULL;
 IBitmap* dev = NULL;

 IDISPLAY_GetDeviceBitmap( m_pIDisplay, &dev );
 if ( dev )
 {
  IBITMAP_CreateCompatibleBitmap( dev, &ret, w, h );

  IBITMAP_Release( dev );
  dev = NULL;
 }
 
 return ret;
}


移植我的 Pocket PC 2003 应用程序到 Windows Mobile 2005:【上一篇】
ZYBB项目总结(二):【下一篇】 
【相关文章】 

BREW的资源文件概述及问题 
《深入BREW开发》——前言 
《深入BREW开发》——第一篇 勿在浮沙筑高塔 
《深入BREW开发》——第一章 硬件基础 
深度剖析BREW实现原理 
数据库技术在BREW中的应用 
brew3.1.5的simulator 不能显示中文 
BREW Applet框架 
开发 BREW Extension 
BREW回调技术分析 
【相关评论】
没有相关评论 
【发表评论】
 姓名:
邮件:
随机码*: 
评论*:
       |  首 页  |  版权声明  |  联系我们   |  网站地图  |it 
CopyRight ? 2004-2007 软讯网络 All Rigths Reserved. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -