public async Task Icon () { var size = new Size (64); var canvas = Platforms.Current.CreateImageCanvas (size, scale: 2); canvas.SaveState (); canvas.Scale (size); canvas.Translate (1 / 8.0, 0); var p = new Path (); p.MoveTo (0, 1,false); p.LineTo (0, 0, false); p.LineTo (0.5, 1, false); p.LineTo (0.5, 0,false); var colors = new [] { "#DCDCDD", "#C5C3C6", "#46494C", "#4C5C68", "#68A5E2", }; foreach (var c in colors) { p.Pen = new Pen (c, 1 / 4.0); p.Draw (canvas); canvas.Translate (1 / 16.0, 0); } await SaveImage (canvas, "Icon.png"); }
public Drawing(Size size, DrawingFunc func) { if (func == null) { throw new ArgumentNullException("func"); } this.size = size; this.func = func; }
public IImageCanvas CreateImageCanvas(Size size, double scale = 1.0, bool transparency = true) { var pixelWidth = (int) Math.Ceiling(size.Width*scale); var pixelHeight = (int) Math.Ceiling(size.Height*scale); var bitmap = Bitmap.CreateBitmap(pixelWidth, pixelHeight, Bitmap.Config.Argb8888); if (!transparency) { bitmap.EraseColor(Colors.Black.Argb); } return new BitmapCanvas(bitmap, scale); }
public WICBitmapCanvas(WIC.Bitmap bmp, D2D1.RenderTargetProperties properties, Direct2DFactories factories = null) : base(new D2D1.WicRenderTarget ((factories ?? Direct2DFactories.Shared).D2DFactory, bmp, properties), factories) { this.Bmp = bmp; this.scale = properties.DpiX / 96.0; var bmpSize = bmp.Size; this.size = new Size (bmpSize.Width / scale, bmpSize.Height / scale); }
public WICBitmapCanvas(Size size, double scale = 1.0, bool transparency = true, Direct2DFactories factories = null) : this(// DIPs = pixels / (DPI/96.0) new WIC.Bitmap ((factories ?? Direct2DFactories.Shared).WICFactory, (int)(Math.Ceiling (size.Width * scale)), (int)(Math.Ceiling (size.Height * scale)), transparency ? WIC.PixelFormat.Format32bppPBGRA : WIC.PixelFormat.Format32bppBGR, WIC.BitmapCreateCacheOption.CacheOnLoad), new D2D1.RenderTargetProperties (D2D1.RenderTargetType.Default, new D2D1.PixelFormat (DXGI.Format.Unknown, D2D1.AlphaMode.Unknown), (float)(96.0 * scale), (float)(96.0 * scale), D2D1.RenderTargetUsage.None, D2D1.FeatureLevel.Level_DEFAULT)) { }
public void DrawImage(IImage image, Rect frame, double alpha = 1.0) { var ii = image as BitmapImage; if (ii != null) { var paint = GetImagePaint(alpha); var isize = new Size(ii.Bitmap.Width, ii.Bitmap.Height); var scale = frame.Size/isize; var m = new Matrix(); m.PreTranslate((float) frame.X, (float) frame.Y); m.PreScale((float) scale.Width, (float) scale.Height); graphics.DrawBitmap(ii.Bitmap, m, paint); } }
public IImageCanvas CreateImageCanvas(Size size, double scale = 1.0, bool transparency = true) { var pixelWidth = (int) Math.Ceiling(size.Width*scale); var pixelHeight = (int) Math.Ceiling(size.Height*scale); var format = transparency ? PixelFormat.Format32bppPArgb : PixelFormat.Format24bppRgb; var bitmap = new Bitmap(pixelWidth, pixelHeight, format); return new BitmapCanvas(bitmap, scale); }
private void Read(XDocument doc) { var svg = doc.Root; var ns = svg.Name.Namespace; // // Find the defs (gradients) // foreach (var d in svg.Descendants()) { var idA = d.Attribute("id"); if (idA != null) { defs[ReadString(idA).Trim()] = d; } } // // Get the dimensions // var widthA = svg.Attribute("width"); var heightA = svg.Attribute("height"); var width = _valuesParser.ReadNumber(widthA); var height = _valuesParser.ReadNumber(heightA); var size = new Size(width, height); var viewBox = new Rect(size); var viewBoxA = svg.Attribute("viewBox") ?? svg.Attribute("viewPort"); if (viewBoxA != null) { viewBox = ReadRectangle(viewBoxA.Value); } if (widthA != null && widthA.Value.Contains("%")) { size.Width *= viewBox.Width; } if (heightA != null && heightA.Value.Contains("%")) { size.Height *= viewBox.Height; } // // Add the elements // Graphic = new Graphic(size, viewBox); AddElements(Graphic.Children, svg.Elements(), null, null); }
public void Inflate(Size padding) { Inflate(padding.Width, padding.Height); }
public Rect(Size size) : this(0, 0, size.Width, size.Height) { }
public Rect(Point position, Size size) : this(position.X, position.Y, size.Width, size.Height) { }
public IImageCanvas CreateImageCanvas(Size size, double scale = 1.0, bool transparency = true) { return new NullImageSurface(); }