Load dynamic image with through handler
-
- Posts: 11
- Joined: Thu Jan 25, 2007 3:30 pm
- Location: Portugal
Load dynamic image with through handler
Hi
I usually use an Image Handler to create thumbnails for my web-sites which works OK.
I am trying to do the same with Stimulreport but it does not work:
Line 181: Dim my_img_1 As StiImage = my_rep.GetComponents()("img_1")
Line 182: my_img_1.Image = "imgHandler.ashx?h=255&w=340&img=app_content_prop_photo/" & my_dtr("PHOTO") & ".jpg"
Line 182 causes the error.
Any ideas?
Thanks, Mike.
BTW Any news on the Express Edition?
I usually use an Image Handler to create thumbnails for my web-sites which works OK.
I am trying to do the same with Stimulreport but it does not work:
Line 181: Dim my_img_1 As StiImage = my_rep.GetComponents()("img_1")
Line 182: my_img_1.Image = "imgHandler.ashx?h=255&w=340&img=app_content_prop_photo/" & my_dtr("PHOTO") & ".jpg"
Line 182 causes the error.
Any ideas?
Thanks, Mike.
BTW Any news on the Express Edition?
Load dynamic image with through handler
Instead of the Image property have you tried the ImageURL property?
-
- Posts: 11
- Joined: Thu Jan 25, 2007 3:30 pm
- Location: Portugal
Load dynamic image with through handler
Thanks, but that would not work since the image is actually hold in memory.Brendan wrote:Instead of the Image property have you tried the ImageURL property?
I also tried ImageToDraw, but to no avail.
Mike
-
- Posts: 11
- Joined: Thu Jan 25, 2007 3:30 pm
- Location: Portugal
Load dynamic image with through handler
Thanks.
I adapted to VB, errors are in bold:
Dim bmp As Image = Nothing
Dim stream As System.IO.FileStream = Nothing
Dim fileName As String = "imgHandler.ashx?h=255&w=340&img=app_content_prop_photo/" & my_dtr("PHOTO") & ".jpg"
Try
stream = New System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim buf As Byte() = New Byte(stream.Length) {}
stream.Read(buf, 0, buf.Length)
bmp = Image.FromStream(New System.IO.MemoryStream(buf))
Catch
Finally
If Not stream Is Nothing Then
stream.Close()
End If
End Try
Image1.Image = bmp
Any ideas?
BTW the report is compiled as an dll.
Mike
I adapted to VB, errors are in bold:
Dim bmp As Image = Nothing
Dim stream As System.IO.FileStream = Nothing
Dim fileName As String = "imgHandler.ashx?h=255&w=340&img=app_content_prop_photo/" & my_dtr("PHOTO") & ".jpg"
Try
stream = New System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim buf As Byte() = New Byte(stream.Length) {}
stream.Read(buf, 0, buf.Length)
bmp = Image.FromStream(New System.IO.MemoryStream(buf))
Catch
Finally
If Not stream Is Nothing Then
stream.Close()
End If
End Try
Image1.Image = bmp
Any ideas?
BTW the report is compiled as an dll.
Mike
Load dynamic image with through handler
Please modify the code as follows:algarveweb wrote:Thanks.
I adapted to VB, errors are in bold:
Dim bmp As Image = Nothing
Dim stream As System.IO.FileStream = Nothing
Dim fileName As String = "imgHandler.ashx?h=255&w=340&img=app_content_prop_photo/" & my_dtr("PHOTO") & ".jpg"
Try
stream = New System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim buf As Byte() = New Byte(stream.Length-1) {}
stream.Read(buf, 0, buf.Length)
bmp = Image.FromStream(New System.IO.MemoryStream(buf))
Catch
Finally
If Not stream Is Nothing Then
stream.Close()
End If
End Try
Image1.Image = bmp
Also please check that the fileName contains correct link to the image file.
Thank you.
-
- Posts: 11
- Joined: Thu Jan 25, 2007 3:30 pm
- Location: Portugal
Load dynamic image with through handler
Thanks, but the what is Image.FromStream and Image1 which are the errors?
Mike


Mike


Load dynamic image with through handler
Image1 - it is a StiImage component inside the report page.
Image - it is a .Net class in a namespace Image.Drawing
Please check the path to the images. Is it correct?
Thank you.
Image - it is a .Net class in a namespace Image.Drawing
Please check the path to the images. Is it correct?
Thank you.
-
- Posts: 11
- Joined: Thu Jan 25, 2007 3:30 pm
- Location: Portugal
Load dynamic image with through handler
Thanks, the report opens now (directly in PDF) but the Images are empty:
http://www.mod.algarveweb.com/expose_dll.aspx
The filename is correct since it shows in normal web-forms.
Here is my update code:
Dim bmp As System.Drawing.Image = Nothing
Dim stream As System.IO.FileStream = Nothing
Dim fileName As String = "imgHandler.ashx?h=255&w=340&img=app_content_prop_photo/" & my_dtr("PHOTO") & ".jpg"
Try
stream = New System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim buf As Byte() = New Byte(stream.Length - 1) {}
stream.Read(buf, 0, buf.Length)
bmp = System.Drawing.Image.FromStream(New System.IO.MemoryStream(buf))
Catch
Finally
If Not stream Is Nothing Then
stream.Close()
End If
End Try
Dim my_img_1 As StiImage = CType(my_rep.GetComponents()("img_1"), StiImage)
my_img_1.Image = bmp
Please advice, thanks, Mike.
http://www.mod.algarveweb.com/expose_dll.aspx
The filename is correct since it shows in normal web-forms.
Here is my update code:
Dim bmp As System.Drawing.Image = Nothing
Dim stream As System.IO.FileStream = Nothing
Dim fileName As String = "imgHandler.ashx?h=255&w=340&img=app_content_prop_photo/" & my_dtr("PHOTO") & ".jpg"
Try
stream = New System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim buf As Byte() = New Byte(stream.Length - 1) {}
stream.Read(buf, 0, buf.Length)
bmp = System.Drawing.Image.FromStream(New System.IO.MemoryStream(buf))
Catch
Finally
If Not stream Is Nothing Then
stream.Close()
End If
End Try
Dim my_img_1 As StiImage = CType(my_rep.GetComponents()("img_1"), StiImage)
my_img_1.Image = bmp
Please advice, thanks, Mike.
Load dynamic image with through handler
Loading image from URL into stream not always possible.
So please load images via the following static (sharing) method:
Thank you.
So please load images via the following static (sharing) method:
Code: Select all
Stimulsoft.Base.Drawing.StiImageFromURL.LoadBitmap(ByVal url As String)