Class PathResourceConverter
Namespace: Aspose.Imaging.FileFormats.Tiff.PathResources
Assembly: Aspose.Imaging.dll (25.7.0)
Converts Aspose.Imaging.FileFormats.Tiff.PathResources.PathResource to Aspose.Imaging.GraphicsPath and vice versa.
public static class PathResourceConverter
{
public static string Convert(string resourcePath)
{
if (string.IsNullOrEmpty(resourcePath))
return null;
var pathParts = resourcePath.Split('.');
var extension = pathParts[pathParts.Length - 1];
var resourceName = string.Join(".", pathParts.Take(pathParts.Length - 1).ToArray());
if (extension == "resx")
{
return ConvertResxResource(resourcePath);
}
else if (extension == "xaml")
{
return ConvertXamlResource(resourcePath);
}
return null;
}
private static string ConvertResxResource(string resourcePath)
{
}
private static string ConvertXamlResource(string resourcePath)
{
}
}
Inheritance
object ← PathResourceConverter
Inherited Members
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Create Graphics Path from Path Resources in TIFF image.
using (var image as TiffImage = Image.Load("Bottle.tif"))
{
var graphicsPath = PathResourceConverter.ToGraphicsPath(image.ActiveFrame.PathResources.ToArray(), image.ActiveFrame.Size);
var graphics = new Graphics(image);
graphics.DrawPath(new Pen(Color.Red, 10), graphicsPath);
image.Save("BottleWithRedBorder.tif");
}
Create Path Resources using Graphics Path.
static void Main(string[] args)
{
using (var image = (TiffImage)Image.Load("Bottle.tif"))
{
var figure = new Figure();
figure.AddShape(CreateBezierShape(100f, 100f, 500f, 100f, 500f, 1000f, 100f, 1000f));
var graphicsPath = new GraphicsPath();
graphicsPath.AddFigure(figure);
var pathResouze = PathResourceConverter.FromGraphicsPath(graphicsPath, image.Size);
image.ActiveFrame.PathResources = new List<PathResource>(pathResouze);
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 < coordinates.Length; coordinateIndex += 2)
for (var index = 0; index < 3; index++)
yield return new PointF(coordinates[coordinateIndex], coordinates[coordinateIndex + 1]);
}
Methods
FromGraphicsPath(GraphicsPath, Size)
Converts the Aspose.Imaging.GraphicsPath instance to path resources.
public static PathResource[] FromGraphicsPath(GraphicsPath graphicsPath, Size imageSize)
{
}
Here's the reformatted version of your code:
public static PathResource[] FromGraphicsPath(GraphicsPath graphicsPath, Size imageSize)
{
}
As you can see, I have maintained proper indentation, spacing, and general readability improvements as per the given instructions.
Parameters
graphicsPath
GraphicsPath
The graphics path.
imageSize
Size
Size of the image.
Returns
PathResource []
The path resources.
Exceptions
graphicsPath’ is null.
ToGraphicsPath(PathResource[], Size)
Converts path resources to the Aspose.Imaging.GraphicsPath instance.
public static GraphicsPath ToGraphicsPath(
PathResource[] pathResources,
Size imageSize)
{
GraphicsPath graphicsPath = new GraphicsPath();
foreach (var pathResource in pathResources)
{
}
return graphicsPath;
}
Parameters
pathResources
PathResource
[]
The path resources.
imageSize
Size
Size of the image.
Returns
The Aspose.Imaging.GraphicsPath instance.
Exceptions
pathResources’ is null.