Inheritance: SKStreamMemory
Example #1
0
		public static SKBitmap Decode (byte[] buffer)
		{
			if (buffer == null) {
				throw new ArgumentNullException (nameof (buffer));
			}
			using (var stream = new SKMemoryStream (buffer)) {
				return Decode (stream);
			}
		}
Example #2
0
 public static SKImageInfo DecodeBounds(byte[] buffer)
 {
     if (buffer == null)
     {
         throw new ArgumentNullException(nameof(buffer));
     }
     using (var stream = new SKMemoryStream(buffer)) {
         return(DecodeBounds(stream));
     }
 }
Example #3
0
        public static void CustomFonts(SKCanvas canvas, int width, int height)
        {
            string text = "\u03A3 and \u0750";

            using (var paint = new SKPaint()) {
                canvas.Clear(SKColors.White);
                paint.IsAntialias = true;

                using (var tf = SKTypeface.FromFile(CustomFontPath)) {
                    paint.Color    = XamGreen;
                    paint.TextSize = 60;
                    paint.Typeface = tf;

                    canvas.DrawText(text, 50, 50, paint);
                }

                using (var stream = new SKFileStream(CustomFontPath))
                    using (var tf = SKTypeface.FromStream(stream)) {
                        paint.Color    = XamDkBlue;
                        paint.TextSize = 60;
                        paint.Typeface = tf;

                        canvas.DrawText(text, 50, 100, paint);
                    }

                var assembly = typeof(Demos).GetTypeInfo().Assembly;
                var fontName = assembly.GetName().Name + ".embedded-font.ttf";

                using (var resource = assembly.GetManifestResourceStream(fontName))
                    using (var memory = new MemoryStream()) {
                        resource.CopyTo(memory);
                        var bytes = memory.ToArray();
                        using (var stream = new SKMemoryStream(bytes))
                            using (var tf = SKTypeface.FromStream(stream)) {
                                paint.Color    = XamLtBlue;
                                paint.TextSize = 60;
                                paint.Typeface = tf;

                                canvas.DrawText(text, 50, 150, paint);
                            }
                    }

                using (var resource = assembly.GetManifestResourceStream(fontName))
                    using (var stream = new SKManagedStream(resource))
                        using (var tf = SKTypeface.FromStream(stream)) {
                            paint.Color    = XamPurple;
                            paint.TextSize = 60;
                            paint.Typeface = tf;

                            canvas.DrawText(text, 50, 200, paint);
                        }
            }
        }
		public static void CustomFonts (SKCanvas canvas, int width, int height)
		{
			string text = "\u03A3 and \u0750";

			using (var paint = new SKPaint ()) {
				canvas.Clear (SKColors.White);
				paint.IsAntialias = true;

				using (var tf = SKTypeface.FromFile (CustomFontPath)) {
					paint.Color = XamGreen;
					paint.TextSize = 40;
					paint.Typeface = tf;

					canvas.DrawText (text, 50, 50, paint);
				}

				using (var stream = new SKFileStream (CustomFontPath))
				using (var tf = SKTypeface.FromStream (stream)) {
					paint.Color = XamDkBlue;
					paint.TextSize = 40;
					paint.Typeface = tf;

					canvas.DrawText (text, 50, 100, paint);
				}

				var assembly = typeof(Demos).GetTypeInfo ().Assembly;
				var fontName = assembly.GetName ().Name + ".embedded-font.ttf";

				using (var resource = assembly.GetManifestResourceStream (fontName))
				using (var memory = new MemoryStream ()) {
					resource.CopyTo (memory);
					var bytes = memory.ToArray ();
					using (var stream = new SKMemoryStream (bytes))
					using (var tf = SKTypeface.FromStream (stream)) {
						paint.Color = XamLtBlue;
						paint.TextSize = 40;
						paint.Typeface = tf;

						canvas.DrawText (text, 50, 150, paint);
					}
				}

				using (var resource = assembly.GetManifestResourceStream (fontName))
				using (var stream = new SKManagedStream (resource))
				using (var tf = SKTypeface.FromStream (stream)) {
					paint.Color = XamPurple;
					paint.TextSize = 40;
					paint.Typeface = tf;

					canvas.DrawText (text, 50, 200, paint);
				}
			}
		}