当前位置: 首页>>代码示例>>C++>>正文


C++ CColor::GetAlpha方法代码示例

本文整理汇总了C++中CColor::GetAlpha方法的典型用法代码示例。如果您正苦于以下问题:C++ CColor::GetAlpha方法的具体用法?C++ CColor::GetAlpha怎么用?C++ CColor::GetAlpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CColor的用法示例。


在下文中一共展示了CColor::GetAlpha方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FillTextureWithColor

bool CTexture::FillTextureWithColor (unsigned int width, unsigned int height, const CColor& color)
{
  if (m_Texture==NULL)
  {
    LOGGER->AddNewLog(ELL_ERROR,"CTexture::FillTextureWithColor-> m_Texture no ha sido creado aun ");
    return false;
  }

  HRESULT hr;
  D3DLOCKED_RECT lock;
  hr=m_Texture->LockRect(0, &lock, NULL, D3DLOCK_DISCARD);
  if(hr==D3D_OK)
  {
    uint8 *pTxtBuffer; // Bitmap buffer, texture buffer
    pTxtBuffer = (uint8*)lock.pBits;

		
    uint32 j = 0;
    for( uint32 cont = 0; cont< width * height; cont++)
    {
      //BLUE
      pTxtBuffer[cont*4 + 0] = (uint8)(color.GetBlue()*255);
      //GREEN
      pTxtBuffer[cont*4 + 1] = (uint8)(color.GetGreen()*255);
      //RED
      pTxtBuffer[cont*4 + 2] = (uint8)(color.GetRed()*255);
      //ALPHA
      pTxtBuffer[cont*4 + 3] = (uint8)(color.GetAlpha()*255);
    }
    hr=m_Texture->UnlockRect(0);
  }
  else
  {
    LOGGER->AddNewLog(ELL_ERROR,"CTexture::FillTextureWithColor->Error en la llamada lockRect");
    return false;
  }

	m_Width	= width;
	m_Height	= height;

  return true;
}
开发者ID:BGCX261,项目名称:zombigame-svn-to-git,代码行数:42,代码来源:Texture.cpp

示例2: center

void DX9SpriteBatch::Draw(
	ITextureBase *Texture2D, CRectangle &PositionInTexture, 
	Vector2I &Origin, Vector2F &Position, 
	float Rotation, Vector2F &Scale, CColor &Color, 
	float ZOrder, eSpriteEffects SpriteEffect )
{
	CDX9Texture *tex = dynamic_cast<CDX9Texture *>(Texture2D);
	RECT src;
	src.left = PositionInTexture.Left();
	src.right = PositionInTexture.Right();
	src.top = PositionInTexture.Top();
	src.bottom = PositionInTexture.Bottom();
	D3DXVECTOR2 center(static_cast<float>(Origin.x), static_cast<float>(Origin.y));
	D3DXVECTOR2 pos(Position.x - Origin.x, Position.y - Origin.y);

	D3DXMATRIX transform;
	DXCheck(D3DXMatrixTransformation2D(&transform, NULL, NULL, &D3DXVECTOR2(Scale.x, Scale.y), &center, Rotation, &pos));

	if (SUCCEEDED(DXCheck(m_D3DSprite->SetTransform(&transform))))
	{
		DXCheck(m_D3DSprite->Draw( tex->GetDxTexture(), &src, NULL, NULL,
				D3DCOLOR_RGBA(Color.GetRed(), Color.GetGreen(), Color.GetBlue(), Color.GetAlpha()) ));
	}	
}
开发者ID:xcasadio,项目名称:casaengine,代码行数:24,代码来源:DX9SpriteBatch.cpp


注:本文中的CColor::GetAlpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。