private static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr dc, DrawingOptions opts);
internal static extern int SendMessage(IntPtr hWnd, int msg, IntPtr dc, DrawingOptions opts);
public virtual void Draw(SpriteBatch spriteBatch, CephalometricPointCollection points, CephalometricMeasurementCollection measurements, DrawingOptions options) { }
private static extern int SendMessage(IntPtr hWnd, int msg, IntPtr dc, DrawingOptions opts);
private static Image <Bgra32> CutImage(Sprite m_Sprite, Texture2D m_Texture2D, Rectf textureRect, Vector2 textureRectOffset, float downscaleMultiplier, SpriteSettings settingsRaw) { var originalImage = m_Texture2D.ConvertToImage(false); if (originalImage != null) { using (originalImage) { if (downscaleMultiplier > 0f && downscaleMultiplier != 1f) { var width = (int)(m_Texture2D.m_Width / downscaleMultiplier); var height = (int)(m_Texture2D.m_Height / downscaleMultiplier); originalImage.Mutate(x => x.Resize(width, height)); } var rectX = (int)Math.Floor(textureRect.x); var rectY = (int)Math.Floor(textureRect.y); var rectRight = (int)Math.Ceiling(textureRect.x + textureRect.width); var rectBottom = (int)Math.Ceiling(textureRect.y + textureRect.height); rectRight = Math.Min(rectRight, originalImage.Width); rectBottom = Math.Min(rectBottom, originalImage.Height); var rect = new Rectangle(rectX, rectY, rectRight - rectX, rectBottom - rectY); var spriteImage = originalImage.Clone(x => x.Crop(rect)); if (settingsRaw.packed == 1) { //RotateAndFlip switch (settingsRaw.packingRotation) { case SpritePackingRotation.kSPRFlipHorizontal: spriteImage.Mutate(x => x.Flip(FlipMode.Horizontal)); break; case SpritePackingRotation.kSPRFlipVertical: spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); break; case SpritePackingRotation.kSPRRotate180: spriteImage.Mutate(x => x.Rotate(180)); break; case SpritePackingRotation.kSPRRotate90: spriteImage.Mutate(x => x.Rotate(270)); break; } } //Tight if (settingsRaw.packingMode == SpritePackingMode.kSPMTight) { try { var triangles = GetTriangles(m_Sprite.m_RD); var polygons = triangles.Select(x => new Polygon(new LinearLineSegment(x.Select(y => new PointF(y.X, y.Y)).ToArray()))).ToArray(); IPathCollection path = new PathCollection(polygons); var matrix = Matrix3x2.CreateScale(m_Sprite.m_PixelsToUnits); matrix *= Matrix3x2.CreateTranslation(m_Sprite.m_Rect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, m_Sprite.m_Rect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y); path = path.Transform(matrix); var graphicsOptions = new GraphicsOptions { Antialias = false, AlphaCompositionMode = PixelAlphaCompositionMode.DestOut }; var options = new DrawingOptions { GraphicsOptions = graphicsOptions }; using (var mask = new Image <Bgra32>(rect.Width, rect.Height, SixLabors.ImageSharp.Color.Black)) { mask.Mutate(x => x.Fill(options, SixLabors.ImageSharp.Color.Red, path)); var bursh = new ImageBrush(mask); spriteImage.Mutate(x => x.Fill(graphicsOptions, bursh)); spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); return(spriteImage); } } catch { // ignored } } //Rectangle spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); return(spriteImage); } } return(null); }
/// <summary> /// Creates a new annotation for a document /// </summary> /// <param name="connectionId">Socket connection identifier to validate user permissions for</param> /// <param name="fileId">The document path to create the annotation for</param> /// <param name="type">The annotation type</param> /// <param name="message">The annotation text message</param> /// <param name="rectangle">The annotation bounds</param> /// <param name="pageNumber">The document page number to create the annotation at</param> /// <param name="annotationPosition">The annotation left-top position</param> /// <param name="svgPath">The annotation SVG path</param> /// <param name="options">The annotation drawing options (pen color, width etc.)</param> /// <param name="font">The annotation text font</param> /// <returns>An instance of an object containing information about a created annotation</returns> public CreateAnnotationResult CreateAnnotation(string connectionId, string fileId, byte type, string message, Rectangle rectangle, int pageNumber, Point annotationPosition, string svgPath, DrawingOptions options, FontOptions font) { var reviewer = _annotationBroadcaster.GetConnectionUser(connectionId); if (reviewer == null) { throw new AnnotatorException("There is no such reviewer."); } var user = _userSvc.GetUserByGuid(reviewer.Value.UserGuid); var document = GetDocument(fileId, user.Id); var collaboratorsInfo = _mapper.Map <GetCollaboratorsResult>(_annotator.GetCollaborators(document.Id)); var caller = collaboratorsInfo.Collaborators.FirstOrDefault(c => c.Guid == reviewer.Value.UserGuid); var annotation = new GroupDocs.Annotation.Domain.AnnotationInfo { Type = (AnnotationType)type, Box = new GroupDocs.Annotation.Domain.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height), PageNumber = pageNumber, AnnotationPosition = new GroupDocs.Annotation.Domain.Point(annotationPosition.X, annotationPosition.Y), SvgPath = svgPath, PenColor = options?.PenColor, PenWidth = options?.PenWidth, PenStyle = options != null ? (byte?)options.DashStyle : null, BackgroundColor = options?.BrushColor, FontFamily = font?.Family, FontSize = font?.Size }; if (!string.IsNullOrWhiteSpace(message)) { annotation.Replies = new[] { new GroupDocs.Annotation.Domain.AnnotationReplyInfo { Message = message } }; } var result = _annotator.CreateAnnotation(annotation, document.Id, user.Id); _annotationBroadcaster.CreateAnnotation( collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), connectionId, reviewer.Value.UserGuid, caller != null ? caller.PrimaryEmail : _authenticationSvc.AnonymousUserName, fileId, annotation.Type, result.Guid, (byte)result.Access, result.ReplyGuid, pageNumber, _mapper.Map <Rectangle>(rectangle), annotationPosition, svgPath, options, font); return(_mapper.Map <CreateAnnotationResult>(result)); }