Post Reply 
Files on HP Prime Question
05-21-2015, 06:38 PM
Post: #21
RE: Files on HP Prime Question
(05-20-2015 10:10 PM)critor Wrote:  
We could convert a PDF into a collection of several PNG images, with one image per page.
But …
- to be able to get a part of a file data, we have to use AFilesB() and not AFiles()
- to be able to display the PNG data, we have to use AFiles() and not AFilesB()

Any idea of a workaround ? Any other ideas ?

How about generating png files on demand from the archive file? Here's what I tried…

1. Make a couple png files, from screen captures. (I entered a bunch of trivial calculations between captures to make it obvious [to me] which png was which.)
Code:

AFiles("img1.png"):=G0
AFiles("img2.png"):=G0

2. Store the sizes of the two files in J and T.
Code:

J:=AFilesB("img1.png")
T:=AFilesB("img2.png")

3. Combine the two png files into a single combo png file.
Code:

AFilesB("big.combopng",0):=AFilesB("img1.png",0,J)
AFilesB("big.combopng",J):=AFilesB("img2.png",0,T)

4. Pull out the two files.
Code:

AFilesB("pulled1.png",0):=AFilesB("big.combopng",0,J)
AFilesB("pulled2.png",0):=AFilesB("big.combopng",J,T)

5. Try displaying the two files.
Code:

G0:=AFiles("pulled1.png");WAIT(0)
G0:=AFiles("pulled2.png");WAIT(0)

The above worked for my screen captures. For larger png files it may well be prudent to read / write in fixed size blocks (rather than the whole png at once).

The above is just a quick test. A viewer would likely simply do #4 / #5 on demand (produce, e.g., "todisplay.png" from "big.combopng" with offsets & size depending on the png to display).

For larger text-heavy documents (or, more generally, documents where cross-page compression can pay off) a more sophisticated format should allow better use of the available memory.
Find all posts by this user
Quote this message in a reply
05-21-2015, 06:45 PM
Post: #22
RE: Files on HP Prime Question
Thank you jte.

Yeah, I've already tried something like this :
- getting the part of the file content with AFilesB
- saving it in a temp file with AFilesB
- then opening the temp file with AFiles

Unfortunately, with big files, I'm easily getting crashes on both calculator and software.
Using a buffer seems to increase the stability, but crashes still remain possible.
Find all posts by this user
Quote this message in a reply
05-24-2015, 09:49 AM (This post was last modified: 05-24-2015 10:03 AM by critor.)
Post: #23
RE: Files on HP Prime Question
(05-21-2015 04:38 PM)Tim Wessman Wrote:  Why would that be any easier then simply having your viewer flip from page to page using separate files? Just put the files in a directory and send. There is no "difficult process to add files" like you seem to be implying. You can open your document\HP Connectivity Kit\Content\<your_app>\ and add the files like any other folder. Or do the same thing by dragging them into the folder in the connkit file browser. Or load them in a folder in a zip. Or directly add it to the folder in the HP Connectivity Kit\Calcs\<your calc name> directory.

You are correct that you can't yet drag to an individual application directly in the calculator tree, but there are at least 4 other ways to do it directly right now.

Thank you Tim for your reply.
But did you already try sending an application with more than 2MB of attached files using the content pane you told me about ?
My calculator just goes crazy when I try this.

Here's an unlisted youtube video :




I'm first sending my application folder together with 1.9MB of PNG files and it works.

Then at 2min10s after resetting both calculator and content pane, I add a fourth PNG file in the application folder, making it 2.6MB large, and send the folder.
The calculator can then do various things and you can see it triggering menus by itself.
It's not shown in the video, but it can also disconnect itself from the HPCK, freeze, reboot, or ask the user for a newer firmware through the HPCK.
(and unfortunately, the application is not there, even when the whole process does end up without a freeze/reboot)

I can't release the app version of my document viewer while I cannot find a safe way for the end user to easily add several MB of PNG files.

For the moment :
- dragging files on the application doesn't work
- adding files one by one through the contextual menu is too time consuming for the end user (unless by concatenating PNG files, a way you don't seem happy with)
- dragging files through the content pane doesn't seem reliable.
Any other way ?
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)