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


C# ImageAttributes.ClearColorKey方法代码示例

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


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

示例1: CreateDisabledImage

 /// <summary>
 /// Creates the disabled image for the specified Image
 /// </summary>
 /// <param name="normalImage"></param>
 /// <returns></returns>
 public static Image CreateDisabledImage(Image normalImage)
 {
     var imageAttr = new ImageAttributes();
     imageAttr.ClearColorKey();
     imageAttr.SetColorMatrix(DisabledImageColorMatrix);
     var size = normalImage.Size;
     var image = new Bitmap(size.Width, size.Height);
     var graphics = Graphics.FromImage(image);
     graphics.DrawImage(normalImage, new Rectangle(0, 0, size.Width, size.Height), 0, 0, size.Width, size.Height, GraphicsUnit.Pixel, imageAttr);
     graphics.Dispose();
     return image;
 }
开发者ID:AlexGaidukov,项目名称:gipertest_streaming,代码行数:17,代码来源:RibbonRenderer.cs

示例2: GetDesaturatedImageAttributes

		/*
		 * GetDesaturatedImageAttributes
		 */

		/// <summary>
		/// </summary>
		/// <returns></returns>
		public static ImageAttributes GetDesaturatedImageAttributes()
		{
			float[][] matrixComponents = new float[5][];
			matrixComponents[0] = new float[] { 0.2125f, 0.2125f, 0.2125f, 0f, 0f };
			matrixComponents[1] = new float[] { 0.2577f, 0.2577f, 0.2577f, 0f, 0f };
			matrixComponents[2] = new float[] { 0.0361f, 0.0361f, 0.0361f, 0f, 0f };
			
			float[] transformComponents = new float[5];
			transformComponents[3] = 1f;
			matrixComponents[3] = transformComponents;
			matrixComponents[4] = new float[] { 0.38f, 0.38f, 0.38f, 0f, 1f };
			
			ImageAttributes imageAttributes = new ImageAttributes();
			imageAttributes.ClearColorKey();
			imageAttributes.SetColorMatrix(new ColorMatrix(matrixComponents));

			return imageAttributes;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:25,代码来源:NuGenControlPaint.Color.cs

示例3: GetDisabledImage

        public static Image GetDisabledImage(Image originalBitmap)
        {
            var disabledBitmap = new Bitmap(originalBitmap.Width, originalBitmap.Height);
            var g = Graphics.FromImage(disabledBitmap);

            // We create a color matrix to generated the disabled look
            var array = new float[5][];
            array[0] = new float[] { 0.2125f, 0.2125f, 0.2125f, 0, 0 };
            array[1] = new float[] { 0.2577f, 0.2577f, 0.2577f, 0, 0 };
            array[2] = new float[] { 0.0361f, 0.0361f, 0.0361f, 0, 0 };
            array[3] = new float[] { 0, 0, 0, 1, 0 };
            array[4] = new float[] { 0.38f, 0.38f, 0.38f, 0, 1 };
            var grayMatrix = new ColorMatrix(array);
            var disabledImageAttr = new ImageAttributes();
            disabledImageAttr.ClearColorKey();
            disabledImageAttr.SetColorMatrix(grayMatrix);

            // We draw the image using the color matrix
            var rectImage = new Rectangle(0, 0, originalBitmap.Width, originalBitmap.Height);
            g.DrawImage(originalBitmap, rectImage, 0, 0, originalBitmap.Width, originalBitmap.Height, GraphicsUnit.Pixel, disabledImageAttr);
            g.Dispose();

            return disabledBitmap;
        }
开发者ID:sat1582,项目名称:CODEFramework,代码行数:24,代码来源:ImageHelper.cs

示例4: DrawImageDisabled

 internal static void DrawImageDisabled(Graphics graphics, Image image, Rectangle imageBounds, Color background, bool unscaledImage)
 {
     if (graphics == null)
     {
         throw new ArgumentNullException("graphics");
     }
     if (image == null)
     {
         throw new ArgumentNullException("image");
     }
     Size size = image.Size;
     if (disabledImageAttr == null)
     {
         float[][] newColorMatrix = new float[5][];
         newColorMatrix[0] = new float[] { 0.2125f, 0.2125f, 0.2125f, 0f, 0f };
         newColorMatrix[1] = new float[] { 0.2577f, 0.2577f, 0.2577f, 0f, 0f };
         newColorMatrix[2] = new float[] { 0.0361f, 0.0361f, 0.0361f, 0f, 0f };
         float[] numArray2 = new float[5];
         numArray2[3] = 1f;
         newColorMatrix[3] = numArray2;
         newColorMatrix[4] = new float[] { 0.38f, 0.38f, 0.38f, 0f, 1f };
         ColorMatrix matrix = new ColorMatrix(newColorMatrix);
         disabledImageAttr = new ImageAttributes();
         disabledImageAttr.ClearColorKey();
         disabledImageAttr.SetColorMatrix(matrix);
     }
     if (unscaledImage)
     {
         using (Bitmap bitmap = new Bitmap(image.Width, image.Height))
         {
             using (Graphics graphics2 = Graphics.FromImage(bitmap))
             {
                 graphics2.DrawImage(image, new Rectangle(0, 0, size.Width, size.Height), 0, 0, size.Width, size.Height, GraphicsUnit.Pixel, disabledImageAttr);
             }
             graphics.DrawImageUnscaled(bitmap, imageBounds);
             return;
         }
     }
     graphics.DrawImage(image, imageBounds, 0, 0, size.Width, size.Height, GraphicsUnit.Pixel, disabledImageAttr);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:40,代码来源:ControlPaint.cs

示例5: CreateDisabledImage

       /// <include file='doc\ToolStripRenderer.uex' path='docs/doc[@for="ToolStripRenderer.CreateDisabledImage"]/*' />
       public static Image CreateDisabledImage(Image normalImage) {
           ImageAttributes imgAttrib = new ImageAttributes();
           imgAttrib.ClearColorKey();
           imgAttrib.SetColorMatrix(DisabledImageColorMatrix);
 
           Size size = normalImage.Size;
           Bitmap disabledBitmap = new Bitmap(size.Width, size.Height);
           Graphics graphics = Graphics.FromImage(disabledBitmap);
 
           graphics.DrawImage(normalImage, 
                              new Rectangle(0, 0, size.Width, size.Height), 
                              0, 0, size.Width, size.Height,
                              GraphicsUnit.Pixel, 
                              imgAttrib);
           graphics.Dispose();
 
           return disabledBitmap;
       }
开发者ID:JianwenSun,项目名称:cc,代码行数:19,代码来源:ToolStripRenderer.cs

示例6: DrawAlphaImage

 private void DrawAlphaImage(Image alphaImage, Image image, float percent)
 {
     float[][] newColorMatrix = new float[5][];
     newColorMatrix[0] = new float[] { 1, 0, 0, 0, 0 };
     newColorMatrix[1] = new float[] { 0, 1, 0, 0, 0 };
     newColorMatrix[2] = new float[] { 0, 0, 1, 0, 0 };
     newColorMatrix[3] = new float[] { 0, 0, 0, percent, 0 };
     newColorMatrix[4] = new float[] { 0, 0, 0, 0, 1 };
     ColorMatrix matrix = new ColorMatrix(newColorMatrix);
     ImageAttributes imageAttributes = new ImageAttributes();
     imageAttributes.ClearColorKey();
     imageAttributes.SetColorMatrix(matrix);
     using (Graphics gr = Graphics.FromImage(alphaImage))
     {
         gr.DrawImage(image, new Rectangle(0, 0, Size.Width, Size.Height), 0, 0, Size.Width, Size.Height, GraphicsUnit.Pixel, imageAttributes);
     }
 }
开发者ID:xieguigang,项目名称:Reference_SharedLib,代码行数:17,代码来源:CommandLink.cs

示例7: DrawForegroundFromButton

 private void DrawForegroundFromButton(PaintEventArgs pevent)
 {
     if (_imageButton == null)
     {
         _imageButton = new Button();
         _imageButton.Parent = new TransparentControl();
         _imageButton.SuspendLayout();
         _imageButton.BackColor = Color.Transparent;
         _imageButton.FlatAppearance.BorderSize = 0;
         _imageButton.FlatStyle = FlatStyle.Flat;
     }
     else
     {
         _imageButton.SuspendLayout();
     }
     _imageButton.AutoEllipsis = AutoEllipsis;
     if (Enabled)
     {
         _imageButton.ForeColor = ForeColor;
     }
     else
     {
         _imageButton.ForeColor = Color.FromArgb((3*ForeColor.R + _backColor.R) >> 2,
                                                 (3*ForeColor.G + _backColor.G) >> 2,
                                                 (3*ForeColor.B + _backColor.B) >> 2);
     }
     _imageButton.Font = Font;
     _imageButton.RightToLeft = RightToLeft;
     _imageButton.Image = Image;
     if (Image != null && !Enabled)
     {
         Size size = Image.Size;
         var newColorMatrix = new float[5][];
         newColorMatrix[0] = new[] {0.2125f, 0.2125f, 0.2125f, 0f, 0f};
         newColorMatrix[1] = new[] {0.2577f, 0.2577f, 0.2577f, 0f, 0f};
         newColorMatrix[2] = new[] {0.0361f, 0.0361f, 0.0361f, 0f, 0f};
         var arr = new float[5];
         arr[3] = 1f;
         newColorMatrix[3] = arr;
         newColorMatrix[4] = new[] {0.38f, 0.38f, 0.38f, 0f, 1f};
         var matrix = new ColorMatrix(newColorMatrix);
         var disabledImageAttr = new ImageAttributes();
         disabledImageAttr.ClearColorKey();
         disabledImageAttr.SetColorMatrix(matrix);
         _imageButton.Image = new Bitmap(Image.Width, Image.Height);
         using (Graphics gr = Graphics.FromImage(_imageButton.Image))
         {
             gr.DrawImage(Image, new Rectangle(0, 0, size.Width, size.Height), 0, 0, size.Width, size.Height,
                          GraphicsUnit.Pixel, disabledImageAttr);
         }
     }
     _imageButton.ImageAlign = ImageAlign;
     _imageButton.ImageIndex = ImageIndex;
     _imageButton.ImageKey = ImageKey;
     _imageButton.ImageList = ImageList;
     _imageButton.Padding = Padding;
     _imageButton.Size = Size;
     _imageButton.Text = Text;
     _imageButton.TextAlign = TextAlign;
     _imageButton.TextImageRelation = TextImageRelation;
     _imageButton.UseCompatibleTextRendering = UseCompatibleTextRendering;
     _imageButton.UseMnemonic = UseMnemonic;
     _imageButton.ResumeLayout();
     InvokePaint(_imageButton, pevent);
     if (_imageButton.Image != null && _imageButton.Image != Image)
     {
         _imageButton.Image.Dispose();
         _imageButton.Image = null;
     }
 }
开发者ID:Slashmolder,项目名称:RNGReporter,代码行数:70,代码来源:GlassButton.cs

示例8: DrawImageDisabled

        internal static void DrawImageDisabled(Graphics graphics, Image image, Rectangle imageBounds, Color background, bool unscaledImage) {
            if (graphics == null) {
                throw new ArgumentNullException("graphics");
            }
            if (image == null) {
                throw new ArgumentNullException("image");
            }
#if GRAYSCALE_DISABLED
            Size imageSize = image.Size;

            if (disabledImageAttr == null) {
                // This is how I came up with this somewhat random ColorMatrix.
                // Its set to resemble Office10 commandbars, but still be able to
                // deal with hi-color (256+) icons and images.
                //
                // The idea is to scale everything down (more than just a grayscale does,
                // therefore the small numbers in the scaling part of matrix)
                // White -> some shade of gray &
                // Black -> Black
                //
                // Second part of the matrix is to translate everything, so all colors are
                // a bit brigher.
                // Grays become lighter and washed out looking
                // Black becomes a shade of gray as well.
                //
                // btw, if you do come up with something better let me know - [....]
                
                float[][] array = new float[5][];
                    array[0] = new float[5] {0.2125f, 0.2125f, 0.2125f, 0, 0};
                array[1] = new float[5] {0.2577f, 0.2577f, 0.2577f, 0, 0};
                array[2] = new float[5] {0.0361f, 0.0361f, 0.0361f, 0, 0};
                array[3] = new float[5] {0,       0,       0,       1, 0};
                array[4] = new float[5] {0.38f,   0.38f,   0.38f,   0, 1};

                ColorMatrix grayMatrix = new ColorMatrix(array);

                disabledImageAttr = new ImageAttributes();
                disabledImageAttr.ClearColorKey();
                disabledImageAttr.SetColorMatrix(grayMatrix);
            }


            if (unscaledImage) {
                using (Bitmap bmp = new Bitmap(image.Width, image.Height)) {
                    using (Graphics g = Graphics.FromImage(bmp)) {
                        g.DrawImage(image, 
                                   new Rectangle(0, 0, imageSize.Width, imageSize.Height),
                                   0, 0, imageSize.Width, imageSize.Height,
                                   GraphicsUnit.Pixel, 
                                   disabledImageAttr);
                    }
                    graphics.DrawImageUnscaled(bmp, imageBounds);
                }
            }
            else {
                graphics.DrawImage(image, 
                                   imageBounds, 
                                   0, 0, imageSize.Width, imageSize.Height,
                                   GraphicsUnit.Pixel, 
                                   disabledImageAttr);
            }
#else


            // This is remarkably simple -- make a monochrome version of the image, draw once
            // with the button highlight color, then a second time offset by one pixel
            // and in the button shadow color.
            // Technique borrowed from comctl Toolbar.

            Bitmap bitmap;
            bool disposeBitmap = false;
            if (image is Bitmap)
                bitmap = (Bitmap) image;
            else {
                // #37659 -- metafiles can have extremely high resolutions,
                // so if we naively turn them into bitmaps, the performance will be very poor.
                // bitmap = new Bitmap(image);

                GraphicsUnit units = GraphicsUnit.Display;
                RectangleF bounds = image.GetBounds(ref units);
                bitmap = new Bitmap((int) (bounds.Width * graphics.DpiX / image.HorizontalResolution),
                                    (int) (bounds.Height * graphics.DpiY / image.VerticalResolution));

                Graphics bitmapGraphics = Graphics.FromImage(bitmap);
                bitmapGraphics.Clear(Color.Transparent);
                bitmapGraphics.DrawImage(image, 0, 0, image.Size.Width, image.Size.Height);
                bitmapGraphics.Dispose();

                disposeBitmap = true;
            }
            
            Color highlight = ControlPaint.LightLight(background);
            Bitmap monochrome = MakeMonochrome(bitmap, highlight);
            graphics.DrawImage(monochrome, new Rectangle(imageBounds.X + 1, imageBounds.Y + 1, imageBounds.Width, imageBounds.Height));
            monochrome.Dispose();

            Color shadow = ControlPaint.Dark(background);
            monochrome = MakeMonochrome(bitmap, shadow);
            graphics.DrawImage(monochrome, imageBounds);
            monochrome.Dispose();
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:ControlPaint.cs

示例9: ImageMap

        //=====================================================================

        /// <summary>
        /// Default constructor
        /// </summary>
        public ImageMap()
		{
            // Set the value of the double-buffering style bits to true
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint |
                ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
            this.UpdateStyles();

			InitializeComponent();

			gPanel = Graphics.FromHwnd(this.Handle);

            activeArea = mouseArea = -1;
            areaCursor = Cursors.Hand;
            nonAreaCursor = Cursors.Default;
            centerImage = true;
			pathData = new GraphicsPath();

            // Create the disabled image attributes on first use
            if(iaDisabled == null)
            {
                float[][] afColorMatrix = new float[5][];

                afColorMatrix[0] = new float[5] { 0.2125f, 0.2125f, 0.2125f, 0f, 0f };
                afColorMatrix[1] = new float[5] { 0.2577f, 0.2577f, 0.2577f, 0f, 0f };
                afColorMatrix[2] = new float[5] { 0.0361f, 0.0361f, 0.0361f, 0f, 0f };
                afColorMatrix[3] = new float[5] { 0f, 0f, 0f, 1f, 0f };
                afColorMatrix[4] = new float[5] { 0.38f, 0.38f, 0.38f, 0f, 1f};

                iaDisabled = new ImageAttributes();
                iaDisabled.ClearColorKey();
                iaDisabled.SetColorMatrix(new ColorMatrix(afColorMatrix));
            }
		}
开发者ID:exaphaser,项目名称:ImageMaps,代码行数:38,代码来源:ImageMap.cs


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