Hi,
I’m trying to export powerpoint slide as image using Aspose.Slides for .NET (version 17.1.0.0).
Firstly, I tried to get the image with the following code:
private Image GetSlideImage(ISlide slide, float scaleX, float scaleY)
{
var slideImage = slide.GetThumbnail(scaleX, scaleY);
return slideImage;
}
but the image quality is really bed. Please see attached image “Aspose thumbnail.png” (logo on the right bottom corner)
Then, I tried to set resolution and set some more properties for quality:
private Image GetSlideImage(ISlide slide, Size size)
{
var scale = 1f;
if (size.Width > 0)
scale = size.Width / slide.Presentation.SlideSize.Size.Width;
var thumbnail = slide.GetThumbnail(scale, scale);
var image = ResetResoulution(thumbnail, 300);
var mfImage = resizeImage(image, new Size(size.Width, size.Height));
return mfImage;
}
private Image ResetResoulution(Bitmap thumbnail, float resolution)
{
int width1 = (int)(thumbnail.Width * resolution / thumbnail.HorizontalResolution);
int height1 = (int)(thumbnail.Height * resolution / thumbnail.VerticalResolution);
Bitmap bmp = new Bitmap(width1, height1);
bmp.SetResolution(resolution, resolution);
using (Graphics g = Graphics.FromImage(bmp))
{
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.CompositingQuality = CompositingQuality.HighQuality;
g.DrawImage(thumbnail, Point.Empty);
}
return bmp;
}
private static Image resizeImage(Image imgToResize, Size size)
{
var scaledBitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(scaledBitmap))
{
var attr = new ImageAttributes();
attr.SetWrapMode(WrapMode.TileFlipXY);
g.CompositingQuality = CompositingQuality.HighQuality;
g.CompositingMode = CompositingMode.SourceCopy;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.DrawImage(imgToResize, new Rectangle(0, 0, size.Width, size.Height), 0, 0, imgToResize.Width, imgToResize.Height, GraphicsUnit.Pixel, attr);
}
return scaledBitmap;
}
But I get the same quality as previously. No changes.
Any advice on how the quality can be improved?
P.S I also attached the presentation I was trying with.
Looking forward for solution.
Regards,
Aleksandra