今天在MSDN 站点上看到一篇<GAPI 时代>文章,有关介绍GAPI编程的内容,原文地址.
GAPI 提供了一系列函数,可以直接对屏幕缓冲区进行读/写访问,因此处理的效率明显高于GDI.于是想到了改用GAPI来实现手机九宫格菜单.
我手中的设备是ARMI平台的,而从Microsoft提供下载的GAPI是ARM版本,所以开始我抱着侥幸的心情尝试着,没想到居然能成功的运行在ARMI设备上,看来GAPI的ARM版本还是能很好的运行在ARMI平台上,心中窃喜中.以下是用GAPI实现的九宫格菜单的手机截图,增加了Alpha效果.

 

以下部分是实现Alpha效果的代码,希望对大家实现Alpha有所参考
for (int y = 0; y < nHeight; y++)
{
 WORD* pDest = pDestLine;
 WORD* pSrc = pSrcLine;
 for (int x = 0; x < nWidth; x++)
 {
  if (*pSrc != dwTranspNativeColor)
  {

   if( m_dispProps.ffFormat & kfDirect565 )
   {
    /* n% ALPHA */
    Color = *(unsigned short*)pDest;
    ColorR = (unsigned short)((Color >> 11) & 0x1f) * ( 1 - fAlpha );
    ColorG = (unsigned short)((Color >> 5) & 0x3f) * ( 1 - fAlpha );
    ColorB = (unsigned short)(Color & 0x1f) * ( 1 - fAlpha );
    Color = *(unsigned short*)pSrc;
    ColorR = (unsigned short)(((Color >> 11)&0x1f) * fAlpha + ColorR);
    ColorG = (unsigned short)(((Color >> 5)&0x3f) * fAlpha + ColorG);
    ColorB = (unsigned short)((Color & 0x1f)* fAlpha + ColorB);
    Color = (unsigned short)( ( ColorR & 0xff ) << 11 |
          ( ColorG & 0xff ) << 5 |
          ( ColorB & 0xff ) );
    *(unsigned short*)pDest = Color;
   }
   else if( m_dispProps.ffFormat & kfDirect555 )
   {
     /* n% ALPHA */
    Color = *(unsigned short*)pDest;
    ColorR = (unsigned short)((Color >> 10) & 0x1f) * ( 1 - fAlpha );
    ColorG = (unsigned short)((Color >> 5) & 0x1f) * ( 1 - fAlpha );
    ColorB = (unsigned short)(Color & 0x1f) * ( 1 - fAlpha );
    Color = *(unsigned short*)pSrc;
    ColorR = (unsigned short)(((Color >> 10)&0x1f) * fAlpha + ColorR);
    ColorG = (unsigned short)(((Color >> 5)&0x1f) * fAlpha + ColorG);
    ColorB = (unsigned short)((Color & 0x1f)* fAlpha + ColorB);
    Color = (unsigned short)( ( ColorR & 0xff ) << 10 |
          ( ColorG & 0xff ) << 5 |
          ( ColorB & 0xff ) );
    *(unsigned short*)pDest = Color;
   }
   else *(unsigned short*)pDest = Color;

  }

  pDest += m_nXPitch;
  pSrc++;
 }
 pDestLine += m_nYPitch;
 pSrcLine += pNativeBitmap->m_size.cx;