• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ColorFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ColorFormat的典型用法代码示例。如果您正苦于以下问题:C# ColorFormat类的具体用法?C# ColorFormat怎么用?C# ColorFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ColorFormat类属于命名空间,在下文中一共展示了ColorFormat类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestParameterSerialization

 public void TestParameterSerialization()
 {
     var decoder = new PackedDecoder();
     var p = new List<Parameter>();
     decoder.WriteParameters(p);
     Assert.AreNotEqual(0, p.Count);
     var c1 = p.Count;
     decoder.WriteParameters(p);
     Assert.AreEqual(c1, p.Count);
     decoder.ColorBPP = 4;
     var cf = new ColorFormat(12, 5, 6, 4, 1, 3, 18, 1);
     decoder.ColorFormat = cf;
     ((IPictureDecoderController)decoder).Width = 13;
     ((IPictureDecoderController)decoder).Height = 21;
     decoder.WriteParameters(p);
     Assert.AreEqual(1.ToString(), p.First(z => z.Name == "ppbyp").Value);
     Assert.AreEqual(cf.ToString(), p.First(z => z.Name == "ColorFormat").Value);
     Assert.AreEqual("13", p.First(z => z.Name == "Width").Value);
     Assert.AreEqual("21", p.First(z => z.Name == "Height").Value);
     var d2 = new PackedDecoder();
     d2.ReadParameters(p);
     Assert.AreEqual(4, d2.ColorBPP);
     Assert.AreEqual(cf, d2.ColorFormat);
     Assert.AreEqual(13, ((IPictureDecoderController)decoder).Width);
     Assert.AreEqual(21, ((IPictureDecoderController)decoder).Height);
 }
开发者ID:kael-ip,项目名称:rippix,代码行数:26,代码来源:PackedDecoder.cs


示例2: SelectGraphicsMode

 public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
 {
     GraphicsMode gfx = new GraphicsMode((IntPtr)1, color, depth, stencil, samples,
                                          accum, buffers, stereo);
     System.Diagnostics.Debug.Print("Created dummy graphics mode.");
     return gfx;
 }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:7,代码来源:MacOSGraphicsMode.cs


示例3: RawImage

 public RawImage(byte[] tiles, TileForm form, ColorFormat format, int width, int height,
     bool editable, string fileName = "")
     : base()
 {
     this.fileName = fileName;
     Set_Tiles(tiles, width, height, format, form, editable);
 }
开发者ID:ShadeDBZ,项目名称:tinke,代码行数:7,代码来源:RawData.cs


示例4: LessEngine

 public LessEngine(Parser.Parser parser, ILogger logger, bool compress, ColorFormat colorFormat)
 {
     Parser = parser;
     Logger = logger;
     Compress = compress;
         ColorFormat = colorFormat;
 }
开发者ID:ayoung,项目名称:dotless,代码行数:7,代码来源:LessEngine.cs


示例5: TextureCubeArray

		/// <summary>
		/// 
		/// </summary>
		/// <param name="device"></param>
		/// <param name="size"></param>
		/// <param name="count"></param>
		/// <param name="format"></param>
		/// <param name="mips"></param>
		public TextureCubeArray ( GraphicsDevice device, int size, int count, ColorFormat format, bool mips ) : base(device)
		{
			if (count>2048/6) {
				throw new GraphicsException("Too much elements in texture array");
			}

			this.Width		=	size;
			this.Depth		=	1;
			this.Height		=	size;
			this.MipCount	=	mips ? ShaderResource.CalculateMipLevels(Width,Height) : 1;

			var texDesc = new Texture2DDescription();

			texDesc.ArraySize		=	6 * count;
			texDesc.BindFlags		=	BindFlags.ShaderResource;
			texDesc.CpuAccessFlags	=	CpuAccessFlags.None;
			texDesc.Format			=	MakeTypeless( Converter.Convert( format ) );
			texDesc.Height			=	Height;
			texDesc.MipLevels		=	0;
			texDesc.OptionFlags		=	ResourceOptionFlags.TextureCube;
			texDesc.SampleDescription.Count	=	1;
			texDesc.SampleDescription.Quality	=	0;
			texDesc.Usage			=	ResourceUsage.Default;
			texDesc.Width			=	Width;


			texCubeArray	=	new D3D.Texture2D( device.Device, texDesc );
			SRV				=	new ShaderResourceView( device.Device, texCubeArray );
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:37,代码来源:TextureCubeArray.cs


示例6: VolumeRWTexture

		/// <summary>
		/// Creates texture
		/// </summary>
		/// <param name="device"></param>
		public VolumeRWTexture ( GraphicsDevice device, int width, int height, int depth, ColorFormat format, bool mips ) : base( device )
		{
			this.Width		=	width;
			this.Height		=	height;
			this.Depth		=	depth;
			this.format		=	format;
			this.mipCount	=	mips ? ShaderResource.CalculateMipLevels(Width,Height,Depth) : 1;

			var texDesc = new Texture3DDescription();
			texDesc.BindFlags		=	BindFlags.ShaderResource | BindFlags.UnorderedAccess;
			texDesc.CpuAccessFlags	=	CpuAccessFlags.None;
			texDesc.Format			=	Converter.Convert( format );
			texDesc.Height			=	Height;
			texDesc.MipLevels		=	mipCount;
			texDesc.OptionFlags		=	ResourceOptionFlags.None;
			texDesc.Usage			=	ResourceUsage.Default;
			texDesc.Width			=	Width;
			texDesc.Depth			=	Depth;

			var uavDesc = new UnorderedAccessViewDescription();
			uavDesc.Format		=	Converter.Convert( format );
			uavDesc.Dimension	=	UnorderedAccessViewDimension.Texture3D;
			uavDesc.Texture3D.FirstWSlice	=	0;
			uavDesc.Texture3D.MipSlice		=	0;
			uavDesc.Texture3D.WSize			=	depth;

			tex3D	=	new D3D.Texture3D( device.Device, texDesc );
			SRV		=	new D3D.ShaderResourceView( device.Device, tex3D );
			uav		=	new UnorderedAccessView( device.Device, tex3D, uavDesc );
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:34,代码来源:VolumeRWTexture.cs


示例7: Image

 public Image()
 {
     this.data     = null;
     this.original = null;
     this.format   = ColorFormat.Unknown;
     this.pixelEnc = PixelEncoding.Unknown;
     this.tileSize = new Size(8, 8);
     this.width    = 0;
     this.height   = 0;
 }
开发者ID:pleonex,项目名称:ninoimager,代码行数:10,代码来源:Image.cs


示例8: Color

        /// <summary>
        /// Return a Random color.
        /// </summary>
        /// <param name="format"></param>
        /// <param name="casing"></param>
        /// <param name="grayscale"></param>
        /// <example>
        ///   <code language="cs">
        ///     // this will return a string. (ex. "rgba(128, 255, 128, 0.5)")
        ///     var color = _random.Color(ColorFormat.Rgba);
        ///   </code>
        /// </example>
        /// <returns></returns>
        public string Color(ColorFormat format, CasingType casing = CasingType.Lower, bool grayscale = true)
        {
            var colorValue = "";
              switch (format)
              {
            case ColorFormat.Hex:
              colorValue = string.Format("#{0}", grayscale ? Gray(Hash(2)) : Hash(6));
              break;
            case ColorFormat.ShortHex:
              colorValue = string.Format("#{0}", grayscale ? Gray(Hash(1)) : Hash(3));
              break;
            case ColorFormat.Rgb:
              if (grayscale)
              {
            var rgb = Gray(Natural(max: 255).ToString(), ",");
            colorValue = string.Format("rgb({0})", rgb);
              }
              else
              {
            var r = Natural(255);
            var g = Natural(255);
            var b = Natural(255);
            colorValue = string.Format("rgb({0}, {1}, {2})", r, g, b);
              }
              break;
            case ColorFormat.Rgba:
              if (grayscale)
              {
            var rgb = Gray(Natural(max: 255).ToString(), ",");
            var alpha = Float(0, 1);
            colorValue = string.Format("rgba({0}, {1})", rgb, alpha);
              }
              else
              {
            var r = Natural(255);
            var g = Natural(255);
            var b = Natural(255);
            var alpha = Float(0, 1);
            colorValue = string.Format("rgba({0}, {1}, {2}, {3})", r, g, b, alpha);
              }
              break;
            case ColorFormat.ConstantHex:
              colorValue = string.Format("0x{0}", grayscale ? Gray(Hash(2)) : Hash(6));
              break;
            default:
              colorValue = string.Empty;
              break;
              }

              if (casing == CasingType.Upper)
            colorValue = colorValue.ToUpper();

              return colorValue;
        }
开发者ID:NotYours180,项目名称:Fluky,代码行数:67,代码来源:Randomizer.Web.cs


示例9: RenderTargetSurface

 /// <summary>
 /// 
 /// </summary>
 /// <param name="rtv"></param>
 internal RenderTargetSurface( RenderTargetView rtv, UnorderedAccessView uav, Resource resource, int subresource, ColorFormat format, int width, int height, int sampleCount )
 {
     Width			=	width;
     Height			=	height;
     Format			=	format;
     SampleCount		=	sampleCount;
     RTV				=	rtv;
     UAV				=	uav;
     Resource		=	resource;
     Subresource		=	subresource;
 }
开发者ID:temik911,项目名称:audio,代码行数:15,代码来源:RenderTargetSurface.cs


示例10: FromFormat

 public static Color FromFormat(uint color, ColorFormat format)
 {
     switch(format)
     {
         case ColorFormat.ARGB:
             return new Color((byte)(color >> 24), (byte)(color >> 16), (byte)(color >> 8), (byte)(color));
         case ColorFormat.RGBA:
             return new Color((byte)(color & 0xFF), (byte)((color & 0xFF000000) >> 24), (byte)((color & 0x00FF0000) >> 16), (byte)((color & 0x0000FF00) >> 8));
         default:
             throw new ArgumentException();
     }
 }
开发者ID:Trontastic,项目名称:ExternalUtilsCSharp,代码行数:12,代码来源:Color.cs


示例11: ColorToDecimal

 public static int ColorToDecimal(Color color, ColorFormat format = ColorFormat.RGB)
 {
     switch (format)
     {
         default:
         case ColorFormat.RGB:
             return color.R << 16 | color.G << 8 | color.B;
         case ColorFormat.RGBA:
             return color.R << 24 | color.G << 16 | color.B << 8 | color.A;
         case ColorFormat.ARGB:
             return color.A << 24 | color.R << 16 | color.G << 8 | color.B;
     }
 }
开发者ID:andre-d,项目名称:ShareXYZ,代码行数:13,代码来源:ColorHelpers.cs


示例12: ColorToHex

 public static string ColorToHex(Color color, ColorFormat format = ColorFormat.RGB)
 {
     switch (format)
     {
         default:
         case ColorFormat.RGB:
             return string.Format("{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
         case ColorFormat.RGBA:
             return string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", color.R, color.G, color.B, color.A);
         case ColorFormat.ARGB:
             return string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", color.A, color.R, color.G, color.B);
     }
 }
开发者ID:L1Q,项目名称:ShareX,代码行数:13,代码来源:ColorHelpers.cs


示例13: TestDecode

 public void TestDecode()
 {
     unchecked {
         var cf = new ColorFormat(16, 8, 8, 8, 0, 8, 24, 8);
         var result = cf.Decode((int)0x87654321);
         Assert.AreEqual((int)0x87654321, result);
         Assert.AreEqual((int)0x87, ((result >> 24) & 0xff));
     }
     {
         var cf = new ColorFormat(8, 4, 4, 4, 0, 4, 0, 0);
         var result = cf.Decode(0x0352);
         Assert.AreEqual((uint)0xff335522, (uint)result);
     }
 }
开发者ID:kael-ip,项目名称:rippix,代码行数:14,代码来源:ColorFormat.cs


示例14: ColorConverterSmartTagAction

        public ColorConverterSmartTagAction(ITrackingSpan span, ParseItem item, ColorModel colorModel, ColorFormat format)
        {
            _span = span;
            _item = item;
            _format = format;
            _colorModel = colorModel;

            if (Icon == null)
            {
                Icon = BitmapFrame.Create(new Uri("pack://application:,,,/WebEssentials2013;component/Resources/palette.png", UriKind.RelativeOrAbsolute));
            }

            SetDisplayText();
        }
开发者ID:joeriks,项目名称:WebEssentials2013,代码行数:14,代码来源:ColorConverterSmartTagAction.cs


示例15: AddColor

        public int AddColor( ref byte[] Bytes, int idx, Color clr, ColorFormat fmt )
        {
            int nc = (int)clr.ToArgb();

            byte a = (byte)((nc&0xFF000000)>>24);
            byte r = (byte)((nc&0x00FF0000)>>16);
            byte g = (byte)((nc&0x0000FF00)>>8);
            byte b = (byte)((nc&0x000000FF));
            switch (fmt)
            {
                case ColorFormat.ARGB4444:
                {
                    byte b1 = (byte)((a&0xF0)|(r>>4));
                    byte b2 = (byte)((g&0xF0)|(b>>4));
                    Bytes[idx] = b2;
                    Bytes[idx + 1] = b1;
                    return 2;
                }
                case ColorFormat.ARGB8888:
                {
                    Bytes[idx] = b;
                    Bytes[idx + 1] = g;
                    Bytes[idx + 2] = r;
                    Bytes[idx + 3] = a;
                    return 4;
                }
                case ColorFormat.RGB565:
                {
                    byte b1 = (byte)((r&0xF8)|((g&0xFC)>>5));
                    byte b2 = (byte)(((g<<3)&0xE0)|((b&0xF8)>>3));
                    Bytes[idx] = b2;
                    Bytes[idx + 1] = b1;
                    return 2;
                }
                case ColorFormat.RGB888:
                {
                    Bytes[idx] = b;
                    Bytes[idx + 1] = g;
                    Bytes[idx + 2] = r;
                    return 3;
                }
                case ColorFormat.A8:
                {
                    Bytes[idx] = a;
                    return 1;
                }
            }
            return 0;
        }
开发者ID:silverio,项目名称:rush,代码行数:49,代码来源:SpritePackage.cs


示例16: Sprite

        public Sprite( string name, string path, Bitmap bmp, ColorFormat fmt, bool bFiltered )
        {
            Name          = name;
            FilePath      = path;
            Width         = bmp.Width;
            Height        = bmp.Height;
            ClrFormat     = fmt;
            Filtered      = bFiltered;
            PivotX        = 0;
            PivotY        = 0;
            ShiftX        = 0;
            ShiftY        = 0;
            Difference    = false;

            CreatePartition( bmp );
        }
开发者ID:silverio,项目名称:rush,代码行数:16,代码来源:SpritePackage.cs


示例17: ColorConverterSmartTagAction

        public ColorConverterSmartTagAction(ITrackingSpan span, ColorModel colorModel, ColorFormat format)
        {
            _span = span;

            if (format == ColorFormat.RgbHex6)
                format = ColorFormat.RgbHex3;

            _format = format;
            _colorModel = colorModel.Clone();
            _colorModel.Format = format;

            if (Icon == null)
            {
                Icon = BitmapFrame.Create(new Uri("pack://application:,,,/WebEssentials2015;component/Resources/Images/palette.png", UriKind.RelativeOrAbsolute));
            }

            _displayText = "Convert to " + GetColorString(_format, _colorModel);
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:18,代码来源:ColorConverterSmartTagAction.cs


示例18: GetColorString

        private static string GetColorString(ColorFormat format, ColorModel model)
        {
            switch (format)
            {
                case ColorFormat.Name:
                    return GetNamedColor(model.Color);

                case ColorFormat.Hsl:
                    return FormatHslColor(model); //ColorFormatter.FormatColorAs(_colorModel, ColorFormat.Hsl);

                case ColorFormat.Rgb:
                case ColorFormat.RgbHex3:
                case ColorFormat.RgbHex6:
                    return ColorFormatter.FormatColor(model, format);

                default:
                    throw new InvalidEnumArgumentException("format", (int)format, typeof(ColorFormat));
            }
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:19,代码来源:ColorConverterSmartTagAction.cs


示例19: TestSerialize

 public void TestSerialize()
 {
     {
         var cf = new ColorFormat(16, 8, 8, 8, 0, 8, 24, 8);
         Assert.AreEqual("S24:8,16:8,8:8,0:8", cf.ToString());
     }
     {
         var cf = new ColorFormat(0, 4, 4, 4, 8, 4, 0, 0);
         Assert.AreEqual("S0:0,0:4,4:4,8:4", cf.ToString());
     }
     {
         var cf = new ColorFormat(16, 8, 8, 8, 0, 8, 24, 8);
         Assert.AreEqual("S24:8,16:8,8:8,0:8", cf.ToString());
     }
     {
         var cf = new ColorFormat(11, 5, 5, 6, 0, 5, 0, 0);
         Assert.AreEqual("S0:0,11:5,5:6,0:5", cf.ToString());
     }
     {
         var cf = new ColorFormat(10, 5, 5, 5, 0, 5, 15, 1);
         Assert.AreEqual("S15:1,10:5,5:5,0:5", cf.ToString());
     }
 }
开发者ID:kael-ip,项目名称:rippix,代码行数:23,代码来源:ColorFormat.cs


示例20: Dither

        public static BitmapSource Dither(BitmapSource source, ColorFormat format)
        {
            if(source.Format == PixelFormats.Indexed8)
            {
                var rgb = new FormatConvertedBitmap();
                rgb.BeginInit();
                rgb.Source = source;
                rgb.DestinationFormat = PixelFormats.Rgb24;
                rgb.EndInit();
                source = rgb;
            }

            var dest = new FormatConvertedBitmap();
            dest.BeginInit();

            dest.Source = source;
            var numColors = (int)Math.Pow(2, (int) format);
            var colors = ColorList.Take(numColors).ToList();
            dest.DestinationPalette = new BitmapPalette(colors);
            dest.DestinationFormat = PixelFormats.Indexed8;
            dest.EndInit();

            return dest;
        }
开发者ID:ungood,项目名称:OmegaNET,代码行数:24,代码来源:BitmapHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ColorGradient类代码示例发布时间:2022-05-24
下一篇:
C# ColorCollection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap