Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
440
Images In Documents
posted

Hi

I have been reading the documantation on how to add images to an Infragistics.Document - seems basically straight forwards, but...

How do I read the image from a file (or maybe from an UltraPictureBox.Image), resize in memory, and place on the document?

Thanks for your help

Parents
  • 37774
    Verified Answer
    posted

    You could read in the image as a bitmap (the constructor has an overload that takes a file name), then draw that image into a new Bitmap:

    public Bitmap ResizeBitmap(Bitmap b, int nWidth, int nHeight)
    {
        Bitmap result = new Bitmap(nWidth, nHeight);
        using (Graphics g = Graphics.FromImage((Image)result))
            g.DrawImage(b, 0, 0, nWidth, nHeight);
        return result;
    }

    You would then add it to the document through whichever element you're using, such as:

    section.AddImage(new Infragistics.Documents.Graphics.Image(bmp));

    -Matt

Reply Children
No Data