Lazarus

Programming => Widgetset => Other => Topic started by: Fred vS on November 21, 2014, 03:10:08 pm

Title: Universal Ressource Translator => Yet a other fpGUI bomb...
Post by: Fred vS on November 21, 2014, 03:10:08 pm
Hello everybody.  :)

There is a highly indispensable tool in fpGUI tools => Image Convertor =>  fpGUI/tools/ImageConvert.

In fact it is a universal resource convertor, usable for Lazarus applications too.

The ImageConvert tool simply converts some data file to a byte array. It
is primarily used for images. But nothing stops you from embedding say
sound files into your application too.

To archive something similar you could obviously use FPC's resource
support too. The problem with this is that only FPC for Windows includes
a resource compiler. There is a 3rd party Linux resource compiler
somewhere on the Internet, and nothing for other platforms like FreeBSD
etc. The ImageConvert way works cross-platform.

Here how to use fpGUI/tools/ImageConvert for a Bitmap image.

1) Run ImageConvert

2) Choose your favorite bitmap and convert-it.

3) Click on "Copy in Memory" button.

4) Open (or create) a text file and paste the conversion => save it for
example as myicons.inc .

5) In your program, after uses section, add => {$I myicons.inc}   

6) In  constructor TMyForm.Create(AOwner: TComponent);  ( or when you need the resource) => add =>
       fpgImages.AddMaskedBMP('my.icon1', @newimage_myicon1,
sizeof(newimage_myicon1), 0, 0);   => (according with what you use in
myicons.inc) 

7) And to store the bitmap =>   Mybutton.ImageName := 'my.icon1';   

=> You may also use the converted bitmap directly in your program, as a const
( so no need of {$I myicons.inc} ) 

Here some test  of sound files into converted files =>

Wav =>

Original test.wav       => 263.0 kB

Converted testwav.txt   =>   1.1 MB => + 318.2 %

Compress testwavtxt.bz2 => 277.5 kB => + 5.5 % => not bad


Mp3 =>

Original test.mp3       => 20.0 kB

Converted testmp3.txt   => 87.2 kB => + 336 %

Compress testmp3txt.bz2 => 21.1 kB => + 5.5 % => not bad

So that converter tool could be used as a universal file storer too...

PS :  If you use designer_ext => that tool is included in "Tools" menu =>
https://github.com/fredvs/uidesigner_ext (https://github.com/fredvs/uidesigner_ext)

Fre;D


Title: Re: Universal Ressource Translator => Yet a other fpGUI bomb...
Post by: Never on November 21, 2014, 04:47:00 pm
what a coincidence implemented excactly the same  for the sam reasons befor a month or so
using base64 to encode the data
TinyPortal © 2005-2018