Utilizzando Aspose.Total for .NET puoi facilmente esportare un’immagine CGM in APNG all’interno di qualsiasi applicazione .NET in due semplici passaggi. Innanzitutto, utilizzando Aspose.PDF for .NET , puoi esportare CGM in JPEG. Successivamente, utilizzando l’API di elaborazione delle immagini Aspose.Imaging for .NET , è possibile convertire JPEG in APNG.
Converti file CGM in APNG tramite .NET
- Aprire il file CGM utilizzando la classe Document
- Inizializzare l’oggetto classe JpegDevice ed eseguire il rendering di CGM in JPEG utilizzando Process metodo
- Caricare il file JPEG utilizzando la classe Image
- Salvare il documento in formato APNG utilizzando il metodo Salva
Requisiti di conversione
Installa dalla riga di comando come nuget install Aspose.Total
o tramite Package Manager Console di Visual Studio con Install-Package Aspose.Total
.
In alternativa, scarica il programma di installazione MSI offline o le DLL in un file ZIP da downloads .
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
var document = new Document("input.pdf"); | |
// create an object of jpegDevice | |
var renderer = new JpegDevice(); | |
// convert a particular page and save the image in JPEG format | |
renderer.Process(document.Pages[1], "output.jpeg"); | |
// load JPEG file | |
var image = Image.Load("output.jpeg"); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save JPEG to PSD file format | |
image.Save("output.psd", new PsdOptions()); |
Converti file CGM in APNG in un singolo file tramite C#
Utilizzando l’API, puoi anche convertire il file CGM in APNG in un singolo file immagine. Per convertire tutte le pagine, puoi prima eseguire il rendering del tuo documento CGM in un file TIFF e successivamente puoi esportare il file TIFF in APNG. È possibile aprire il file di input utilizzando la classe Document e creare oggetti dispositivo Resolution, TiffSettings e TIFF. È possibile ottenere una singola immagine TIFF utilizzando il metodo Process di TiffDevice . Infine, puoi caricare il file TIFF usando la classe Image e salvalo in formato APNG usando il metodo Save .
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// Open PDF document | |
Document pdfDocument = new Document("input.pdf"); | |
// Create Resolution object | |
Resolution resolution = new Resolution(300); | |
// Create TiffSettings object | |
TiffSettings tiffSettings = new TiffSettings | |
{ | |
Compression = CompressionType.None, | |
Depth = ColorDepth.Default, | |
Shape = ShapeType.Landscape, | |
SkipBlankPages = false | |
}; | |
// Create TIFF device | |
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings); | |
// Convert a particular page and save the image to stream | |
tiffDevice.Process("output.tif"); | |
// load TIFF file | |
var image = Image.Load("output.tif"); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save TIFF to PSD file format | |
image.Save("output.psd", new PsdOptions()); |
Converti e ruota il file CGM in APNG tramite C#
Utilizzando l’API, puoi anche ruotare l’immagine APNG di output secondo le tue esigenze. Il metodo Image.RotateFlip può essere utilizzato per ruotare l’immagine di 90/180/270 gradi e capovolgere l’immagine orizzontalmente o verticalmente. È possibile specificare il tipo di rotazione e capovolgimento da applicare all’immagine. Per ruotare e capovolgere l’immagine è possibile caricare l’immagine JPEG convertita utilizzando il metodo di fabbrica esposto dalla classe Image e chiamare l’immagine .RotateFlip mentre si specifica l’appropriato RotateFlipType .
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
var document = new Document("input.pdf"); | |
// create an object of jpegDevice | |
var renderer = new JpegDevice(); | |
// convert a particular page and save the image in JPEG format | |
renderer.Process(document.Pages[1], "output.jpeg"); | |
// load JPEG file | |
var image = Image.Load("output.jpeg"); | |
// rotate the image | |
image.RotateFlip(RotateFlipType.Rotate270FlipNone); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save JPEG to PSD file format | |
image.Save("output.psd", new PsdOptions()); |