CSharp examples for System.Drawing:Color
Apply alpha to color
// Copyright (C) Microsoft Corporation. All rights reserved. using System.Text; using System.Collections.Generic; using System;/*from w ww . j av a 2s.c o m*/ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; public class Main{ /// <summary> /// Apply alpha to color /// </summary> /// <param name="col">Color</param> /// <param name="newAlpha">New alpha</param> /// <returns>Color</returns> public static Color ApplyAlphaToColor(Color col, float newAlpha) { if (newAlpha < 0) newAlpha = 0; if (newAlpha > 1) newAlpha = 1; return new Color( (byte)(col.R), (byte)(col.G), (byte)(col.B), (byte)(newAlpha * 255.0f)); } }