I'd like to use a variable to pass an image into my report. Is this possible? I've tried declaring a variable of type object and setting it to the desired image (via a control's ToBitmap() method). That part works fine, but when I try to assign it to the StiImage component in the report (from within the Report.BeginRender), I get an InvalidCast exception. My BeginRender looks like this:
imgSketch.Image = (Image)SketchImage;
What am I doing wrong? Is there an easier way to pass the Image into the report without using a temporary file?
Thanks
David
Passing an Image as a variable
Passing an Image as a variable
You may use the following code:DavidD wrote:I'd like to use a variable to pass an image into my report. Is this possible? I've tried declaring a variable of type object and setting it to the desired image (via a control's ToBitmap() method). That part works fine, but when I try to assign it to the StiImage component in the report (from within the Report.BeginRender), I get an InvalidCast exception. My BeginRender looks like this:
imgSketch.Image = (Image)SketchImage;
What am I doing wrong? Is there an easier way to pass the Image into the report without using a temporary file?
Thanks
David
Code: Select all
StiReport report = new StiReport();
report.Load("D:\\myimage.mrt");
StiImage im = new StiImage();
im.Image = Image.FromFile("d:\\SomeImage.jpg");
report.Compile();
report["MyImage"] = im.Image;
report.Show();
Code: Select all
if (MyImage is StiImage)
Image1.Image = (MyImage as StiImage).Image;
Image1 - StiImage component on Report's page.
But this method does not show images in Designer. It shows only Images in rendered report.
Also you can load image to the StiImage component in the Report's Designer. For this you should select Image property of StiImage component. Then choose path to your image and press ok button and selected image will be stored in report code.
At latest build new Variable.ValueObject property is available.
So in latest build you may use the following code:
Code: Select all
report.Dictionary.Variables["MyImage"].ValueObject = Image.FromFile("d:\\SomeImage.jpg");

Thank you.
Passing an Image as a variable
Latest version contains variables of type Image and very convenient Property Editor for StiImage component. You may specify variable or expression of type Image for the image in it, to load Image in report code in design time, to load Image from DataColumn, File or URL in run time.

Thank you.

Thank you.