本文整理汇总了C#中Palette类的典型用法代码示例。如果您正苦于以下问题:C# Palette类的具体用法?C# Palette怎么用?C# Palette使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Palette类属于命名空间,在下文中一共展示了Palette类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
r = new RandomSeed(DateTime.Now.Millisecond);
//First we create the buffer. This will contain all our sprites
buffer = new GameObject[NUM_LAYERS,WIDTH,HEIGHT];
//Second, we find a pointer to the level data
LD_Cave ld = new LD_Cave(WIDTH, HEIGHT, r.getSeed(),new Vector2(0,0));
//LD_Dungeon ld = new LD_Dungeon(WIDTH, HEIGHT, r.getSeed(), new Vector2(0,0));
ld.generate();
//Next, we generate a color palette
palette = new Palette(r);
//Third, we translate the level into sprites
for(int layer = 0; layer < NUM_LAYERS; layer++)
{
for(int y = 0; y < HEIGHT; y++)
{
for(int x = 0; x < WIDTH; x++)
{
buffer[layer,x,y] = makeSprite(x,y,ld.mapData[layer,x,y],layer); //ld.mapData[layer,x,y]
}//for
}//for
}//for
}
开发者ID:snotwadd20,项目名称:UnityLevelGen,代码行数:27,代码来源:Buffer.cs
示例2: RenderResourceType
public static ResourceTemplate RenderResourceType(ResourceTypeInfo info, string[] exts, Palette p)
{
var image = info.EditorSprite;
using (var s = GlobalFileSystem.OpenWithExts(image, exts))
{
// TODO: Do this properly
var shp = new ShpReader(s) as ISpriteSource;
var frame = shp.Frames.Last();
var bitmap = new Bitmap(frame.Size.Width, frame.Size.Height, PixelFormat.Format8bppIndexed);
bitmap.Palette = p.AsSystemPalette();
var data = bitmap.LockBits(bitmap.Bounds(),
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
unsafe
{
byte* q = (byte*)data.Scan0.ToPointer();
var stride = data.Stride;
for (var i = 0; i < frame.Size.Width; i++)
for (var j = 0; j < frame.Size.Height; j++)
q[j * stride + i] = frame.Data[i + frame.Size.Width * j];
}
bitmap.UnlockBits(data);
return new ResourceTemplate { Bitmap = bitmap, Info = info, Value = shp.Frames.Count() - 1 };
}
}
开发者ID:RunCraze,项目名称:OpenRA,代码行数:28,代码来源:RenderUtils.cs
示例3: InitPalette
public void InitPalette( WorldRenderer wr )
{
var paletteName = "{0}{1}".F( info.BaseName, owner.InternalName );
var newpal = new Palette(wr.GetPalette(info.BasePalette),
new PlayerColorRemap(info.PaletteFormat, owner.ColorRamp));
wr.AddPalette(paletteName, newpal);
}
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:7,代码来源:PlayerColorPalette.cs
示例4: CreateImage
IndexedBitmap CreateImage()
{
var image = new IndexedBitmap(100, 100, 8, Generator);
var ega = Palette.GetEgaPalette();
var pal = new Palette(ega);
// must have at least 256 colors for an 8-bit bitmap
while (pal.Count < 256)
pal.Add(Colors.Black);
image.Palette = pal;
using (var bd = image.Lock())
{
unsafe
{
var brow = (byte*)bd.Data;
for (int y = 0; y < image.Size.Height; y++)
{
byte* b = brow;
var col = -y;
for (int x = 0; x < image.Size.Width; x++)
{
while (col < 0)
col = ega.Count + col;
while (col >= ega.Count)
col -= ega.Count;
*b = (byte)col++;
b++;
}
brow += bd.ScanWidth;
}
}
}
return image;
}
开发者ID:alexandrebaker,项目名称:Eto,代码行数:35,代码来源:IndexedBitmapSection.cs
示例5: CreateImage
IndexedBitmap CreateImage()
{
var image = new IndexedBitmap (100, 100, 8);
var pal = new Palette (Palette.GetEgaPalette ());
// must have at least 256 colors for an 8-bit bitmap
while (pal.Count < 256)
pal.Add (Color.Black);
image.Palette = pal;
var bd = image.Lock ();
unsafe {
int col = 0;
byte* brow = (byte*)bd.Data;
for (int y = 0; y < image.Size.Height; y++) {
byte* b = brow;
for (int x = 0; x < image.Size.Width; x++) {
if (col >= pal.Count)
col = 0;
*b = (byte)col++;
b++;
}
brow += bd.ScanWidth;
}
}
image.Unlock (bd);
return image;
}
开发者ID:hultqvist,项目名称:Eto,代码行数:29,代码来源:IndexedBitmapSection.cs
示例6: RenderActor
public static ActorTemplate RenderActor(ActorInfo info, TileSet tileset, Palette p)
{
var image = RenderSprites.GetImage(info);
using (var s = GlobalFileSystem.OpenWithExts(image, tileset.Extensions))
{
var shp = new ShpReader(s);
var bitmap = RenderShp(shp, p);
try
{
using (var s2 = GlobalFileSystem.OpenWithExts(image + "2", tileset.Extensions))
{
var shp2 = new ShpReader(s2);
var roofBitmap = RenderShp(shp2, p);
using (var g = System.Drawing.Graphics.FromImage(bitmap))
g.DrawImage(roofBitmap, 0, 0);
}
}
catch { }
return new ActorTemplate
{
Bitmap = bitmap,
Info = info,
Appearance = info.Traits.GetOrDefault<EditorAppearanceInfo>()
};
}
}
开发者ID:RunCraze,项目名称:OpenRA,代码行数:30,代码来源:RenderUtils.cs
示例7: CopyRectangleToPoint
/// <summary>
/// Copies the rectangle to point.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="sourceRectangle">The source rectangle.</param>
/// <param name="destination">The destination.</param>
/// <param name="destinationPoint">The destination point.</param>
/// <param name="flip">if set to <c>true</c> [flip].</param>
public static void CopyRectangleToPoint( this Bitmap source, Rectangle sourceRectangle, Bitmap destination, Point destinationPoint, Palette palette, bool reverseX, bool reverseY )
{
BitmapData bmdSource = source.LockBits( new Rectangle( 0, 0, source.Width, source.Height ), ImageLockMode.ReadOnly, source.PixelFormat );
BitmapData bmdDest = destination.LockBits( new Rectangle( 0, 0, destination.Width, destination.Height ), ImageLockMode.WriteOnly, destination.PixelFormat );
int width = sourceRectangle.Width;
int height = sourceRectangle.Height;
int x = destinationPoint.X;
int y = destinationPoint.Y;
CalcOffset calcX = reverseX ?
(CalcOffset)(col => (width - col - 1)) :
(CalcOffset)(col => col);
CalcOffset calcY = reverseY ?
(CalcOffset)(row => (height - row - 1)) :
(CalcOffset)(row => row);
for (int col = 0; col < sourceRectangle.Width; col++)
{
for (int row = 0; row < sourceRectangle.Height; row++)
{
int index = bmdSource.GetPixel( col + sourceRectangle.X, row + sourceRectangle.Y );
if (palette.Colors[index % 16].A != 0)
{
bmdDest.SetPixel8bpp(
x + calcX( col ),
y + calcY( row ),
index );
}
}
}
source.UnlockBits( bmdSource );
destination.UnlockBits( bmdDest );
}
开发者ID:Glain,项目名称:FFTPatcher,代码行数:42,代码来源:ExtensionMethods.cs
示例8: LoadFileOverride
protected override XCImageCollection LoadFileOverride(string directory,string file,int imgWid,int imgHei,Palette pal)
{
System.IO.Stream tabStream=null;
string tabBase = file.Substring(0,file.LastIndexOf("."));
try
{
if(System.IO.File.Exists(directory+"\\"+tabBase+TAB_EXT))
tabStream = System.IO.File.OpenRead(directory+"\\"+tabBase+TAB_EXT);
return new PckFile(System.IO.File.OpenRead(directory+"\\"+file),
tabStream,
2,
pal,
imgHei,
imgWid);
}
catch(Exception)
{
if(System.IO.File.Exists(directory+"\\"+tabBase+TAB_EXT))
tabStream = System.IO.File.OpenRead(directory+"\\"+tabBase+TAB_EXT);
return new PckFile(System.IO.File.OpenRead(directory+"\\"+file),
tabStream,
4,
pal,
imgHei,
imgWid);
}
}
开发者ID:pmprog,项目名称:OpenXCOM.Tools,代码行数:31,代码来源:xcPck.cs
示例9: InitPalette
public void InitPalette( WorldRenderer wr )
{
var paletteName = "{0}{1}".F( info.BaseName, owner.InternalName );
var newpal = new Palette(wr.Palette(info.BasePalette).Palette,
new PlayerColorRemap(info.RemapIndex, owner.ColorRamp));
wr.AddPalette(paletteName, newpal, info.AllowModifiers);
}
开发者ID:nevelis,项目名称:OpenRA,代码行数:7,代码来源:PlayerColorPalette.cs
示例10: GetDefaultPalette
public static Palette GetDefaultPalette()
{
var swatches = new Swatches();
var pal = new Palette();
pal.Add(swatches.FadedDarkBlue);
pal.Add(swatches.BrightOrange);
pal.Add(swatches.SimpleGreen);
pal.Add(swatches.PurpleByzantium);
pal.Add(swatches.Jonquil);
pal.Add(swatches.FireEngineRed);
pal.Add(swatches.LightGray);
pal.Add(swatches.DeepBlue);
pal.Add(swatches.DarkGray);
pal.Add(swatches.ForestGreen);
pal.Add(swatches.Carmine);
pal.Add(swatches.BrightPink);
pal.Add(swatches.Eggplant);
pal.Add(swatches.Byzantine);
pal.Add(swatches.JungleGreen);
pal.Add(swatches.Black);
pal.Add(swatches.Jonquil);
pal.Add(swatches.Chamoisee);
return pal;
}
开发者ID:saveenr,项目名称:saveenr,代码行数:25,代码来源:PaletteBuilder.cs
示例11: CommandDPForm
public CommandDPForm()
{
InitializeComponent();
this.pbImage.Image = new Bitmap(CommandDPForm.IMG_WIDTH, CommandDPForm.IMG_HEIGHT);
Graphics imgGraphics = Graphics.FromImage(this.pbImage.Image);
imgGraphics.Clear(Color.White);
this.calcStretch();
this.tool = Palette.LINE;
this.tsbLine.Tag = Palette.LINE;
this.tsbRectangle.Tag = Palette.RECTANGLE;
this.tsbEllipse.Tag = Palette.ELLIPSE;
this.tsbLeft.Tag = MoveType.LEFT;
this.tsbUp.Tag = MoveType.UP;
this.tsbRight.Tag = MoveType.RIGHT;
this.tsbDown.Tag = MoveType.DOWN;
this.tscbLineWidth.SelectedIndex = 0;
this.tsbColor.BackColor = Color.Black;
this.editor = new Editor();
this.tscbShapes.Items.Add(new EmptyShape(Pens.White));
this.tscbShapes.SelectedIndex = 0;
}
开发者ID:davidbedok,项目名称:oeprogvep,代码行数:26,代码来源:CommandDPForm.cs
示例12: 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
示例13: RemoveTest
public void RemoveTest()
{
Palette palette = new Palette
{
new PaletteEntry(0, Colors.Red),
new PaletteEntry(2, Colors.Blue),
new PaletteEntry(1, Colors.Green)
};
Assert.AreEqual(3, palette.Count);
Assert.AreEqual(new PaletteEntry(0, Colors.Red), palette[0]);
Assert.AreEqual(new PaletteEntry(2, Colors.Blue), palette[1]);
Assert.AreEqual(new PaletteEntry(1, Colors.Green), palette[2]);
bool result = palette.Remove(1);
Assert.IsTrue(result);
Assert.AreEqual(2, palette.Count);
Assert.AreEqual(new PaletteEntry(0, Colors.Red), palette[0]);
Assert.AreEqual(new PaletteEntry(2, Colors.Blue), palette[1]);
result = palette.Remove(2);
Assert.IsTrue(result);
Assert.AreEqual(1, palette.Count);
Assert.AreEqual(new PaletteEntry(0, Colors.Red), palette[0]);
result = palette.Remove(1);
Assert.IsFalse(result);
Assert.AreEqual(1, palette.Count);
result = palette.Remove(0);
Assert.IsTrue(result);
Assert.AreEqual(0, palette.Count);
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:33,代码来源:PaletteTest.cs
示例14: Load
/// <summary>
/// Load theme from xml.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static bool Load(string path)
{
if (!File.Exists(path))
return false;
palette = XmlSerializer.Load<Palette>(path);
return true;
}
开发者ID:h3tch,项目名称:ProtoFX,代码行数:12,代码来源:Theme.cs
示例15: LoadFileOverride
protected override XCImageCollection LoadFileOverride(string directory, string file, int imgWid, int imgHei, Palette pal)
{
XCImageCollection collect = new XCImageCollection();
XCImage img = new SPKImage(pal, File.OpenRead(directory + "\\" + file),imgWid,imgHei);
collect.Add(img);
return collect;
}
开发者ID:pmprog,项目名称:OpenXCOM.Tools,代码行数:8,代码来源:xcSpk.cs
示例16: RegisterAppearance
public void RegisterAppearance(ChartAppearance appearance, ViewType viewType, Palette palette)
{
AppearanceColors row = new AppearanceColors(appearance, palette);
matrix.Add(row);
for (int i = 0; i <= palette.Count; i++)
row[i] = AddStyleEditor(AppearanceImageHelper.CreateImage(viewType, appearance, palette, i), i);
lastRegisteredAppearance++;
}
开发者ID:BadButton,项目名称:WOT-Statistics,代码行数:8,代码来源:StylesContainerControl.cs
示例17: AddPalette
public void AddPalette(string name, Palette p)
{
if (palettes.ContainsKey(name))
throw new InvalidOperationException("Palette {0} has already been defined".F(name));
palettes.Add(name, p);
indices.Add(name, allocated++);
}
开发者ID:katzsmile,项目名称:OpenRA,代码行数:8,代码来源:HardwarePalette.cs
示例18: IXCTileset
protected IXCTileset(string name)
: base(name)
{
myPal = GameInfo.DefaultPalette;
mapSize = new MapSize(60, 60, 4);
mapDepth = 0;
underwater = true;
baseStyle = false;
}
开发者ID:pmprog,项目名称:OpenXCOM.Tools,代码行数:9,代码来源:IXCTileset.cs
示例19: OnGenerated
public void OnGenerated(Palette palette)
{
Color vibrantDark = new Color(palette.GetDarkVibrantColor(Resource.Color.appMain));
Color dullDark = new Color(palette.GetDarkMutedColor(Resource.Color.appDark));
SupportActionBar.SetBackgroundDrawable(new ColorDrawable(vibrantDark));
SupportActionBar.SetDisplayShowTitleEnabled(false);
SupportActionBar.SetDisplayShowTitleEnabled(true);
Window.SetStatusBarColor(dullDark);
}
开发者ID:GSDan,项目名称:Speeching_Client,代码行数:10,代码来源:RecordPlaceEntryActivity.cs
示例20: 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
注:本文中的Palette类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论