public PxMatrix CalcMatrix(PxSize viewPort, PxRectangle imageSize) { if (Option == PreserveAspectRatioOption.None) { return(PxMatrix.Translation( viewPort.Width / imageSize.Width, viewPort.Height / imageSize.Height, 0, 0 )); } var scale = Option == PreserveAspectRatioOption.Meet ? Math.Min( viewPort.Height / imageSize.Height, viewPort.Width / imageSize.Width ) : Math.Max( viewPort.Height / imageSize.Height, viewPort.Width / imageSize.Width ); var scaledW = imageSize.Width * scale; var scaledH = imageSize.Height * scale; var scaleX = scaledW / imageSize.Width; var scaleY = scaledH / imageSize.Height; return(PxMatrix.Translation( scaleX, scaleY, imageSize.X + CalcOffset(AlignX, viewPort.Width, scaledW), // / scaleX, imageSize.Y + CalcOffset(AlignY, viewPort.Height, scaledH) // / scaleY )); }
public void PageEditorControllerDidFinishedEditingPage(PageEditorController editor, CGPoint[] pts) { points = PxRectangle.FromCGPointRect(pts); editor.DismissViewController(true, null); this.Process(); }
public XyRect Add(PxRectangle r) { return(new XyRect( Math.Min(_x1, r.X), Math.Min(_y1, r.Y), Math.Max(_x2, r.X + r.Width), Math.Max(_y2, r.Y + r.Height) )); }
public static DXM.RawRectangleF ToDx(this PxRectangle rect) { return(new DXM.RawRectangleF( rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height )); }
public void DrawBarcode( IElement element, IFrameContext context, PxRectangle bounds, Fill fill, Stroke strokeStyle, string value ) { var fillBrush = CreateBrush(element, context, fill.Brush, fill.Opacity); var strokeBrush = strokeStyle.Width > 0 ? CreateBrush(element, context, strokeStyle.Brush, strokeStyle.Opacity) : null; var rect = bounds.ToDx(); if (fillBrush != null) { Target.FillRectangle(rect, fillBrush); } if (value == null || strokeBrush == null) { return; } if (!long.TryParse(value, out var v)) { return; } var ss = GetStrokeStyle(strokeStyle); var x = bounds.X; var a = BarcodeCode39.Encode(v).ToList(); var w = a.Sum(); var s = bounds.Width / w; var i = 0; foreach (var q in a) { Target.DrawLine( new DXM.RawVector2(x, rect.Top), new DXM.RawVector2(x, rect.Bottom), i % 2 == 0 ? strokeBrush : fillBrush, (q * s), ss ); i++; x += (q * s); } }
public void DrawRectangle( IElement element, IFrameContext context, PxRectangle bounds, PxPoint radius, Fill fill, Stroke strokeStyle ) { if (MathEx.IsZero(bounds.Width) || MathEx.IsZero(bounds.Height)) { return; } var fillBrush = fill == null ? null : CreateBrush(element, context, fill.Brush, fill.Opacity); var strokeBrush = strokeStyle.Width > 0 ? CreateBrush(element, context, strokeStyle.Brush, strokeStyle.Opacity) : null; var rect = bounds.ToDx(); if (radius.X > 0 || radius.Y > 0) { var roundedRect = new D2D1.RoundedRectangle() { Rect = rect, RadiusX = MathEx.IsZero(radius.X) ? radius.Y : radius.X, RadiusY = MathEx.IsZero(radius.Y) ? radius.X : radius.Y }; if (fillBrush != null) { Target.FillRoundedRectangle(roundedRect, fillBrush); } if (strokeBrush != null) { Target.DrawRoundedRectangle(roundedRect, strokeBrush, strokeStyle.Width, GetStrokeStyle(strokeStyle)); } } else { if (fillBrush != null) { Target.FillRectangle(rect, fillBrush); } if (strokeBrush != null) { Target.DrawRectangle(rect, strokeBrush, strokeStyle.Width, GetStrokeStyle(strokeStyle)); } } }
private static float ResolvePercentage(float value, ref PxRectangle size, MeasureUsage usage) { // ReSharper disable once SwitchStatementMissingSomeCases switch (usage) { case MeasureUsage.Horizontal: return((size.Width * value) / 100); case MeasureUsage.Vertical: return((size.Height * value) / 100); default: return(0.0f); } }
private static void Render(this D2D1.Bitmap bitmap, IElement element, IFrameContext context, RendererDirect2D render) { var size = element.GetSize(context, context.Size); var viewPort = new PxRectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height); using (TransformHelper.CreatePosition(render, element, context)) using (LayerHelper.Create(render, element, context, size)) using (TransformHelper.Create(render, element.GetPreserveAspectRatio().CalcMatrix(size, viewPort))) { render.Target.DrawBitmap( bitmap, new DXM.RawRectangleF(0, 0, bitmap.Size.Width, bitmap.Size.Height), element.GetOpacity(), D2D1.BitmapInterpolationMode.NearestNeighbor ); } }
private bool ProcessCrop(PxMetaImage source, out PxRectangle pts) { PxDocCorners docCorners; bool result = PxSDK.DetectDocumentCorners(source, out docCorners); pts.leftTop = docCorners.ptUL; pts.rightTop = docCorners.ptUR; pts.leftBotton = docCorners.ptBL; pts.rightBotton = docCorners.ptBR; bool isSmartCropMode = false; if (result) { isSmartCropMode = docCorners.isSmartCropMode; } return(isSmartCropMode); }
public Path(PathSegment[] segments, PxRectangle bounds) { Segments = segments; Bounds = bounds; }
public static float Resolve(this Measure measure, IElement element, IFrameContext context, PxRectangle size, bool TreatUserAsPercentage = false) { // ReSharper disable once SwitchStatementMissingSomeCases switch (measure.Unit) { case MeasureUnit.Em: return(measure.Value * element.GetFontSize(context)); case MeasureUnit.Ex: return((measure.Value * element.GetFontSize(context)) / 2); case MeasureUnit.User: return(TreatUserAsPercentage ? ResolvePercentage(measure.Value * 100, ref size, measure.Usage) : context.ToDeviceValue(measure)); case MeasureUnit.Percentage: return(ResolvePercentage(measure.Value, ref size, measure.Usage)); default: return(context.ToDeviceValue(measure)); } }
public Text(IEnumerable <TextEntry> textEntries, PxRectangle bounds) { Bounds = bounds; TextEntries = textEntries; }
public PathSegment(IEnumerable <IPathCommand> commands, PxRectangle bounds, bool isClosed) { Bounds = bounds; Commands = commands.ToArray(); IsClosed = isClosed; }