public static IEnumerable <Bitmap> ToBitmap(string filename, Parameters parameters) { using (var xpsConverter = new Xps2Image(filename)) { return(xpsConverter.ToBitmap(parameters).ToList()); } }
public static IEnumerable <Bitmap> ToBitmap(Stream stream, Parameters parameters) { using (var xpsConverter = new Xps2Image(stream)) { return(xpsConverter.ToBitmap(parameters).ToList()); } }
public static IEnumerable<Bitmap> ToBitmap(string filename, Parameters parameters) { using (var xpsConverter = new Xps2Image(filename)) { return xpsConverter.ToBitmap(parameters).ToList(); } }
public static IEnumerable <Bitmap> ToBitmap(byte[] byteArray, Parameters parameters) { using (var xpsConverter = new Xps2Image(byteArray)) { return(xpsConverter.ToBitmap(parameters).ToList()); } }
private static int Main(string[] args) { if (args.Length > 0) { for (int i = 0; i < args.Length; i++) { if (File.Exists(args[i])) { string filename = Path.GetFileNameWithoutExtension(args[i]); string extension = Path.GetExtension(args[i]); if (extension == ".xps") { using (var xpsConverter = new Xps2Image(args[i])) { var images = xpsConverter.ToBitmap(new Parameters { ImageType = ImageType.Png, Dpi = 300 }); int index = 1; foreach (var image in images) { image.Save(filename + index.ToString() + ".jpg", ImageFormat.Jpeg); index++; } } } } } } return(0); }
public static IEnumerable <Bitmap> ToBitmap(IEnumerable <byte[]> byteArrays, Parameters parameters) { foreach (var byteArray in byteArrays) { using (var xpsConverter = new Xps2Image(byteArray)) { return(xpsConverter.ToBitmap(parameters).ToList()); } } return(new List <Bitmap>()); }
public static IEnumerable <Bitmap> ToBitmap(IEnumerable <Stream> streams, Parameters parameters) { foreach (var stream in streams) { using (var xpsConverter = new Xps2Image(stream)) { return(xpsConverter.ToBitmap(parameters).ToList()); } } return(new List <Bitmap>()); }
public static IEnumerable <Bitmap> ToBitmap(IEnumerable <string> filenames, Parameters parameters) { foreach (var filename in filenames) { using (var xpsConverter = new Xps2Image(filename)) { return(xpsConverter.ToBitmap(parameters).ToList()); } } return(new List <Bitmap>()); }
public static IEnumerable<Bitmap> ToBitmap(Stream stream, Parameters parameters) { using (var xpsConverter = new Xps2Image(stream)) { return xpsConverter.ToBitmap(parameters).ToList(); } }
public static IEnumerable<Bitmap> ToBitmap(byte[] byteArray, Parameters parameters) { using (var xpsConverter = new Xps2Image(byteArray)) { return xpsConverter.ToBitmap(parameters).ToList(); } }
public static IEnumerable<Bitmap> ToBitmap(IEnumerable<byte[]> byteArrays, Parameters parameters) { foreach (var byteArray in byteArrays) { using (var xpsConverter = new Xps2Image(byteArray)) { return xpsConverter.ToBitmap(parameters).ToList(); } } return new List<Bitmap>(); }
public static IEnumerable<Bitmap> ToBitmap(IEnumerable<Stream> streams, Parameters parameters) { foreach (var stream in streams) { using (var xpsConverter = new Xps2Image(stream)) { return xpsConverter.ToBitmap(parameters).ToList(); } } return new List<Bitmap>(); }
public static IEnumerable<Bitmap> ToBitmap(IEnumerable<string> filenames, Parameters parameters) { foreach (var filename in filenames) { using (var xpsConverter = new Xps2Image(filename)) { return xpsConverter.ToBitmap(parameters).ToList(); } } return new List<Bitmap>(); }
public static IEnumerable <Bitmap> Convert(byte[] fileData, int?width, int?height, int?dpi, int quality = 85) { using (var xpsConverter = new Xps2Image(fileData)) { var pageSizeRatio = xpsConverter.PageSize.Width / xpsConverter.PageSize.Height; Size?size; if (width.HasValue || height.HasValue) { int newWidth = 0; int newHeight = 0; if (!(width.HasValue && height.HasValue)) { newWidth = width.HasValue ? width.Value : (int)(height.Value * pageSizeRatio); newHeight = height.HasValue ? height.Value : (int)(width.Value / pageSizeRatio); size = new Size(newWidth, newHeight); } else { size = new Size(width.Value, height.Value); } } else { size = new Size?(); } Parameters parameters = new xps2img.Parameters { ImageOptions = new ImageOptions(quality, TiffCompressOption.Zip), Dpi = dpi.HasValue ? dpi.Value : 300, ImageType = ImageType.Jpeg, RequiredSize = size }; var images = xpsConverter.ToBitmap(parameters); return(images); } // Convert a xps document to png from disk // // using (var xpsConverter = new Xps2Image("multipage.xps")) // { // var images = xpsConverter.ToBitmap(new Parameters // { // ImageType = ImageType.Png, // Dpi = 300 // }); // } // Convert a xps document to png from a byte array // // using (var xpsConverter = new Xps2Image(File.ReadAllBytes("multipage.xps"))) // { // var images = xpsConverter.ToBitmap(new Parameters // { // ImageType = ImageType.Png, // Dpi = 300 // }); // } // Convert a xps document to png from stream // // using (var xpsConverter = new Xps2Image(new MemoryStream(File.ReadAllBytes("multipage.xps")))) // { // var images = xpsConverter.ToBitmap(new Parameters // { // ImageType = ImageType.Png, // Dpi = 300 // }); // } }