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


C# ImageAttributes.SetOpacity方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:ClementDidier,项目名称:GameMapEditor,代码行数:69,代码来源:MapPanel.cs


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