Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
squirreltown
Level 9

Re: Mask an image (show only part of an image)?

Are you saying  that you are saving the file to tmp:/ and it's being deleted without you doing so? Simply downloading it makes a object of it, but it seems to be going out of scope.

OK i see your edit. Don't know, i thought tmp:/ was tmp:/. It should be there until the channel exits.
Kinetics Screensavers
0 Kudos
jackhand
Level 7

Re: Mask an image (show only part of an image)?

I tried placing the bitmap into a poster of the task node, but it still doesn't work. Perhaps because the task node is not paced on stage visually so Roku immediately tries to get rid of it.

Any other thoughts?
0 Kudos
squirreltown
Level 9

Re: Mask an image (show only part of an image)?

Any other thoughts?
if you are saving something to tmp:/ and it's disappearing then something must be removing it. I know zip about RSG so the only thing i can think of is save the file to a directory and maybe the node will ignore it.
Kinetics Screensavers
0 Kudos
necrotek
Level 7

Re: Mask an image (show only part of an image)?

If you are using SceneGraph, a poster node extends Group therefore has its fields.

https://sdkdocs.roku.com/display/sdkdoc/Group
0 Kudos
jackhand
Level 7

Re: Mask an image (show only part of an image)?

How do you save the file in a different folder? I tried to use the "images/" folder but the app crashed.
0 Kudos
squirreltown
Level 9

Re: Mask an image (show only part of an image)?

"jackhand" wrote:
How do you save the file in a different folder? I tried to use the "images/" folder but the app crashed.

filesystem.CreateDirectory("tmp:/newdir")
Do it before you call SceneGraph, see what happens.
Kinetics Screensavers
0 Kudos
jackhand
Level 7

Re: Mask an image (show only part of an image)?

I created the folder. I am able to create a bitmap in the task node. If I log the bitmap variable it returns as "<Component: roBitmap>"

However, if I create the bitmap in the screen code using the same folder, then the bitmap variable returns as "invalid"

What is the method to store a remote folder on the Roku within a task node but then gain access to that file outside of the task node and in the screen code?
0 Kudos
necrotek
Level 7

Re: Mask an image (show only part of an image)?

If you are using a task node to retrieve the image file I will assume you are making a Scenegraph app.
roBitmap and roCompositor are not usable in Scenegraph components

Look at using a Poster node https://sdkdocs.roku.com/display/sdkdoc/Poster

Set the uri field to the image path you have created. Do not use the roBitmap it is for roScreen components.
0 Kudos
jackhand
Level 7

Re: Mask an image (show only part of an image)?

I tried to use the the temp image uri that I got from within the task node. But the locally stored image never loads when I set the local uri to the poster. 

Besides, I need to use bitmap in order to use a region of the bitmap so I can use just a portion of the sprite map, so I'm not sure I could a poster if it worked.

So here are the probems.

  • I can't pass a bitmap from a task node within an associative array since associative arrays can only hold certain simple object types

  • I can pass the image path from the task node, but I cannot use that image path to create a bitmap or set the uri of a poster if the code is outside of the task node. Not sure why! 
0 Kudos
necrotek
Level 7

Re: Mask an image (show only part of an image)?

First, I would like to establish that you are creating a sceneGraph app. From the code you have posted you seem to be mixing ROKU SDK1 and Scenegraph which don't mix so well. For instance compositor cannot draw to a posternode unless posternode is roScreen. roBitmap, roRegion, and roCompositor  are all to be used with the SDK1 roScreen components and will fail when used with Scenegraph. Before tackling downloading an external file to the temp file, I would suggest looking at the scenegraph poster component demos to make sure that you can access and display image file that is included locally in the package. 

Once you are familiar with displaying images to a scenegraph scene, then you can determine what the problem is with fetching an image remotely. Possible problems 1) there was a problem with the file transfer 2) make sure that the image size is less that 2048x 2048 pixels in either direction  . Larger will cause a a image to be invalid because Roku has a limit on image size (ie.1px x 2049 px will be invalid ). The downloaded file should remain in the temp:/ file system until channel is exited. You can use the filesystem components to verify the file is there.

Then we can work on displaying part of an image. For those that are interested and looking for an answer to your initial question. Create a group as a child of the scene (or parent of your choosing) use  ClippingRect  to the size you would like the partial image to be. Create a poster node as a child of this group and use translation (negative numbers relative to group) of the poster to position the area you would like to display in the window created by ClippingRect. ClippingRect is documented on the "group"  documentation page I referenced earlier.  

There is a way to do it the way you are trying, but it is more complicated than necessary to achieve the results you are looking for.
0 Kudos