locked
Dynamically loading images in Crystal Report RRS feed

  • Question

  • User768014394 posted

    We have several Crystal Reports with images that need to be loaded dynamically.  There are blank image controls in the report and I need to load an image when the report is populated.

    Is there a way to load an image in crystal report dynamically without having the image be part of the bound data?  If so, can I do it programmatically without having to modify the report in the RDC?

    Wednesday, December 7, 2011 6:46 PM

All replies

  • User-2001765250 posted

    Image in crystal report can be loaded by defining columns data type to image.

    Ex: CompanyMaster having a column Logo then column data type of Logo column is of Image type.

    At time of Inserting and Updating save it to image type in database.

    Because of this you can directly drag and drop image on the report as you are doing for the other columns.

    Refer the following link for converting Image toCommon Format (Here is Bitmap Format) 

    http://www.eggheadcafe.com/community/csharp/2/10119558/converting-binary-image-to-bitmap-image.aspx

    Here is another function to to it :

    public byte[] ConvertTobyteArray(Bitmap value)
    {
    byte[] bitmapbytes = new byte[5000];
    MemoryStream stream;//= new MemoryStream ();
    using (stream = new MemoryStream())
    {
    value.Save(stream, value.RawFormat);
    bitmapbytes = stream.ToArray();
    }
    return bitmapbytes;
    }


    public Bitmap ConvertToBitmapImage(byte[] image)
    {
    MemoryStream memStream = new MemoryStream(image, false);
    Bitmap bitImage = new Bitmap(System.Drawing.Image.FromStream(memStream));
    bitImage.Save(Application.StartupPath + "\\NoPhoto.bmp");
    return bitImage;
    }
    Wednesday, December 14, 2011 2:37 AM