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


C# Color.ToArgb方法代码示例

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


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

示例1: GetBytes

 public static byte[] GetBytes(Color color, ColorType type)
 {
     switch (type)
     {
         case ColorType.ARGB8888_32:
             return ByteConverter.GetBytes(color.ToArgb());
         case ColorType.XRGB8888_32:
             color = Color.FromArgb(0, color);
             goto case ColorType.ARGB8888_32;
         case ColorType.ARGB8888_16:
         {
             byte[] result = new byte[4];
             int i = color.ToArgb();
             ByteConverter.GetBytes((ushort)(i & 0xFFFF)).CopyTo(result, 0);
             ByteConverter.GetBytes((ushort)((i >> 16) & 0xFFFF)).CopyTo(result, 2);
             return result;
         }
         case ColorType.XRGB8888_16:
             color = Color.FromArgb(0, color);
             goto case ColorType.ARGB8888_16;
         case ColorType.ARGB4444:
             return ByteConverter.GetBytes((ushort)(((color.A >> 4) << 12) | ((color.R >> 4) << 8) | ((color.G >> 4) << 4) | (color.B >> 4)));
         case ColorType.RGB565:
             return ByteConverter.GetBytes((ushort)(((color.R >> 3) << 11) | ((color.G >> 2) << 5) | (color.B >> 3)));
     }
     throw new ArgumentOutOfRangeException("type");
 }
开发者ID:Radfordhound,项目名称:sa_tools,代码行数:27,代码来源:VColor.cs

示例2: boundaryfill4

        protected void boundaryfill4(int seedx, int seedy, Color fcolor, Color bcolor,Bitmap bitmap)
        {
            try
            {
                Queue<Point> pq = new Queue<Point>();
                Color color;
                Point p = new Point();
                Point pt = new Point();
                Point p1 = new Point();
                Point p2 = new Point();
                Point p3 = new Point();
                Point p4 = new Point();
                bitmap.SetPixel(seedx, seedy, fcolor);
                p.X = seedx;
                p.Y = seedy;
                pq.Enqueue(p);
                while (pq.Count > 0)
                {
                    pt = pq.Dequeue();
                    color = bitmap.GetPixel(pt.X, pt.Y - 1);
                    if (color.ToArgb() == bcolor.ToArgb() && color.ToArgb() != fcolor.ToArgb())
                    {
                        bitmap.SetPixel(pt.X, pt.Y - 1, fcolor);
                        p1.X = pt.X;
                        p1.Y = pt.Y - 1;
                        pq.Enqueue(p1);
                    }

                    color = bitmap.GetPixel(pt.X, pt.Y + 1);
                    if (color.ToArgb() == bcolor.ToArgb() && color.ToArgb() != fcolor.ToArgb())
                    {
                        bitmap.SetPixel(pt.X, pt.Y + 1, fcolor);
                        p2.X = pt.X;
                        p2.Y = pt.Y + 1;
                        pq.Enqueue(p2);
                    }

                    color = bitmap.GetPixel(pt.X - 1, pt.Y);
                    if (color.ToArgb() == bcolor.ToArgb() && color.ToArgb() != fcolor.ToArgb())
                    {
                        bitmap.SetPixel(pt.X - 1, pt.Y, fcolor);
                        p3.X = pt.X - 1;
                        p3.Y = pt.Y;
                        pq.Enqueue(p3);
                    }

                    color = bitmap.GetPixel(pt.X + 1, pt.Y);
                    if (color.ToArgb() == bcolor.ToArgb() && color.ToArgb() != fcolor.ToArgb())
                    {
                        bitmap.SetPixel(pt.X + 1, pt.Y, fcolor);
                        p4.X = pt.X + 1;
                        p4.Y = pt.Y;
                        pq.Enqueue(p4);
                    }

                }
            }
            catch { }
        }
开发者ID:huih1984,项目名称:oyjfscode,代码行数:59,代码来源:Fill.cs

示例3: CreateBoxes

        private static List<Rectangle> CreateBoxes(Bitmap image, Rectangle region, Color background)
        {
            List<Rectangle> boxes = new List<Rectangle>();
            Point presentPixel;
            Rectangle newBox;
            int x2 = 0;
            int y2 = 0;
            Color presentColour;

            for (int y = region.Top; y <= region.Bottom; y++)
            {

                for (int x = region.Left; x <= region.Right; x++)
                {
                    if (x > 0 && x < image.Width && y > 0 && y < image.Height)
                    {
                        presentPixel = new Point(x, y);

                        presentColour = image.GetPixel(x, y);

                        if (presentColour.ToArgb() != background.ToArgb())
                        {
                            newBox = new Rectangle(presentPixel, new Size(0, 0));
                            x2 = x;

                            while (x2 < (image.Width - 1) && image.GetPixel(x2, y).ToArgb() != background.ToArgb())
                            {
                                x2 += 1;
                                newBox = new Rectangle(newBox.X, newBox.Y, newBox.Width + 1, newBox.Height);
                            }

                            y2 = y;
                            while (y2 < (image.Height - 1) && image.GetPixel(x2, y2).ToArgb() != background.ToArgb())
                            {
                                y2 += 1;
                                newBox = new Rectangle(newBox.X, newBox.Y, newBox.Width, newBox.Height + 1);
                            }

                            y2 = y + newBox.Height;
                            while (y2 < (image.Height - 1) && image.GetPixel(x, y2).ToArgb() != background.ToArgb())
                            {
                                y2 += 1;
                                newBox = new Rectangle(newBox.X, newBox.Y, newBox.Width, newBox.Height + 1);
                            }

                            boxes.Add(newBox);

                            x += (newBox.Width + 1);
                        }
                    }
                }
            }

            return boxes;
        }
开发者ID:rlugojr,项目名称:Alferd-Spritesheet-Unpacker,代码行数:55,代码来源:RegionUnpacker.cs

示例4: DrawLine

        private void DrawLine(Vector3 from, Vector3 to, Color color)
        {
            var vertices = new List<PositionColored>();

            vertices.Add(new PositionColored(from, color.ToArgb()));
            vertices.Add(new PositionColored(to, color.ToArgb()));

            var buffer = vertices.ToArray();

            SetTarget(Vector3.Zero);

            D3D.Device.DrawUserPrimitives(PrimitiveType.LineStrip, vertices.Count - 1, buffer);
        }
开发者ID:TyrelBaux,项目名称:IceFlake,代码行数:13,代码来源:DebugScript.cs

示例5: GetSolidBrush

 public Brush GetSolidBrush(Color c)
 {
     Brush br;
     if (_solidBrushes.TryGetValue(c.ToArgb(), out br))
     {
         return br;
     }
     else
     {
         br = new SolidBrush(c);
         _solidBrushes.Add(c.ToArgb(), br);
         return br;
     }
 }
开发者ID:charreal,项目名称:jsparser,代码行数:14,代码来源:Palette.cs

示例6: FullScreenPixelSearch

 /// <summary>
 /// Search for a given color within all the client area of BS. Faster then PixelSearch, as it doesn't do a new capture each time. 
 /// </summary>
 /// <param name="left"></param>
 /// <param name="top"></param>
 /// <param name="right"></param>
 /// <param name="bottom"></param>
 /// <param name="color1"></param>
 /// <param name="variation"></param>
 /// <returns></returns>
 public static Point FullScreenPixelSearch(Color color1, int variation, bool forceCapture = false)
 {
     if (!TakeFullScreenCapture(forceCapture)) return Point.Empty;
     int nbMatchMin = 1, xRef = 0, yRef = 0;
     if (FastFindWrapper.GenericColorSearch(1, ref nbMatchMin, ref xRef, ref yRef, color1.ToArgb(), variation, DEFAULT_SNAP) == 0 || nbMatchMin == 0) return Point.Empty;
     return new Point(xRef, yRef);
 }
开发者ID:hasantemel,项目名称:Coc-bot-Csharp,代码行数:17,代码来源:FastFindHelper.cs

示例7: ClearColorInSheet

        private void ClearColorInSheet(Color color)
        {
            if (this.currentSpriteSheet != null)
            {

                int c = color.ToArgb();

                this.currentSpriteSheet.MakeTransparent(color);

                //for (int x = 0; x < this.currentSpriteSheet.Width; x++)
                //{
                //    for (int y = 0; y < this.currentSpriteSheet.Height; y++)
                //    {
                //        if (c.Equals(this.currentSpriteSheet.GetPixel(x, y).ToArgb()))
                //        {
                //            this.currentSpriteSheet.SetPixel(x, y, Color.Transparent);

                //            Color color2 = this.currentSpriteSheet.GetPixel(x, y);
                //        }
                //    }
                //}

                this.sheetPictBx.Refresh();
            }
        }
开发者ID:nadar71,项目名称:Krea,代码行数:25,代码来源:SpriteSheetSplitter.cs

示例8: sColor

 public sColor(int alpha, Color value)
 {
     pName = value.Name;
     pValue = (uint)value.ToArgb();
     pColorAlpha = Color.FromArgb(255 - alpha, value);
     pColor = value;
 }
开发者ID:Koloss78,项目名称:e2skinner2,代码行数:7,代码来源:sColor.cs

示例9: ReturnColor

        public static void ReturnColor(Color c)
        {
            int colorValue = c.ToArgb();

              if( _unusedColors.IndexOf(colorValue) == -1 )
            _unusedColors.Add(colorValue);
        }
开发者ID:jrgcubano,项目名称:ServiceBusMQManager,代码行数:7,代码来源:QueueColorManager.cs

示例10: ColorRange

        public ColorRange(Color c, int threshold)
        {
            int argb = c.ToArgb();

            from = Color.FromArgb(Math.Max(c.R - threshold, 0), Math.Max(c.G - threshold, 0), Math.Max(c.B - threshold, 0)).ToArgb();
            to = Color.FromArgb(Math.Min(c.R + threshold, 255), Math.Min(c.G + threshold, 255), Math.Min(c.B + threshold, 255)).ToArgb();
        }
开发者ID:alexhanh,项目名称:Botting-Library,代码行数:7,代码来源:ColorRange.cs

示例11: DrawCircle

        public static unsafe void DrawCircle(Location center, float radius, Color innerColor, Color outerColor, int complexity = 24, bool isFilled = true)
        {
            var vertices = new List<PositionColored>();

            if (isFilled)
                vertices.Add(new PositionColored(Vector3.Zero, innerColor.ToArgb()));

            double stepAngle = (Math.PI * 2) / complexity;
            for (int i = 0; i <= complexity; i++)
            {
                double angle = (Math.PI * 2) - (i * stepAngle);
                float x = (float)(radius * Math.Cos(angle));
                float y = (float)(-radius * Math.Sin(angle));
                vertices.Add(new PositionColored(new Vector3(x, y, 0), outerColor.ToArgb()));
            }

            var buffer = vertices.ToArray();

            InternalRender(center.ToVector3() + new Vector3(0, 0, 0.3f));

            if (isFilled)
                Device.DrawUserPrimitives(PrimitiveType.TriangleFan, buffer.Length - 2, buffer);
            else
                Device.DrawUserPrimitives(PrimitiveType.LineStrip, buffer.Length - 1, buffer);
        }
开发者ID:Vipeax,项目名称:cleanLayer,代码行数:25,代码来源:Rendering.cs

示例12: DrawColoredRectangle

 public static void DrawColoredRectangle(Device dev,RectangleF rect,Color color)
 {
     VertexBuffer vb=null;
     IndexBuffer ib=null;
     try{
         int colorArgb=color.ToArgb();
         CustomVertex.PositionColored[] quadVerts=new CustomVertex.PositionColored[] {
                 new CustomVertex.PositionColored(rect.Left,rect.Bottom,0,colorArgb),
                 new CustomVertex.PositionColored(rect.Left,rect.Top,0,colorArgb),
                 new CustomVertex.PositionColored(rect.Right,rect.Top,0,colorArgb),
                 new CustomVertex.PositionColored(rect.Right,rect.Bottom,0,colorArgb),
             };
         vb=new VertexBuffer(typeof(CustomVertex.PositionColored),
             CustomVertex.PositionColored.StrideSize*quadVerts.Length,
             dev,Usage.WriteOnly,CustomVertex.PositionColored.Format,Pool.Managed);
         vb.SetData(quadVerts,0,LockFlags.None);
         int[] indicies=new int[] { 0,1,2,0,2,3 };
         ib=new IndexBuffer(typeof(int),indicies.Length,dev,Usage.None,Pool.Managed);
         ib.SetData(indicies,0,LockFlags.None);
         dev.VertexFormat=CustomVertex.PositionColored.Format;
         dev.SetStreamSource(0,vb,0);
         dev.Indices=ib;
         dev.DrawIndexedPrimitives(PrimitiveType.TriangleList,0,0,quadVerts.Length,0,indicies.Length/3);
     }finally{
         if(vb!=null){
             vb.Dispose();
             vb=null;
         }
         if(ib!=null){
             ib.Dispose();
             ib=null;
         }
     }
 }
开发者ID:nampn,项目名称:ODental,代码行数:34,代码来源:ToothChartDirectX.cs

示例13: Circle

        public static void Circle(BitmapData bmpData, int Size, int X, int Y, Color Colour)
        {
            CacheCircles(Size);

            int tempX;
            int i = 0;
            for (int tempY = Y - Size; tempY < Y + Size; tempY++)
            {
                if (tempY >= 0)
                {
                    if (tempY >= bmpData.Height)
                    {
                        break;
                    }
                    tempX = X - CircleCache[Size][i];
                    while (tempX < CircleCache[Size][i] + X)
                    {
                        if (tempX >= 0)
                        {
                            if (tempX >= bmpData.Width)
                            {
                                break;
                            }
                            IntPtr temp = FindPtr(bmpData, tempX, tempY);
                            System.Runtime.InteropServices.Marshal.WriteInt32(temp, Colour.ToArgb());
                        }

                      tempX++;
                    }
                }
                i++;
            }
        }
开发者ID:RichTeaMan,项目名称:EcoSim,代码行数:33,代码来源:Draw.cs

示例14: Engine_Picture

 public Engine_Picture(string fileName, Color colorKey)
 {
     ImageInformation imageInformation = TextureLoader.ImageInformationFromFile(Engine_Game.PicturesPath + fileName);
     m_Width = imageInformation.Width;
     m_Height = imageInformation.Height;
     m_Texture = TextureLoader.FromFile(Engine_Game.Device, Engine_Game.PicturesPath + fileName, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, colorKey.ToArgb());
 }
开发者ID:unk1nd,项目名称:US_AirForce,代码行数:7,代码来源:engine_picture.cs

示例15: XLColor

 internal XLColor(Color color)
 {
     _color = color;
     _hashCode = 13 ^ color.ToArgb();
     HasValue = true;
     _colorType = XLColorType.Color;
 }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:7,代码来源:XLColor_Internal.cs


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