本文整理汇总了C#中System.Drawing.Imaging.ImageAttributes.SetOpacity方法的典型用法代码示例。如果您正苦于以下问题:C# ImageAttributes.SetOpacity方法的具体用法?C# ImageAttributes.SetOpacity怎么用?C# ImageAttributes.SetOpacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Imaging.ImageAttributes
的用法示例。
在下文中一共展示了ImageAttributes.SetOpacity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawSelection
/// <summary>
/// Dessine la selection du tileset si l'état du document est par défaut, sinon dessine l'effet de l'état courant du document
/// </summary>
/// <param name="state">L'état de dessin</param>
/// <param name="e">Les données de dessin</param>
private void DrawSelection(bool state, PaintEventArgs e)
{
if (state)
{
GameVector2 location = this.GetTilePosition(this.mouseLocation.X + this.mapOrigin.X, this.mouseLocation.Y + this.mapOrigin.Y);
if (this.State == GameEditorState.Default)
{
if (this.texture?.BitmapSelection != null)
{
ImageAttributes attributes = new ImageAttributes();
attributes.SetOpacity(0.5f);
/*************** Affichage uniquement à l'interieur de la carte *****************/
/*int limitX = this.texture.BitmapSelection.Width / GlobalData.TileSize.Width;
int limitY = this.texture.BitmapSelection.Height / GlobalData.TileSize.Height;
for (int x = 0; x < limitX; x++)
{
for (int y = 0; y < limitY; y++)
{
if (location.X + x >= 0 && location.X + x < GlobalData.MapSize.Width &&
location.Y + y >= 0 && location.Y + y < GlobalData.MapSize.Height)
{
e.Graphics.DrawImage(this.texture.BitmapSelection,
new Rectangle(
(location.X + x) * GlobalData.TileSize.Width - this.mapOrigin.X,
(location.Y + y) * GlobalData.TileSize.Height - this.mapOrigin.Y,
GlobalData.TileSize.Width,
GlobalData.TileSize.Height),
x * GlobalData.TileSize.Width,
y * GlobalData.TileSize.Height,
GlobalData.TileSize.Width,
GlobalData.TileSize.Height,
GraphicsUnit.Pixel,
attributes);
}
}
}*/
/*************** Affichage possible à l'exterieur de la carte *****************/
e.Graphics.DrawImage(this.texture.BitmapSelection,
new Rectangle(
location.X * GlobalData.TileSize.Width - this.mapOrigin.X,
location.Y * GlobalData.TileSize.Height - this.mapOrigin.Y,
this.texture.BitmapSelection.Width,
this.texture.BitmapSelection.Height),
0, 0,
this.texture.BitmapSelection.Width,
this.texture.BitmapSelection.Height,
GraphicsUnit.Pixel,
attributes);
}
}
else if (this.State == GameEditorState.Erase && GameMap.InBounds(location))
{
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(100, 255, 45, 45)),
location.X * GlobalData.TileSize.Width - this.mapOrigin.X,
location.Y * GlobalData.TileSize.Height - this.mapOrigin.Y,
GlobalData.TileSize.Width,
GlobalData.TileSize.Height);
}
}
}