|
| 1 | +package com.aspose.imaging.examples.SVG; |
| 2 | + |
| 3 | +import com.aspose.imaging.*; |
| 4 | +import com.aspose.imaging.brushes.SolidBrush; |
| 5 | +import com.aspose.imaging.examples.Logger; |
| 6 | +import com.aspose.imaging.examples.Utils; |
| 7 | +import com.aspose.imaging.fileformats.svg.SvgImage; |
| 8 | + |
| 9 | +public class CommonGraphicsEngineForSvgEmfWmf |
| 10 | +{ |
| 11 | + public static void main(String[] args) |
| 12 | + { |
| 13 | + Logger.startExample("SVGToBMPConversion"); |
| 14 | + |
| 15 | + String dataDir = Utils.getOutDir(); |
| 16 | + |
| 17 | + String filePath = dataDir + "test.svg"; |
| 18 | + |
| 19 | + try (VectorImage vectorImage = new SvgImage(100, 100)) |
| 20 | + { |
| 21 | + Graphics g = new Graphics(vectorImage); |
| 22 | + g.fillRectangle(new SolidBrush(Color.getLightYellow()), 10, 10, 80, 80); |
| 23 | + g.drawRectangle(new Pen(Color.getRed(), 4), 10, 10, 80, 80); |
| 24 | + g.fillEllipse(new SolidBrush(Color.getLightGreen()), 20, 20, 60, 60); |
| 25 | + g.drawEllipse(new Pen(Color.getGreen(), 2), 20, 20, 60, 60); |
| 26 | + g.fillPie(new SolidBrush(Color.getLightBlue()), new Rectangle(30, 30, 40, 40), 0, 45); |
| 27 | + g.drawPie(new Pen(Color.getBlue(), 1), new Rectangle(30, 30, 40, 40), 0, 45); |
| 28 | + g.drawLine(new Pen(Color.getDarkRed(), 1), 10, 20, 90, 20); |
| 29 | + g.drawLines(new Pen(Color.getDarkRed(), 1), new PointF[] { new PointF(10, 90), new PointF(20, 80), new PointF(30, 90) }); |
| 30 | + g.drawPolygon(new Pen(Color.getDarkRed(), 1), new PointF[] { new PointF(90, 90), new PointF(80, 80), new PointF(70, 90) }); |
| 31 | + g.drawString("Hello World!", new Font("Arial", 14), new SolidBrush(Color.getDarkBlue()), new PointF(10, 50)); |
| 32 | + g.drawArc(new Pen(Color.getBrown(), 1), new Rectangle(30, 30, 40, 40), 135, -90); |
| 33 | + vectorImage.save(filePath); |
| 34 | + } |
| 35 | + |
| 36 | + Utils.deleteFile(filePath); |
| 37 | + |
| 38 | + Logger.endExample(); |
| 39 | + } |
| 40 | +} |
0 commit comments