Using images in json (base 64 encoding)

Learn here how to create and use plugins.

Moderator: Plugin Moderators

cesareborgia94
Inhabitant of a Planet
Reactions:
Posts: 1307
Joined: Sun Nov 12, 2017 9:23
Location: The Kingdom of Babilandia
Plugins: Show
Version: Beta

Using images in json (base 64 encoding)

Hello,
In the recent update (520), there was a new addition to json which is adding images to json using base64 encoding.

The question I would like to ask is:
1. What does adding images to json mean? What functionality could we use it in plugins?

2. How does the code work? What is the example of adding images to json will do?

I hope Lobby and other experienced plugin makers could explain this. It may be complex stuff but I still want to know what does it do.
I rarely make plugins now, but I still make them in spare time.
Disclaimer

CommanderABab
AB
Reactions:
Posts: 8780
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Using images in json (base 64 encoding)

.
Lobby wrote: 1. Use a website like https://www.freeformatter.com/base64-encoder.html to encode an image file to base64
2. insert the base64 string into the bmp tag.

Code: Select all

[  {
"id":"\$sloth00",
"type":"terrain",
"width":1,
"height":1,
}]

cesareborgia94
Inhabitant of a Planet
Reactions:
Posts: 1307
Joined: Sun Nov 12, 2017 9:23
Location: The Kingdom of Babilandia
Plugins: Show
Version: Beta

Re: Using images in json (base 64 encoding)

Thank you Lobby and Commander for teaching me the basics of using images in json using base 64 encoding.

Although why do plugin creators could use base64 for images? Is it for security?
I rarely make plugins now, but I still make them in spare time.
Disclaimer

Lobby
Developer
Reactions:
Posts: 3590
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta

Re: Using images in json (base 64 encoding)

Base64 is just an encoding, not an encryption
The feature here is to be able to create plugins that only consist of a single json file that contains all the images in textual representation (that's what base64 is about).
=^._.^= ∫

FranchuFranchu
Inhabitant of a Country
Reactions:
Posts: 798
Joined: Sun May 28, 2017 0:07
Location: Freezing in Argentina
Plugins: Show
Version: Beta

Re: Using images in json (base 64 encoding)

So no plugin texture space problems?
Did you know you can't blink while smiling :) ?

cesareborgia94
Inhabitant of a Planet
Reactions:
Posts: 1307
Joined: Sun Nov 12, 2017 9:23
Location: The Kingdom of Babilandia
Plugins: Show
Version: Beta

Re: Using images in json (base 64 encoding)

It is quite a nice feature, so you still make a plugin texture and it is contained in the encoding... I may use it for my future plugins

But I need to experiment first...
I rarely make plugins now, but I still make them in spare time.
Disclaimer

Lobby
Developer
Reactions:
Posts: 3590
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta

Re: Using images in json (base 64 encoding)

@FranchuFranchu unfortunately not, there's no magic involved. The game does nothing else than getting the image out of the json and putting it into the plugin texture, like with any other image, too.

It's indeed more a neat feature than new functionality.
=^._.^= ∫

cesareborgia94
Inhabitant of a Planet
Reactions:
Posts: 1307
Joined: Sun Nov 12, 2017 9:23
Location: The Kingdom of Babilandia
Plugins: Show
Version: Beta

Re: Using images in json (base 64 encoding)

So this is an example of the usage of base 64 encoding using my res building. This is just a test to see it works...
How the bulding looks like in the game, it is a res building with a purple 64 painted on its wall. Has no influences, just a normal res building except it is encoded with base 64