eugeneloza / decoherence

Project moved to https://gitlab.com/EugeneLoza/decoherence
GNU General Public License v3.0
10 stars 7 forks source link

Using Base64 #450

Open eugeneloza opened 6 years ago

eugeneloza commented 6 years ago

We can use Base64 for storing binary data, e.g. to encode an image to XML format. So, it becomes very simple to encode the whole TTextureFont or similar stuff to XML for reading/writing. see here https://www.freepascal.org/docs-html/fcl/base64/index.html

Still unsure if it worth the effort thou as I am not really going for Android right away, and I'm more than satisfied with FreeType library at the moment. And by the time I'll return to Android port (if ever) it might be already available in CGE for Android. (so let it be a "question" for now, to think over)

michaliskambi commented 6 years ago

Note that adding support for freetype on Android in CGE is not much work. It's outlined at the bottom of https://github.com/castle-engine/castle-engine/wiki/OpenGL-ES,-Android-and-iOS-TODOs -- it's between 1h to 4h for me. If you will need it now, I promise to do it fast on the CGE side :) So I would not advice creating elaborate solutions to workaround this missing feature of CGE :)

eugeneloza commented 6 years ago

Yes, thanks a lot. I don't really need it "now" :) I still have Android support planned (and writing everything I can in a cross-platform way), but for some future (when I'll have at least something working). Well, using Base64 is not an elaborate solution, thou I don't really like FPC idea about that, it'd be very simple to implement an own function. It's just writing another string to XML. It's nothing comparing to writing maps, info, metadata, etc to XML :) And having Base64 ready and implemented might find another uses (probably even throughout the Engine, e.g. in Networking).

/yep, I'm just procrastinating, trying to avoid doing the urgent things I have to do, and thinking of something else that can be easily done :D /

michaliskambi commented 6 years ago

Note that CGE already uses Base64 -- in CastleDataURI and CastleTiledMap units.

If you find working with streams (like streams in FPC Base64 unit) uncomfortable, then maybe some CGE helpers in CastleClassUtils will be helpful:

eugeneloza commented 6 years ago

Oh, thanks a lot! That's handy. And seems to solve the issue :) /I'll keep it open just not to forget about the solution/

eugeneloza commented 6 years ago

Note to myself: to think over how can I store the map (and all the map objects) in Base64 (or a similar format). As storing them in structured XML might be a huge waste of space.