本文整理汇总了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;
}
}
示例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++;
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例7: GetColorException
public void GetColorException()
{
Palette palette = new Palette(PaletteMode.Closest);
AssertHelper.Throws<PaletteException>(() => palette.GetColor(0.5));
}