Con Aspose.Total para .NET puede exportar fácilmente una imagen CGM a APNG dentro de cualquier aplicación .NET en dos sencillos pasos. En primer lugar, al usar Aspose.PDF para .NET , puede exportar CGM a JPEG. Después de eso, al usar Aspose.Imaging for .NET API de procesamiento de imágenes, puede convertir JPEG a APNG.
Convierta el archivo CGM a APNG a través de .NET
- Abra el archivo CGM usando la clase Document
- Inicialice el objeto de clase JpegDevice y renderice CGM a JPEG mediante Process método
- Cargue el archivo JPEG usando la clase Imagen
- Guarde el documento en formato APNG usando el método Save
Requisitos de conversión
Instale desde la línea de comandos como nuget install Aspose.Total
o a través de Package Manager Console de Visual Studio con Install-Package Aspose.Total
.
Como alternativa, obtenga el instalador MSI sin conexión o las DLL en un archivo ZIP desde descargas .
// 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()); |
Convierta un archivo CGM a APNG en un solo archivo a través de C#
Con la API, también puede convertir un archivo CGM a APNG en un solo archivo de imagen. Para convertir todas las páginas, primero puede convertir su documento CGM en un archivo TIFF y luego puede exportar el archivo TIFF a APNG. Puede abrir el archivo de entrada usando la clase Document y crear objetos de dispositivo Resolución, TiffSettings y TIFF. Puede obtener una sola imagen TIFF usando el método Proceso de TiffDevice clase. Finalmente, puede cargar el archivo TIFF usando la clase Imagen y guárdelo en formato APNG usando el método 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()); |
Convertir y rotar archivos CGM a APNG a través de C#
Usando la API, también puede rotar la imagen APNG de salida según sus necesidades. El método Image.RotateFlip se puede usar para rotar la imagen 90/180/270 grados y voltear la imagen horizontal o verticalmente. Puede especificar el tipo de rotación y volteo para aplicar a la imagen. Para rotar y voltear la imagen, puede cargar la imagen JPEG convertida utilizando el método de fábrica expuesto por la clase Imagen y llamar a la clase Imagen .RotateFlip al especificar el 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()); |