2009-12-28 16 views
1

je dois montrer la texture de l'image à la forme arrondie, mon code comme suivreà clipser la texture en forme arrondie

texture = Texture.FromBitmap(device,myBitmap, Usage.RenderTarget, Pool.Default); 

_sprite.Begin (SpriteFlags.SortTexture | SpriteFlags.DoNotModifyRenderState); _sprite.Draw (_allocator.Texture, Vector3.Empty, nouveau Vector3 (_objectLocation.X, _objectLocation.Y, 0), RenderingColor); _sprite.End();

Mais il montre toujours la texture rectangle, comment couper cette texture en arrondi.

Répondre

1

Utilisez le canal alpha de la texture (255 est opaque, 0 est transparent et tout ce qui se trouve entre les 2) et définissez alpha blending et alpha test pour ne pas dessiner les pixels transparents. Éditer: (Essayez ces paramètres alpha une fois que vous avez configuré votre texture à 4 canaux).

ALPHABLENDENABLE = TRUE 
SRCBLEND = SRCALPHA 
DESTBLEND = INVSRCALPHA 

ALPHATESTENABLE = TRUE 
ALPHAREF = 192 
ALPHAFUNC = GREATER