//redraws the StatisticsBackground SKImage. public void GenerateStatisticsBackground(GameplayGameState Self) { using (SKBitmap sourcebit = new SKBitmap(new SKImageInfo(1120, 2576, SKColorType.Rgba8888))) { Size BlockSize = new Size(128, 128); int ColumnCount = (sourcebit.Width / BlockSize.Width) + 1; int RowCount = (sourcebit.Height / BlockSize.Height) + 1; using (SKCanvas g = new SKCanvas(sourcebit)) { g.Clear(Color.Black.ToSKColor()); for (int col = 0; col < ColumnCount; col++) { for (int row = 0; row < RowCount; row++) { int DrawBlockX = col * BlockSize.Width; int DrawBlockY = row * BlockSize.Height; StandardColouredBlock GenerateColorBlock = new StandardColouredBlock(); Nomino ArbitraryGroup = new Nomino(); ArbitraryGroup.AddBlock(new Point[] { Point.Empty }, GenerateColorBlock); Self.PlayField.Theme.ApplyRandom(ArbitraryGroup, Self.GameHandler, Self.PlayField); //this.PlayField.Theme.ApplyTheme(ArbitraryGroup, this.PlayField); TetrisBlockDrawSkiaParameters tbd = new TetrisBlockDrawSkiaParameters(g, new SKRect(DrawBlockX, DrawBlockY, DrawBlockX + BlockSize.Width, DrawBlockY + BlockSize.Height), null, new SettingsManager()); RenderingProvider.Static.DrawElement(null, tbd.g, GenerateColorBlock, tbd); } } } StatisticsBackground = SKImage.FromBitmap(sourcebit); LastStatisticsTheme = Self.PlayField.Theme; Self.f_RedrawStatusBitmap = false; } }
//SkiaSharp implementation of GetImage. public SKBitmap GetImageSK(SKSize BlockSize) { RecalcExtents(); Size BitmapSize = new Size((int)BlockSize.Width * (_GroupExtents.Width + 1), (int)BlockSize.Height * (_GroupExtents.Height + 1)); SKImageInfo info = new SKImageInfo(BitmapSize.Width, BitmapSize.Height, SKColorType.Rgba8888, SKAlphaType.Premul); SKBitmap BuiltRepresentation = new SKBitmap(info, SKBitmapAllocFlags.ZeroPixels); using (SKCanvas DrawRep = new SKCanvas(BuiltRepresentation)) { DrawRep.Clear(SKColors.Transparent); foreach (NominoElement bge in this) { //RectangleF DrawPos = new RectangleF(BlockSize.Width * (bge.X - _GroupExtents.X), BlockSize.Height * (bge.Y - _GroupExtents.Y), BlockSize.Width, BlockSize.Height); var Left = BlockSize.Width * (bge.X - _GroupExtents.X); var Top = BlockSize.Height * (bge.Y - _GroupExtents.Y); SKRect DrawPos = new SKRect(Left, Top, Left + BlockSize.Width, Top + BlockSize.Height); TetrisBlockDrawSkiaParameters tbd = new TetrisBlockDrawSkiaParameters(DrawRep, DrawPos, this, new SettingsManager()); RenderingProvider.Static.DrawElement(null, tbd.g, bge.Block, tbd); } } return(BuiltRepresentation); }