public static CreateBitmap ( |
||
src | ||
tmx | SKShaderTileMode | |
tmy | SKShaderTileMode | |
Результат |
public static void BitmapShaderManipulated(SKCanvas canvas, int width, int height) { var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".color-wheel.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var source = SKBitmap.Decode(stream)) { // invert the pixels var pixels = source.Pixels; for (int i = 0; i < pixels.Length; i++) { pixels[i] = new SKColor( (byte)(255 - pixels [i].Red), (byte)(255 - pixels [i].Green), (byte)(255 - pixels [i].Blue), pixels [i].Alpha); } source.Pixels = pixels; using (var shader = SKShader.CreateBitmap(source, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat)) using (var paint = new SKPaint()) { paint.IsAntialias = true; paint.Shader = shader; // tile the bitmap canvas.Clear(SKColors.White); canvas.DrawPaint(paint); } } }
public static void BitmapShader(SKCanvas canvas, int width, int height) { var assembly = typeof(Demos).GetTypeInfo().Assembly; var imageName = assembly.GetName().Name + ".color-wheel.png"; // load the image from the embedded resource stream using (var resource = assembly.GetManifestResourceStream(imageName)) using (var stream = new SKManagedStream(resource)) using (var source = SKBitmap.Decode(stream)) { // create the shader and paint //SkMatrix matrix; //matrix.setScale(0.75f, 0.75f); //matrix.preRotate(30.0f); var matrix = SKMatrix.MakeRotation(30.0f); using (var shader = SKShader.CreateBitmap(source, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat, matrix)) using (var paint = new SKPaint()) { paint.IsAntialias = true; paint.Shader = shader; // tile the bitmap canvas.Clear(SKColors.White); canvas.DrawPaint(paint); } } }
public SKShader ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix) => SKShader.CreateBitmap(this, tmx, tmy, localMatrix);
public SKShader ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy) => SKShader.CreateBitmap(this, tmx, tmy);