jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2010
10:55 PM
first attempt at imagecanvas - not working...
So I tried to throw together a little app to plot points on the screen, using 1 pixel .png images, of red green and blue. Not working. Background display is working. Any suggestions as to why nothing is showing up? The idea was to plot a point and leave it up, plot another in 3 colors, just an experiment. Nothing is happening except if I set the background, which I have commented out in case it was overlaying the points. Heres the code, based off a screensaver test TheEndless posted a while back.
sub main()
backgroundHD = {
Color: "#000000",
TargetRect: { x: 0, y: 0, w: 1280, h: 720 }
}
rx=640
ry=360
gx=640
gy=360
bx=640
by=360
gpix={url:"pkg:/green.png"
TargetRect:{x:gx,y:gy,w:10,h:10}}
bpix={url:"pkg:/blue.png"
TargetRect:{x:bx,y:by,w:10,h:10}}
rpix={url:"pkg:/red.png"
TargetRect:{x:rx,y:ry,w:10,h:10}}
port = CreateObject( "roMessagePort" )
canvas = CreateObject( "roImageCanvas" )
canvas.SetMessagePort(port)
canvas.SetRequireAllImagesToDraw( false )
'canvas.SetLayer( 1, backgroundHD)
canvas.Show()
canvas.SetRequireAllImagesToDraw(false)
While true
msg = Wait(10, port )
if Type(msg)="roImageCanvasEvent" then
?msg.GetMessage()
If msg.isRemoteKeyPressed() Then
canvas.Close()
Return
End If
end if
rx=rx+rnd(3)-2
ry=ry+rnd(3)-2
gx=gx+rnd(3)-2
gy=gy+rnd(3)-2
bx=bx+rnd(3)-2
by=by+rnd(3)-2
canvas.SetLayer( 2, gpix)
canvas.SetLayer( 3, bpix)
canvas.SetLayer( 4, rpix)
canvas.show()
?rx,ry,gx,gy,bx,by
End While
End Sub
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
18 REPLIES 18

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2010
11:09 PM
Re: first attempt at imagecanvas - not working...
First problem I see is that you're never updating the TargetRects for your pixel PNGs. rx, ry, gx, gy, bx, and by are all integers, so changing them won't automatically update the TargetRects. You'll need to explicitly update those.
Second, 10 milliseconds is probably too fast for the screen to refresh. I'd try bumping that up to 100 or so until you get the screen drawing correctly.
Otherwise, it looks ok. Are your images actually in the root of your package, or are they in an images subfolder? If in an images subfolder, then your URLs are wrong, which could be your problem.
Second, 10 milliseconds is probably too fast for the screen to refresh. I'd try bumping that up to 100 or so until you get the screen drawing correctly.
Otherwise, it looks ok. Are your images actually in the root of your package, or are they in an images subfolder? If in an images subfolder, then your URLs are wrong, which could be your problem.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2010
11:44 PM
Re: first attempt at imagecanvas - not working...
Yep, you are correct about the path...
So if I use floats instead of integers, it will auto-update?
- Joel
So if I use floats instead of integers, it will auto-update?
- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2010
11:59 PM
Re: first attempt at imagecanvas - not working...
"jbrave" wrote:
Yep, you are correct about the path...
So if I use floats instead of integers, it will auto-update?
- Joel
No, only objects are updated by reference, so you'll need to change the target rects directly:
rx=rx+rnd(3)-2
ry=ry+rnd(3)-2
gx=gx+rnd(3)-2
gy=gy+rnd(3)-2
bx=bx+rnd(3)-2
by=by+rnd(3)-2
rpix.TargetRect.x = rx
rpix.TargetRecy.y = ry
gpix.TargetRect.x = gx
gpix.TargetRect.y = gy
bpix.TargetRect.x = bx
bpix.TargetRect.y = by
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2010
12:36 AM
Re: first attempt at imagecanvas - not working...
interestingly, nothing happened until I added:
to each line
rpix.CompositionMode="Source_Over"
to each line
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
retrotom
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2010
07:29 AM
Re: first attempt at imagecanvas - not working...
"TheEndless" wrote:
First problem I see is that you're never updating the TargetRects for your pixel PNGs. rx, ry, gx, gy, bx, and by are all integers, so changing them won't automatically update the TargetRects. You'll need to explicitly update those.
Second, 10 milliseconds is probably too fast for the screen to refresh. I'd try bumping that up to 100 or so until you get the screen drawing correctly.
Otherwise, it looks ok. Are your images actually in the root of your package, or are they in an images subfolder? If in an images subfolder, then your URLs are wrong, which could be your problem.
I'd like to mirror what TheEndless says about the update frequency. In my testing you can TRY to update at a really high frequency like that -- but nine times out of ten my roku would crash with anything "sizable" being rendered in under 100ms.
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2010
02:45 PM
Re: first attempt at imagecanvas - not working...
I figured out I don't need my 1pix png, I can just set a color for the targetRect and draw a dot or a square with no .png.
Other weird things: drawing to layer 1 2 or 3 results in a moving image. Drawing to layer 0 results in a line that follows the draw position.
Drawing three colors to layer 0 results in only the last draw appearing - unless a delay is put in after each draw. So as both of you mentioned, there is definitely some timing related weirdness. a 15ms wait between each color draw seems to work, don't know what the minimum is yet.
- Joel
Other weird things: drawing to layer 1 2 or 3 results in a moving image. Drawing to layer 0 results in a line that follows the draw position.
Drawing three colors to layer 0 results in only the last draw appearing - unless a delay is put in after each draw. So as both of you mentioned, there is definitely some timing related weirdness. a 15ms wait between each color draw seems to work, don't know what the minimum is yet.
- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
kbenson
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2010
03:55 PM
Re: first attempt at imagecanvas - not working...
Here's some general tips from other threads about using roImageCanvas, and our own experience:
Also, be careful with floats and integers. In many places using a float instead of an integer in components yields silent but wrong behavior (such as automatically being evaluated as zero). Most places it just blows up though. 😉
- Whenever changing a canvas in any way, the call to .show() will take a while. Anywhere from a little less than 100ms to well over 10 seconds, depending on complexity.
- After you've called .show() on a canvas (and it was given enough time to display), subsequent calls to .show() are very fast, generally displaying in less than 20ms until the next change.
- Creating a new roImageCanvas object anywhere causes all current canvas objects to recomposite (take a long time) on the next call to .show().
- Using TargetRect for simple squares is fine, just don't try to rotate them (unless that's fixed now?)
- Scaling an image causes automatic gradients. A two pixel image with one pixel red and the other green, when scaled will automatically fill in the pixels between the colors with a gradient.
Also, be careful with floats and integers. In many places using a float instead of an integer in components yields silent but wrong behavior (such as automatically being evaluated as zero). Most places it just blows up though. 😉
-- GandK Labs
Check out Reversi! in the channel store!
Check out Reversi! in the channel store!
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2010
04:45 PM
Re: first attempt at imagecanvas - not working...
Thanks. I'm still pretty confused about how all this works. For instance:
If I plot a bunch of squares on layer 0 they all stay on the screen.
If I plot on layer 1, 2 ,3 then each new call erases the previous and draws a new square.
Also, discovered that the transparancy byte documented for text also works for graphics even though it is not documented:
#ff00F00C0 (where C0 is the transparancy)
Rotation is completely inaccurate, but could be used creatively.
- Joel
If I plot a bunch of squares on layer 0 they all stay on the screen.
If I plot on layer 1, 2 ,3 then each new call erases the previous and draws a new square.
Also, discovered that the transparancy byte documented for text also works for graphics even though it is not documented:
#ff00F00C0 (where C0 is the transparancy)
Rotation is completely inaccurate, but could be used creatively.
- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2010
04:54 PM
Re: first attempt at imagecanvas - not working...
Calling SetLayer on any layer should replace all of the content on that layer, even 0. What you may be seeing is left over from the screen behind your ImageCanvas not redrawing.
Actually ff is the transparency in that string (though technically not transparent at FF). Either the trailing 0 or the leading f is likely being ignored, since there are only 4 bytes to a color string, and yours seems to have 4 and a half..
#ff00F00C0 (where C0 is the transparancy)
Actually ff is the transparency in that string (though technically not transparent at FF). Either the trailing 0 or the leading f is likely being ignored, since there are only 4 bytes to a color string, and yours seems to have 4 and a half..
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)