Recent

Author Topic: Universal Ressource Translator => Yet a other fpGUI bomb...  (Read 5676 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Universal Ressource Translator => Yet a other fpGUI bomb...
« 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

Fre;D


« Last Edit: November 21, 2014, 06:58:11 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: Universal Ressource Translator => Yet a other fpGUI bomb...
« Reply #1 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