Can Roku generate a JPG or PNG file?

Roku's free SDK allows developers to build channels and applications and publish them to the Roku Channel Store. Register for the Developer Program at http://www.roku.com/developer

Moderators: RokuDouglas, RokuKen, RokuRyan, RokuJamesL, RokuChris, RokuJoel

Can Roku generate a JPG or PNG file?

Postby EnTerr » Wed Feb 15, 2012 8:49 pm

Let me start with the premise of using roGridScreen and wanting to show text within each "poster" for the categories/items. SDPosterUrl/HDPosterUrl properties for each item instead expect URL to an image. And I don't have that image pre-rendered, assume text is dynamic and making round-trip to external server to render it is unavailable.

So i wonder, is there a way to generate images to tmp:/ so they can be referred by posterUrl?
Something like roBitmap and/or roRegion having save() method that can produce a JPG or PNG?!
EnTerr
 
Posts: 1261
Joined: Sun Jan 02, 2011 2:41 am

Re: Can Roku generate a JPG or PNG file?

Postby RokuJoel » Thu Feb 16, 2012 10:43 am

As to referencing local urls:

Code: Select all
SDPosterURL="tmp:/myimageSD.png"
HDPosterURL="tmp:/myimageHD.png"

should work.

ifDraw2d (page 56 of Brightscript manual) has a GetByteArray() method which should give you an robytearray which you can write to tmp:/ using ifByteArray functions (see page 49 of Brightscript manual)

I haven't tried this myself, so this is just information use at your own risk.

You might also look at LibRokuDev https://github.com/rokudev/librokudev which has some .PNG manipulation functions.

- Joel
User avatar
RokuJoel
 
Posts: 1325
Joined: Mon Nov 14, 2011 5:22 pm

Re: Can Roku generate a JPG or PNG file?

Postby TheEndless » Thu Feb 16, 2012 11:28 am

Writing a byte array directly to disk would result in a raw bitmap, if I'm not mistaken. Do the built-in screens support bmp in addition to jpg, png, and gif? I've had a need for this myself, actually, but haven't had the opportunity to test it out, yet.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), MainSqueeze (MAINSQUEEZE), iTunes Podcasts (ITPC), Twitch.tv (TWITCHTV), My Channels (MYCHANNELS)
User avatar
TheEndless
** Valued Community Member **
 
Posts: 8129
Joined: Mon Oct 04, 2004 10:15 am
Location: US

Re: Can Roku generate a JPG or PNG file?

Postby RokuJoel » Thu Feb 16, 2012 12:05 pm

Just checked, looks like setbytearray has not yet been implemented, so it would appear that librokudev is the only option, other than pushing the raw data to a server, converting it and downloading again.

- Joel
User avatar
RokuJoel
 
Posts: 1325
Joined: Mon Nov 14, 2011 5:22 pm

Re: Can Roku generate a JPG or PNG file?

Postby EnTerr » Thu Feb 16, 2012 3:36 pm

RokuJoel wrote:Just checked, looks like setbytearray has not yet been implemented, so it would appear that librokudev is the only option, other than pushing the raw data to a server, converting it and downloading again.

Thanks for the ideas, Joel -

1. Did you mean getByteArray() from the documentation is not implemented? (And if it's not implemented, how can i even convert text&font to a raw bitmap?!)

2. Can you put a feature request for this to be done? I.e. allow saving image locally in a format which is both easy to implement and roGridScreen&co will feel comfortable as poster (i seem to remember it may take PNG/GIF but will convert to JPG) - or alternatively have a way to provide TEXT as poster blot
EnTerr
 
Posts: 1261
Joined: Sun Jan 02, 2011 2:41 am

Re: Can Roku generate a JPG or PNG file?

Postby RokuJoel » Thu Feb 16, 2012 4:01 pm

EnTerr wrote:1. Did you mean getByteArray() from the documentation is not implemented? (And if it's not implemented, how can i even convert text&font to a raw bitmap?!)


No, just that there is no (fast) way to reverse the process of converting a byte array to a bitmap... at least that is my understanding.

EnTerr wrote:2. Can you put a feature request for this to be done? I.e. allow saving image locally in a format which is both easy to implement and roGridScreen&co will feel comfortable as poster (i seem to remember it may take PNG/GIF but will convert to JPG) - or alternatively have a way to provide TEXT as poster blot


The request is already in the system, just followed up, the more really useful use-cases for this sort of thing there are, the higher likelihood of it actually happening.

- Joel
User avatar
RokuJoel
 
Posts: 1325
Joined: Mon Nov 14, 2011 5:22 pm

Re: Can Roku generate a JPG or PNG file?

Postby EnTerr » Thu Feb 16, 2012 5:55 pm

RokuJoel wrote:No, just that there is no (fast) way to reverse the process of converting a byte array to a bitmap... at least that is my understanding.

Well there is the constructor CreateObject("roBitmap", String filename) that can load files. But this reverse process does not concern me, since it does not relate to my case.

RokuJoel wrote:The request is already in the system, just followed up, the more really useful use-cases for this sort of thing there are, the higher likelihood of it actually happening.

For my case any of the two things will do: a) ability to overlay text on top (or instead) of poster image background or b) ability to save bitmaps to PNG/JPG (or whatever pleases poster screens). In my particular scenario this is to browse file system but i suppose others can chime in with other cases when it was needed.
EnTerr
 
Posts: 1261
Joined: Sun Jan 02, 2011 2:41 am

Re: Can Roku generate a JPG or PNG file?

Postby RokuJoel » Thu Feb 16, 2012 6:40 pm

Hmm - seems like you could just pop an ImageCanvas on top of your posterscreen and display whatever you want there - text etc.

- Joel
User avatar
RokuJoel
 
Posts: 1325
Joined: Mon Nov 14, 2011 5:22 pm

Re: Can Roku generate a JPG or PNG file?

Postby kbenson » Thu Feb 16, 2012 6:43 pm

EnTerr wrote:
RokuJoel wrote:The request is already in the system, just followed up, the more really useful use-cases for this sort of thing there are, the higher likelihood of it actually happening.

For my case any of the two things will do: a) ability to overlay text on top (or instead) of poster image background or b) ability to save bitmaps to PNG/JPG (or whatever pleases poster screens). In my particular scenario this is to browse file system but i suppose others can chime in with other cases when it was needed.


To receive a raw framebuffer from a VNC server fro display as a VNC Client. I've been waiting on this one for quite a while....

Also, librokudev's PNG libs won't work well for this. PNG's require compression, and while the library does allow for arbitrary PNG chunk creation (to some extent), it does not support compression itself. It's main use was in KidPaint to change the pallete indexed color values (separate, non-compressed chunk of the file), thus changing PNG image colors without needing to pack/unpack the image itself.
-- GandK Labs
Check out Reversi! in the channel store!
kbenson
 
Posts: 886
Joined: Fri Apr 09, 2010 9:53 am
Location: Santa Rosa, Ca

Re: Can Roku generate a JPG or PNG file?

Postby TheEndless » Thu Feb 16, 2012 10:22 pm

RokuJoel wrote:Hmm - seems like you could just pop an ImageCanvas on top of your posterscreen and display whatever you want there - text etc.

- Joel

If you put an image canvas on top of a poster screen, then the image canvas will steal all of the events, so you could no longer navigate the poster screen.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), MainSqueeze (MAINSQUEEZE), iTunes Podcasts (ITPC), Twitch.tv (TWITCHTV), My Channels (MYCHANNELS)
User avatar
TheEndless
** Valued Community Member **
 
Posts: 8129
Joined: Mon Oct 04, 2004 10:15 am
Location: US

Re: Can Roku generate a JPG or PNG file?

Postby EnTerr » Thu Feb 16, 2012 11:41 pm

RokuJoel wrote:Hmm - seems like you could just pop an ImageCanvas on top of your posterscreen and display whatever you want there - text etc.

Will that text move (scroll) with the "poster" elements while user navigates left/right/up/down in roGridScreen?
EnTerr
 
Posts: 1261
Joined: Sun Jan 02, 2011 2:41 am

Re: Can Roku generate a JPG or PNG file?

Postby RokuJoel » Fri Feb 17, 2012 4:44 am

No, the control shifts to the screen that is on "top" so you would have to capture the remote input in your image canvas, close the canvas, make your move on the grid with setFocusedListItem and then pop the canvas back up over the grid.

- Joel
User avatar
RokuJoel
 
Posts: 1325
Joined: Mon Nov 14, 2011 5:22 pm

Re: Can Roku generate a JPG or PNG file?

Postby EnTerr » Fri Feb 17, 2012 1:11 pm

RokuJoel wrote:No, the control shifts to the screen that is on "top" so you would have to capture the remote input in your image canvas, close the canvas, make your move on the grid with setFocusedListItem and then pop the canvas back up over the grid.


So no, it is no good. Inventive but useless; you are thinking of something that you needed perhaps but it does not relate to having posters with text on them and said posters moving smooth as they tend to, no jerking and some text flickering on and off on top.

Just imagine I want to show list of n>5 folders/categories by name and choose from those and I don't know them in advance (so can't pre-render them). Showing same generic poster of a folder or a book is bad UI in the case.
EnTerr
 
Posts: 1261
Joined: Sun Jan 02, 2011 2:41 am

Re: Can Roku generate a JPG or PNG file?

Postby RokuJoel » Fri Feb 17, 2012 2:59 pm

So, what you probably need to do is create your own ui using the 2D Api's - roScreen/roBitmap etc.

- Joel
User avatar
RokuJoel
 
Posts: 1325
Joined: Mon Nov 14, 2011 5:22 pm

Re: Can Roku generate a JPG or PNG file?

Postby EnTerr » Fri Feb 17, 2012 3:37 pm

RokuJoel wrote:So, what you probably need to do is create your own ui using the 2D Api's - roScreen/roBitmap etc.

Maybe: Is there an example of that being done in BS - scrolling most of the screen smoothly and sliding new parts on screen - no matter if that is a sample or production channel?

But barring that, probably is better to focus on realistic approach like being able to save roBitmap to JPEG. A note on roGridScreen fw>2.8 says that "File types of .png and .gif files are now supported, though they are converted internally to .jpg by the roGridScreen so they have a performance penalty" so it would seem as if store-as-jpeg functionality/library is already included in the code and if it is added as roBitmap.save(), that would be a) easy and b) have broader use than text on posters.
EnTerr
 
Posts: 1261
Joined: Sun Jan 02, 2011 2:41 am

Next

Return to Roku Developer Program

Who is online

Users browsing this forum: No registered users and 5 guests