Click here to Skip to main content
15,924,367 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am using Solid Framework to convert pdf to image,
so we have one method called " Bitmap bm = page.DrawBitmap(dpi);"
to create the Bitmap image, But i need to resize the image programatically, But this method only return the Default image size, Please help me..
Thanks in advance
Posted

1 solution

You can easily resize the image which you get from page.DrawBitmap(dpi);.
Here is a quick example for you:
C#
public static Bitmap ResizeImage(Image image, int width, int height)
{
    // We will draw resized image on this bitmap
    Bitmap result = new Bitmap(width, height);
    
    // We will use a graphics object to draw the resized image into the bitmap
    using (Graphics graphics = Graphics.FromImage(result))
    {
         // Set the quality modes to high quality.
         // You can change this modes if the speed is more important in your case
         graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality;
         graphics.CompositingQuality = Drawing2D.CompositingQuality.HighQuality;
         graphics.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic;

         // Draw the image into the target bitmap
         graphics.DrawImage(image, 0, 0, result.Width, result.Height);
    }

    // Return the resized bitmap
    return result;
}


Just past the image and desired dimensions(width and height) to this function. It will return a resized image for you. :)

I hope this helps. :)

Regards
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900