當前位置: 首頁>>代碼示例>>C#>>正文


C# ColorFormat類代碼示例

本文整理匯總了C#中ColorFormat的典型用法代碼示例。如果您正苦於以下問題:C# ColorFormat類的具體用法?C# ColorFormat怎麽用?C# ColorFormat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ColorFormat類屬於命名空間,在下文中一共展示了ColorFormat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的ColorFormat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。