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


C# Palette.GetColor方法代码示例

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


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

示例1: RenderTile

        public static void RenderTile(BitmapData canvas, int x, int y, Tile tile, Palette palette, int paletteIndex,
            bool flipX, bool flipY, bool transparent)
        {
            int* start = (int*)canvas.Scan0 + canvas.Stride * y / 4 + x;

            for (int py = 0; py < 8; py++)
            {
                int* current = start;
                int actualY = flipY ? (7 - py) : py;

                for (int px = 0; px < 8; px++)
                {
                    byte colorIndex = tile[flipX ? (7 - px) : px, actualY];

                    if (!transparent || (colorIndex != 0))
                    {
                        *current = palette.GetColor(paletteIndex, colorIndex).Argb;
                    }

                    current++;
                }

                start += canvas.Stride / 4;
            }
        }
开发者ID:ChrisBlueStone,项目名称:RopeSnake,代码行数:25,代码来源:Renderer.cs

示例2: AddPalette

 public int AddPalette(string name, Palette p)
 {
     palettes.Add(name, p);
     indices.Add(name, allocated);
     for (int i = 0; i < 256; i++)
     {
         this[new Point(i, allocated)] = p.GetColor(i);
     }
     return allocated++;
 }
开发者ID:comradpara,项目名称:OpenRA,代码行数:10,代码来源:HardwarePalette.cs

示例3: AsBitmap

        public Bitmap AsBitmap(TextureChannel channel, Palette pal)
        {
            var d = Data;
            var b = new Bitmap(Size.Width, Size.Height);
            var output = b.LockBits(new Rectangle(0, 0, Size.Width, Size.Height),
                ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

            unsafe
            {
                int* c = (int*)output.Scan0;

                for (var x = 0; x < Size.Width; x++)
                    for (var y = 0; y < Size.Height; y++)
                {
                    var index = d[4*Size.Width*y + 4*x + (int)channel];
                    *(c + (y * output.Stride >> 2) + x) = pal.GetColor(index).ToArgb();
                }
            }
            b.UnlockBits(output);

            return b;
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:22,代码来源:Sheet.cs

示例4: ScRgbInterpolationMode

 public void ScRgbInterpolationMode()
 {
     Palette palette = new Palette(PaletteMode.Interpolate)
     {
         new PaletteEntry(0, Color.FromScRgb(0.0f, 0.1f, 0.2f, 0.3f)),
         new PaletteEntry(1, Color.FromScRgb(1.0f, 1.0f, 1.0f, 1.0f)),
     };
     palette.ColorInterpolationMode = ColorInterpolationMode.ScRgbLinearInterpolation;
     Assert.AreEqual(Color.FromScRgb(0.5f, 0.55f, 0.6f, 0.65f), palette.GetColor(0.5));
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:10,代码来源:PaletteTest.cs

示例5: SRgbInterpolationMode

 public void SRgbInterpolationMode()
 {
     Palette palette = new Palette(PaletteMode.Interpolate)
     {
         new PaletteEntry(0, Color.FromArgb(0, 20, 40, 60)),
         new PaletteEntry(1, Color.FromArgb(255, 255, 255, 255)),
     };
     palette.ColorInterpolationMode = ColorInterpolationMode.SRgbLinearInterpolation;
     Assert.AreEqual(Color.FromArgb(127, 137, 147, 157), palette.GetColor(0.5));
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:10,代码来源:PaletteTest.cs

示例6: GetColorException_GreaterOrEqual

        public void GetColorException_GreaterOrEqual()
        {
            Palette palette = new Palette(PaletteMode.GreaterOrEqual)
            {
                new PaletteEntry(0, Colors.Red),
                new PaletteEntry(2, Colors.Blue),
                new PaletteEntry(1, Colors.Green)
            };

            AssertHelper.Throws<PaletteException>(() => palette.GetColor(3));
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:11,代码来源:PaletteTest.cs

示例7: GetColorException

 public void GetColorException()
 {
     Palette palette = new Palette(PaletteMode.Closest);
     AssertHelper.Throws<PaletteException>(() => palette.GetColor(0.5));
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:5,代码来源:PaletteTest.cs


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