Class PathResourceConverter

Class PathResourceConverter

نام ها : Aspose.Imaging.FileFormats.Tiff.PathResources جمع آوری: Aspose.Imaging.dll (25.4.0)

تبدیل Aspose.Imaging.FileFormats.Tiff.PathResources.PathResource به Aspose.Imaging.GraphicsPath و برعکس.

public static class PathResourceConverter

Inheritance

object PathResourceConverter

اعضای ارثی

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

ایجاد نمودار مسیر از منابع مسیر در تصویر TIFF.

using (var image = (TiffImage)Image.Load("Bottle.tif"))
                                                                  {
                                                                      // Create the GraphicsPath using PathResources from TIFF image
                                                                      var graphicsPath = PathResourceConverter.ToGraphicsPath(image.ActiveFrame.PathResources.ToArray(), image.ActiveFrame.Size);
                                                                      var graphics = new Graphics(image);

                                                                      // Draw red line and save the image
                                                                      graphics.DrawPath(new Pen(Color.Red, 10), graphicsPath);
                                                                      image.Save("BottleWithRedBorder.tif");
                                                                  }

ایجاد منابع مسیر با استفاده از مسیر گرافیک.

static void Main(string[] args)
                                                     {
                                                         using (var image = (TiffImage)Image.Load("Bottle.tif"))
                                                         {
                                                             // Create rectangular Figure for GraphicsPath
                                                             var figure = new Figure();
                                                             figure.AddShape(CreateBezierShape(100f, 100f, 500f, 100f, 500f, 1000f, 100f, 1000f));

                                                             // Create GraphicsPath using our Figure
                                                             var graphicsPath = new GraphicsPath();
                                                             graphicsPath.AddFigure(figure);

                                                             // Set PathResources using GraphicsPath
                                                             var pathResouze = PathResourceConverter.FromGraphicsPath(graphicsPath, image.Size);
                                                             image.ActiveFrame.PathResources = new List<pathresource>(pathResouze);

                                                             // Save the image
                                                             image.Save("BottleWithRectanglePath.tif");
                                                         }
                                                     }

                                                     private static BezierShape CreateBezierShape(params float[] coordinates)
                                                     {
                                                         var bezierPoints = CoordinatesToBezierPoints(coordinates).ToArray();
                                                         return new BezierShape(bezierPoints, true);
                                                     }

                                                     private static IEnumerable<pointf> CoordinatesToBezierPoints(float[] coordinates)
                                                     {
                                                         for (var coordinateIndex = 0; coordinateIndex &lt; coordinates.Length; coordinateIndex += 2)
                                                             for (var index = 0; index &lt; 3; index++)
                                                                 yield return new PointF(coordinates[coordinateIndex], coordinates[coordinateIndex + 1]);
                                                     }</pointf></pathresource>

Methods

FromGraphicsPath(گرافیک، اندازه)

تبدیل نمونه Aspose.Imaging.Graphics به منابع مسیر.

public static PathResource[] FromGraphicsPath(GraphicsPath graphicsPath, Size imageSize)

Parameters

graphicsPath GraphicsPath

مسیر گرافیک

imageSize Size

اندازه تصویر است.

Returns

PathResource [ ]

منابع مسیر

Exceptions

ArgumentNullException

graphicsPath’ is null.

ToGraphicsPath(PathResource[ ], ، اندازه)

تبدیل منابع مسیر به مثال Aspose.Imaging.GraphicsPath.

public static GraphicsPath ToGraphicsPath(PathResource[] pathResources, Size imageSize)

Parameters

pathResources PathResource [ ]

منابع مسیر

imageSize Size

اندازه تصویر است.

Returns

GraphicsPath

در این مطلب به معرفی Aspose.Imaging.Graphics

Exceptions

ArgumentNullException

pathResources’ is null.

 فارسی