Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Resources Question

Resources Question

Discuss PocketC for CE (including Desktop Edition)

Postby Glasswalker on Sun Apr 20, 2003 4:22 pm

Hello, another question:

My program uses a large number (about 350) jpg files, totalling nearly 3-4megs of image data...

I believe I read that the resources can be compiled into the binary, and they will be compressed... and then decompressed on the fly...

My question is: Do they decompress into the filesystem, and if so are they deleted after use? Also how do you access them?

And also, are they ALL decompressed at runtime, and deleted afterwards (rather useless) or are they decompressed one at a time, and deleted again when done? (quite useful)

Thanks
Glasswalker
 
Posts: 47
Joined: Wed Mar 21, 2001 12:18 am
Location: Canada

Postby KOU on Mon Apr 21, 2003 11:13 am

Edited Out

Sorry for the wrong answer
KOU
 
Posts: 92
Joined: Mon Mar 18, 2002 8:04 pm
Location: USA

Postby KOU on Mon Apr 21, 2003 11:15 am

I don't think pocketc compress the resource files

KOU
KOU
 
Posts: 92
Joined: Mon Mar 18, 2002 8:04 pm
Location: USA

Postby wolfgang on Mon Apr 21, 2003 4:22 pm

Hi,

there seems to be some confusion about what #resource really does. But in reality it is quite simple:

(1) the #resource pragma tell the PocketC compiler to pack the give file into the applet. THERE IS NO COMPRESSION WHATSOEVER. So when you have e.g. a 10KB text file, your applet just got 10KB larger.

(2) the loadres statement takes the packed file and creates a TEMPORARY copy in the \Temp folder, giving it some unique name (not the original one). You'll end up with names like 3452_2.txt or the like, but you don't care because the loadres statement returns this filename to you. The file extension is the same as the orginal file's extension, however.

(3) when the applet exits, those temporary files are deleted again. This does not happen in case the applet crashes with a runtime error, so make sure you program is clean :-)


Upside of resources (I use them myself):

- You can distribute a single applet instead of a large number of files. Updates are easier to send out. Less of a concern when you create an .exe installer.

- Files are unpacked into main memory even when the applet is installed on a flash storage card - faster access (that's what I use it for).

Downsides:

- Each resource file wastes space - during runtime it is present twice, once within the applet and once as the temporary file. I would not use resources for very large files.

- Temporary files are left over when the applet crashes (my programs never do of couse :-) Not an issue if the files are small, but when it't a few MB, that's a bummer.


By the way, in case you still use PocketC V2 like I do (I do because it is stable and faster), resources can be a way out of the undocumented size restriction (applet crashes at startup when compiled program code exceeds approx. 80KB): I found out that reosurces don't count agains this size limit. So I write a file with all the parameters for all my GUI objects (i.e. all the parameters for the createctrl() calls), make it a resource and parse the contents at program startup in a small loop. The user still sees only a single file, but it took about 25KB of source code (6KB compiled) out of my program which will enable me to add quite a lot of new code before the restriction hits again. My applet (including all the reosurce files) is now over 200KB and runs fine.

Wolfgang


Composing music on the PocketPC! - http://www.pdamusician.com
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA

Postby wolfgang on Mon Apr 21, 2003 4:30 pm

One more detail, resources are extracted (not decompressed, as mentioned before) when you call the loadres() function - which means, one by one. If you don't issue a loadres() statement for a particular file, this file won't get extracted. They are all deleted at once when the applet exits, but since you have the filename (returned by loadres ()), you can delete them earlier if you want to save space and don't need them anymore.

In your case (several MB of data) I would forget about resources and create an installer instead. I can send you sample files for creating .cab files and an automated .exe installer if you want. You'll need Windows2000, NT, or XP.

CuteInstall does not work for you because it only allows a limited number of files to be included.

Wolfgang


Composing music on the PocketPC! - http://www.pdamusician.com
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA

Postby Glasswalker on Tue Apr 22, 2003 1:29 pm

I was mainly looking for a way to make my program smaller... I can't compress the jpg files any further, they allready are barely acceptable quality now...

I would appreciate the installer code wolfgang... That will be nice when the program is done.

Mainly though, my problem is... How to I make it smaller??? :) (3-4meg of data to install on a handheld is a big footprint to ask for)

thanks
Glasswalker
 
Posts: 47
Joined: Wed Mar 21, 2001 12:18 am
Location: Canada

Postby darwin on Tue Apr 22, 2003 2:02 pm

What type of Images are we talking about?
JPEG has already a great compression and you will not find a better fileformat than this - well or you compress the images as GIFs and reduce the colors instead of picture quality).
I think GIF would be a solution too, because it has also a good compression and reducing the colordepth don't hurt so much (as long as we are not talking about photos).

The only way to safe memory is to optimize the program smarter (by using only parts of images etc etc).

Well the rest is a problem that can hardly be avoided (as long as you are not writing a decompressionfilter for JPEG-2000 (wavelets) files)

cya

http://www.strange-phenomenom.de/
darwin
 
Posts: 71
Joined: Tue Dec 05, 2000 12:04 pm
Location: Germany

Postby wolfgang on Tue Apr 22, 2003 2:52 pm

Ways to further compress your image files:

- jpg is your best bet for photographs, i.e. pictures with a wide range of different shades of colors.

- JPG has adjustable compression: The more you compress, the smaller the file size gets, but on the expense of image quality. But for the limited resolution of the PocketPC screen (only 240x300 pixels) you may be able to compress them more without noticing much difference.

- GIF is better for computer graphics that has only few different colors, e.g. graphs, clipart. In this case it may provide much smaller files than jpg, and without the artefacts (color errors) caused by strong jpg compression (GIF is a los-less compression method).

I'll dig up the installer code when I get home.

Wolfgang


Composing music on the PocketPC! - http://www.pdamusician.com
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA

Postby wolfgang on Tue Apr 22, 2003 2:54 pm

By the way, Glasswalker, I'd need you email address tyo send you the files. You find my mail in my profile:

wolfgang@pdamusician.com

Wolfgang

Composing music on the PocketPC! - http://www.pdamusician.com
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA


Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 1 guest

cron