PathResourceConverter

Inheritance: java.lang.Object

public final class PathResourceConverter

PathResource öğesini GraphicsPath öğesine dönüştürür ve tersine.

Yöntemler

YöntemAçıklama
toGraphicsPath(PathResource[] pathResources, Size imageSize)Yol kaynaklarını GraphicsPath örneğine dönüştürür.
fromGraphicsPath(GraphicsPath graphicsPath, Size imageSize)GraphicsPath örneğini yol kaynaklarına dönüştürür.

Example: Create Graphics Path from Path Resources in TIFF image.

try (TiffImage image = (TiffImage)Image.load("Bottle.tif"))
{
    // TIFF görüntüsünden PathResources kullanarak GraphicsPath oluşturun
    GraphicsPath graphicsPath = PathResourceConverter.toGraphicsPath(
            image.getActiveFrame().getPathResources().toArray(new PathResource[0]), 
            image.getActiveFrame().getSize());
    Graphics graphics = new Graphics(image);

    // Kırmızı bir çizgi çizin ve görüntüyü kaydedin
    graphics.drawPath(new Pen(Color.getRed(), 10), graphicsPath);
    image.save("BottleWithRedBorder.tif");
}

Example: Create Path Resources using Graphics Path.

static void main()
{
    try (TiffImage image = (TiffImage)Image.load("Bottle.tif"))
    {
        // GraphicsPath için dikdörtgen Figure oluşturun
        Figure figure = new Figure();
        figure.addShape(createBezierShape(100f, 100f, 500f, 100f, 500f, 1000f, 100f, 1000f));

        // Figure'ımızı kullanarak GraphicsPath oluşturun
        GraphicsPath graphicsPath = new GraphicsPath();
        graphicsPath.addFigure(figure);

        // GraphicsPath kullanarak PathResources ayarlayın
        PathResource[] pathResource = PathResourceConverter.fromGraphicsPath(graphicsPath, image.getSize());
        image.getActiveFrame().setPathResources(Arrays.asList(pathResource));

        // Görüntüyü kaydedin
        image.save("BottleWithRectanglePath.tif");
    }
}

private static BezierShape createBezierShape(float ... coordinates)
{
    PointF[] bezierPoints = coordinatesToBezierPoints(coordinates);
    return new BezierShape(bezierPoints, true);
}

private static PointF[] coordinatesToBezierPoints(float[] coordinates)
{
    PointF[] bezierPoints = new PointF[3 * coordinates.length / 2];
    int i = 0;
    for (int coordinateIndex = 0; coordinateIndex < coordinates.length - 1; coordinateIndex += 2)
        for (int index = 0; index < 3; index++)
        {
            bezierPoints[i++] = new PointF(coordinates[coordinateIndex], coordinates[coordinateIndex + 1]);
        }
                
    return bezierPoints;
}

toGraphicsPath(PathResource[] pathResources, Size imageSize)

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

Yol kaynaklarını GraphicsPath örneğine dönüştürür.

Parameters:

ParametreTürAçıklama
pathResourcesPathResource[]Yol kaynakları.
imageSizeSizeGörüntünün boyutu.

Returns: GraphicsPath - The GraphicsPath instance.

fromGraphicsPath(GraphicsPath graphicsPath, Size imageSize)

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

GraphicsPath örneğini yol kaynaklarına dönüştürür.

Parameters:

ParametreTürAçıklama
graphicsPathGraphicsPathGrafik yolu.
imageSizeSizeGörüntünün boyutu.

Returns: com.aspose.imaging.fileformats.tiff.pathresources.PathResource[] - Yol kaynakları.