WmfRecorderGraphics2D
Contenuti
[
Nascondere
]Inheritance: java.lang.Object, com.aspose.imaging.fileformats.emf.graphics.MetafileRecorderGraphics2D
public final class WmfRecorderGraphics2D extends MetafileRecorderGraphics2D
Il registratore Wmf.
Costruttori
| Costruttore | Descrizione |
|---|---|
| WmfRecorderGraphics2D(Rectangle frame, int inch) | Inizializza una nuova istanza della classe WmfRecorderGraphics2D. |
Metodi
| Metodo | Descrizione |
|---|---|
| getBackgroundMode() | Ottiene o imposta la modalità di sfondo. |
| setBackgroundMode(int value) | Ottiene o imposta la modalità di sfondo. |
| endRecording() | Termina la registrazione. |
| fromWmfImage(WmfImage wmfImage) | Ottiene un’istanza del registratore Wmf per l’immagine Wmf esistente. |
Example: This example shows how to create a WMF image and draw some geometric shapes using WmfRecorderGraphics2D.
String dir = "c:\\temp\\";
int imageWidth = 600;
int imageHeight = 400;
// Questa è la risoluzione dello schermo predefinita.
int dpi = 96;
com.aspose.imaging.Rectangle frame = new com.aspose.imaging.Rectangle(0, 0, imageWidth, imageHeight);
// Crea un'immagine WMF.
com.aspose.imaging.fileformats.wmf.graphics.WmfRecorderGraphics2D graphics =
new com.aspose.imaging.fileformats.wmf.graphics.WmfRecorderGraphics2D(frame, dpi);
// Disegna un rettangolo nero lungo i bordi dell'immagine usando una penna nera larga 1 pixel.
graphics.drawRectangle(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 1), 0, 0, imageWidth, imageHeight);
// Riempi un rettangolo con il colore white-smoke.
graphics.fillRectangle(
new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getWhiteSmoke()),
new com.aspose.imaging.Rectangle(10, 10, 580, 380));
// Disegna due linee diagonali usando una penna darkgreen larga 1 pixel.
graphics.drawLine(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getDarkGreen(), 1), 0, 0, imageWidth, imageHeight);
graphics.drawLine(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getDarkGreen(), 1), 0, imageHeight, imageWidth, 0);
// Disegna un arco all'interno del rettangolo {0, 0, 200, 200} usando una penna blu larga 2 pixel.
graphics.drawArc(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlue(), 2), new com.aspose.imaging.Rectangle(0, 0, 200, 200), 90, 270);
// Riempi un arco
graphics.fillPie(
new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getLightSkyBlue()),
new com.aspose.imaging.Rectangle(0, 0, 150, 150), 90, 270);
// Disegna un bezier cubico usando una penna rossa larga 2 pixel.
graphics.drawCubicBezier(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2),
new com.aspose.imaging.Point(0, 0),
new com.aspose.imaging.Point(200, 133),
new com.aspose.imaging.Point(400, 166),
new com.aspose.imaging.Point(600, 400));
// Disegna un'immagine raster della dimensione specificata nella posizione specificata.
// L'immagine è scalata per adattarsi al rettangolo desiderato.
com.aspose.imaging.RasterImage imageToDraw = (com.aspose.imaging.RasterImage) com.aspose.imaging.Image.load(dir + "sample.bmp");
{
graphics.drawImage(imageToDraw,
new com.aspose.imaging.Rectangle(400, 200, 100, 50),
new com.aspose.imaging.Rectangle(0, 0, imageWidth, imageHeight),
com.aspose.imaging.GraphicsUnit.Pixel);
}
// Disegna una stringa di testo
graphics.drawString("Hello World!", new com.aspose.imaging.Font("Arial", 48, com.aspose.imaging.FontStyle.Regular), com.aspose.imaging.Color.getDarkRed(), 200, 300);
// Crea un percorso da riempire
com.aspose.imaging.Figure figureToFill = new com.aspose.imaging.Figure();
figureToFill.setClosed(true);
com.aspose.imaging.GraphicsPath pathToFill = new com.aspose.imaging.GraphicsPath();
pathToFill.addFigure(figureToFill);
figureToFill.addShapes(new com.aspose.imaging.Shape[]
{
new com.aspose.imaging.shapes.ArcShape(new com.aspose.imaging.RectangleF(400, 0, 200, 100), 45, 300),
new com.aspose.imaging.shapes.BezierShape(
new com.aspose.imaging.PointF[]
{
new com.aspose.imaging.PointF(300, 200),
new com.aspose.imaging.PointF(400, 200),
new com.aspose.imaging.PointF(500, 100),
new com.aspose.imaging.PointF(600, 200),
}),
new com.aspose.imaging.shapes.PolygonShape(
new com.aspose.imaging.PointF[]
{
new com.aspose.imaging.PointF(300, 100),
}),
new com.aspose.imaging.shapes.RectangleShape(new com.aspose.imaging.RectangleF(0, 100, 200, 200)),
});
// Riempi il percorso usando un pennello giallo e una penna verde per disegnare il contorno
graphics.fillPath(
new com.aspose.imaging.Pen(com.aspose.imaging.Color.getGreen(), 2),
new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getYellow()), pathToFill);
// Crea un percorso da disegnare
com.aspose.imaging.GraphicsPath pathToDraw = new com.aspose.imaging.GraphicsPath();
com.aspose.imaging.Figure figureToDraw = new com.aspose.imaging.Figure();
pathToDraw.addFigure(figureToDraw);
figureToDraw.addShapes(new com.aspose.imaging.Shape[]
{
new com.aspose.imaging.shapes.ArcShape(new com.aspose.imaging.RectangleF(200, 200, 200, 200), 0, 360),
});
// Disegna il percorso usando una penna arancione larga 5 pixel.
graphics.drawPath(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getOrange(), 5), pathToDraw);
// Per rasterizzare SVG è necessario specificare le opzioni di rasterizzazione.
com.aspose.imaging.imageoptions.SvgRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.SvgRasterizationOptions();
com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions();
saveOptions.setVectorRasterizationOptions(rasterizationOptions);
// Ottieni l'immagine WMF finale che include tutti i comandi di disegno
com.aspose.imaging.fileformats.wmf.WmfImage wmfImage = graphics.endRecording();
try {
wmfImage.save(dir + "test.output.wmf");
} finally {
wmfImage.dispose();
}
WmfRecorderGraphics2D(Rectangle frame, int inch)
public WmfRecorderGraphics2D(Rectangle frame, int inch)
Inizializza una nuova istanza della classe WmfRecorderGraphics2D.
Parameters:
| Parametro | Tipo | Descrizione |
|---|---|---|
| frame | Rectangle | Rettangolo di destinazione, misurato in twip, per la visualizzazione del metafile. |
| pollice | int | Il numero di pixel per pollice. |
getBackgroundMode()
public int getBackgroundMode()
Ottiene o imposta la modalità di sfondo.
Valore: La modalità di sfondo.
Returns: int
setBackgroundMode(int value)
public void setBackgroundMode(int value)
Ottiene o imposta la modalità di sfondo.
Valore: La modalità di sfondo.
Parameters:
| Parametro | Tipo | Descrizione |
|---|---|---|
| valore | int |
endRecording()
public WmfImage endRecording()
Termina la registrazione.
Returns: WmfImage - The result image.
fromWmfImage(WmfImage wmfImage)
public static WmfRecorderGraphics2D fromWmfImage(WmfImage wmfImage)
Ottiene un’istanza del registratore Wmf per l’immagine Wmf esistente.
Parameters:
| Parametro | Tipo | Descrizione |
|---|---|---|
| wmfImage | WmfImage | L’immagine Wmf per cui ottenere un registratore. |
Returns: WmfRecorderGraphics2D - An instance of the WmfRecorderGraphics2D class.