I have a .NET app that returns a photo by passing url parameters to a page such as:
/getfile.aspx?photo=dog
This page returns a .png image file format by writing it to the HTTP response stream. Works fine using a browser to navigate to the URL, but doesn’t seem to work as a valid URL for my roSlideShow object. I’ve tried:
Thank you for your reply. Yes, I’m placing my image into a MemoryStream and then writing it to the HTTP response using BinaryWrite(). Here’s more of my code, so you can see what I’m doing. Again, if I use a browser to navigate to the URL, I get a valid .png image. If I use this same URL for my roSlideShow photo, no image is rendered.
MemoryStream ms = new MemoryStream();
imgResult.Save(ms, ImageFormat.Png); //imgResult is a System.Drawing.Bitmap
I tried saving the image to the file system, then using Response.Redirect() to point to the file. I’ve also tried Server.Transfer() to point to the file. Again, all of these methods work fine just using a web browser and return my .png image. When my brightscript code requests the URL, it apparently tries 3 times because 3 image files are created in the file system; however, the image is never displayed by my roSlideShow object.
get URL? I don’t think I’m using that anywhere. Perhaps that’s what I’m missing? I’m testing with a simple array of 1 associative array item. Here’s a simplified version of my brightscript code:
Function showPageScreen(slideshow As Object) As Integer
contentArray = CreateObject(“roArray”, 10, true)
aa = CreateObject(“roAssociativeArray”)
'aa.Url = “http://www.[mysite].com/myimage.png” ← This works when uncommented (albeit, it takes ~30 seconds to display the image)
aa.Url = “http://www.[mysite].com/getimage.aspx?img=1” ← This is what I’m trying to get to work
contentArray.Push(aa)
slideshow.SetContentList(contentArray)
slideshow.Show()
while true
msg = wait(0, slideshow.GetMessagePort())
if type(msg) = “roSlideShowEvent” then
if msg.isScreenClosed() then
return -1
end if
end if
end while
return 0
End Function
What am I missing/doing wrong here? I think if I can get this simple example to work, I’ll be off to the races. Thanks in advance for any other suggestions you can offer,
I think EngoTom was thinking you were retrieving the image via the roUrlTransfer component, which actually offers another possibility. You could use the GetToFile method of the roUrlTransfer component to save the image to a “tmp:/” path, and then set the Url of the slideshow content to that local path. Seems a bit of a long route to take, but it should work if your direct URL doesn’t.
Ok, I experimented with roUrlTransfer a bit, but no luck. So, I tried using the roImageCanvas component - success!! This component will allow me to provide a URL value that doesn’t point directly to a .png file. Hopefully, I’ll be able to do everything I want to do using this component. Thank you for your suggestions and advice!
Glad you found a workaround by using roImageCanvas. I opened a bug against roSlideShow so that it doesn’t require the url to end in .jpg or .png in the future.
Just a thought, but it the URL is required to end in a .jpg or .png, did you try adding a dummy parameter at the end to fool the Roku component?
E.g. if you want
/getfile.aspx?photo=dog
then request
/getfile.aspx?photo=dog&dummy=file.png
As long as your .NET app is lenient towards unknown parameters, and if the Roku component really just cares that the supplied full (GET) URL ends in .png or .jpg, that might work.