URL of image

Stimulsoft Reports.NET discussion
Raul2
Posts: 6
Joined: Mon Jan 04, 2010 3:35 am
Location: Zaragoza (Spain)

URL of image

Post by Raul2 »

Hi from Spain,

I have this url, http://localhost/?id=266&doc=90630&tipo=i, for URL property in a image, but dont show anything at designer or rendered, but if I copy and paste this url in Internet Explorer, it show me the image, open it, no download.
Does designer needs the clean url to image file?

The version is 2009.3

Thanks, regards.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

URL of image

Post by Jan »

Hello Raul,

We use following code to load image from url:

Code: Select all

using System;
using System.Net;
using System.Drawing;
using System.Drawing.Imaging;
using System.ComponentModel;
using System.IO;

public static Image LoadBitmap(string url)
{
	WebClient cl = new WebClient();
	cl.Credentials = CredentialCache.DefaultCredentials;
	byte [] bytes = cl.DownloadData(url);
        cl.Dispose();

	MemoryStream stream = new MemoryStream(bytes);
        return new Bitmap(stream);
}
Try to load your image with help of this method.

Thank you.
Raul2
Posts: 6
Joined: Mon Jan 04, 2010 3:35 am
Location: Zaragoza (Spain)

URL of image

Post by Raul2 »

Hi Jan, thanks for your response.

With the url http://localhost/?id=266&doc=90630&tipo=i as parameter for this method I get a error of "The parameter is not valid." when render. I use this:

Code: Select all

Image2.Image = LoadBitmap("http://localhost/?id=266&doc=90630&tipo=i")
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

URL of image

Post by Edward »

Hi Raúl,

In that case please use absolute or relative URLs for images. Nice example of that:

http://www.aspdotnetfaq.com/Faq/how-to- ... -page.aspx
http://msdn.microsoft.com/en-us/library/ms178116.aspx

Thank you.
Raul2
Posts: 6
Joined: Mon Jan 04, 2010 3:35 am
Location: Zaragoza (Spain)

URL of image

Post by Raul2 »


Thanks for the info.
Raul2
Posts: 6
Joined: Mon Jan 04, 2010 3:35 am
Location: Zaragoza (Spain)

URL of image

Post by Raul2 »

and could be possible something like this?:

Code: Select all

Me.Image1.File = "C:\Images\" + {FILES.FILE_NAME}
or 
Me.Image1.File = "C:\Images\" + {FILES.FILE_NAME} + ".jpg"
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

URL of image

Post by Edward »

Hi,

Yes, that is possible:

string p = "C:\\Images\\" + FILES.FILE_NAME.ToString()+".jpg";

im.Image = Image.FromFile(p);

Thank you.
Raul2
Posts: 6
Joined: Mon Jan 04, 2010 3:35 am
Location: Zaragoza (Spain)

URL of image

Post by Raul2 »

Now I am trying to show some images in a data element with 2 columns. The name of the image files is stored in a field of a table, looking this thread (http://forum.stimulsoft.com/default.aspx?g=posts&t=2857) I try to put in the "Image Data" of the Image1 located in first column in the data element this code:

Code: Select all

{Image.FromFile("C:\Images\" + FILES.FILE_NAME.ToString() + ".jpg"}
but i get error because in the code I have this:

Code: Select all

Public Sub Image1__GetImageData(ByVal sender As Object, ByVal e As Stimulsoft.Report.Events.StiGetImageDataEventArgs)
            e.Value = "{Image.FromFile(""C:\Images\"" + FILES.FILE_NAME.ToString() + "".jpg""}"
End Sub
How I must write it in "Image Data"?

Thanks and sorry for my bad English.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

URL of image

Post by Jan »

Hello,

Please check following:

Code: Select all

Image.FromFile("C:\Images\" + FILES.FILE_NAME.ToString() + ".jpg"
Thank you.
Raul2
Posts: 6
Joined: Mon Jan 04, 2010 3:35 am
Location: Zaragoza (Spain)

URL of image

Post by Raul2 »

I get this now:

Code: Select all

Public Sub Image1__GetImageData(ByVal sender As Object, ByVal e As Stimulsoft.Report.Events.StiGetImageDataEventArgs)
            e.Value = "Image.FromFile(""C:\Images\"" + FILES.FILE_NAME.ToString() + "".jpg"""
End Sub
but I have solved it saving the entire path in the field:

Code: Select all

{Image.FromFile(FILES.ENTIRE_PATH)}
Thanks for help me.
Post Reply