Completed
Last Updated: 31 Jan 2019 11:16 by ADMIN
Don
Created on: 15 Jan 2019 11:01
Category: UI for WinForms
Type: Bug Report
1
FIX. RadPdfViewer - incorrect page export to an image with aspect ratio less than 1
How to reproduce: 
float ratio = .5f;
private void radButton1_Click(object sender, EventArgs e)
{
    float ratio = .5f;
    this.radPdfViewer1.ExportPage(1, @"..\..\img.jpeg", ratio, true, ImageFormat.Png);
}

Workaround: change the resolution of the document after exporting it with a ratio = 1
private void radButton1_Click(object sender, EventArgs e)
{
    float ratio = .5f;
    Bitmap bmp = this.radPdfViewer1.ExportPage(1, 1, true, ImageFormat.Png);
    Bitmap resizedImage = this.ResizeImage(bmp, (int)(bmp.Width * ratio), (int)(bmp.Height * ratio));
    resizedImage.Save(@"..\..\img2.jpeg");
}

public Bitmap ResizeImage(Image image, int width, int height)
{
    Rectangle destRect = new Rectangle(0, 0, width, height);
    Bitmap destImage = new Bitmap(width, height);
    destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);

    using (var graphics = Graphics.FromImage(destImage))
    {
        graphics.CompositingMode = CompositingMode.SourceCopy;
        graphics.CompositingQuality = CompositingQuality.HighQuality;
        graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
        graphics.SmoothingMode = SmoothingMode.HighQuality;
        graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

        using (var wrapMode = new ImageAttributes())
        {
            wrapMode.SetWrapMode(WrapMode.TileFlipXY);
            graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
        }
    }

    return destImage;
}
1 comment
ADMIN
Dimitar
Posted on: 31 Jan 2019 11:16
Hello,

A fix will be available in Telerik UI for WinForms version R1 2019 SP1.

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.