How can I change my application Images?

Сonversation on different topics
Post Reply
nathanma
Posts: 7
Joined: Wed Feb 01, 2012 6:10 am

How can I change my application Images?

Post by nathanma »

Hi,

(VS2010 c# .NET 4 for Winfrom)

I know how to change the text from my application, Frist I create new variable of string from Dictionary, then I can change it with my application.

Stimulsoft.Report.StiReport rep = new Stimulsoft.Report.StiReport();
rep.Load("report.mrt");
rep.Compile();
rep["Name"] = "Nathan";
rep["Age"] = "23";
...

So it is OK.

But I want to change images from my application or from file, I made a image component from Stimulsoft Designer Tools, Then made image variable named MyImage. So ImageData is {MyImage}, Edit Variable: Name:MyImage, Alias:MyImage,Type:image,value.

Then my code is,

Stimulsoft.Report.StiReport rep = new Stimulsoft.Report.StiReport();
rep.Load("report.mrt");
rep.Compile();
rep["Name"] = "Nathan";
rep["Age"] = "23";
StiImage image = new StiImage();
image.Image = Image.FromFile("pic01.jpg"); //the path of the image is correct;
rep["MyImage"] = image; //Wrong here;
stiViewerControl1.Report = rep;
rep.Render();

Or

Stimulsoft.Report.StiReport rep = new Stimulsoft.Report.StiReport();
rep.Load("report.mrt");
StiImage image = new StiImage();
image.Image = Image.FromFile("pic01.jpg"); //the path of the image is correct;
rep.Compile();
rep["MyImage"] = image; //Wrong here;
rep.Show();


I compile both my code, there are wrong, rep["MyImage"] = image; "Stimulsoft.Report.Components.StiImage" object can not change to "System.Drawing.Image".

So, please help me, thanks.
nathanma
Posts: 7
Joined: Wed Feb 01, 2012 6:10 am

How can I change my application Images?

Post by nathanma »

I solved this problem,

Stimulsoft.Report.StiReport rep = new Stimulsoft.Report.StiReport();
rep.Load("report.mrt");
rep.Compile();
System.Drawing.Image img = System.Drawing.Image.FromFile("pic01.jpg");
rep["MyImage"] = img; //It is ok now.

stiViewerControl1.Report = rep;
rep.Render();


But I still don't understand. Why can't I use StiImage image = new StiImage(); image.Image = Image.FromFile("pic01.jpg"); ?
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

How can I change my application Images?

Post by HighAley »

Hello.
nathanma wrote:But I still don't understand. Why can't I use StiImage image = new StiImage(); image.Image = Image.FromFile("pic01.jpg"); ?
If you'd look in our Class Reference you'll see that StiImage.Image Property is a System.Drawing.Image type.
Therefore you previous code didn't work properly.

Thank you.
Post Reply