Templot Club Archive 2007-2020                             

topic: 3561BGS file format
author remove search highlighting
 
posted: 27 Nov 2019 02:54

from:

Martin Wynne
 
West Of The Severn - United Kingdom

click the date to link to this post
click member name to view archived images
view images in gallery view images as slides
As you know I recently introduced a new MECBOX interchange file format for BOX data transfers between T2 and T3.

So thoughts naturally turned to doing something similar for the BGS background shapes files, which are equally incompatible between T2 and T3 as they stand.

The existing BGS binary file format was invented in 5 minutes flat on a wet Wednesday afternoon 25 years ago, solely for the purpose of getting some data from one computer to another before teatime, on a floppy disk. (The data, not the tea.)

The BGS format has been a constant thorn in my side ever since. It is so primitive that it has been impossible to add some much-needed extra functions to the background shapes, and the picture shapes and maps had to be bolted on the side as separate SK7n and SK8n files. It should have been replaced years ago of course -- but I originally intended that the sketchboard functions would replace the background shapes entirely. That didn't work out in the end, and now with the screenshot maps it wouldn't have been ideal. So we are where we are, still using the same old BGS file format.

Until now that is. It seemed that if I was going to invent a new transfer format, I might as well do it properly and invent a completely new compatible format for T2 and T3 to replace the BGS files entirely.

So for the next program update 225a we have a new BGS3 file format. Your old BGS/SK7/SK8 files can still be loaded (in T2 only), but all saving of background shapes will now be in BGS3.

A single file including the picture shapes and maps, making it much easier to share with other users and attach to posts here.

For MECBOX with around 500 settings for every template, I used the old Windows INI format, which is natively supported in both Delphi and Lazarus. It's easy to use, tried and tested, but slow. That doesn't really matter for one-time transfer use. Also it doesn't easily support embedded image files, which we need for the background shapes.

So for BGS3 I have used XML instead. Like INI it is text-based and readable, and editable in a text editor, although I wouldn't recommend doing that.

Fortunately we already have Nils's open-source XML engine used for the sketchboard SK9 files:

 http://sourceforge.net/projects/simdesign/files/trunk/nativexml/

So I was able to use that more or less as-is, and much to my relief I found that it compiled in Lazarus with only a few minor tweaks.

Here is an example of what a BGS3 file looks like:  

<?xml version="1.0" encoding="UTF-8"?>
<BGS3>
  <HEADER>
    <program_name>Templot2 background shapes, saved from version 2.25.a</program_name>
    <program_version>225</program_version>
    <file_date>27/11/2019 01:50:17</file_date>
    <shapes_count>6</shapes_count>
  </HEADER>
  <BGND_SHAPE_0>
    <shape_name>baseboard joint</shape_name>
    <wrap_offset>0</wrap_offset>
    <show_transparent>False</show_transparent>
    <shape_code>0</shape_code>
    <shape_style>0</shape_style>
    <picture_is_metafile>False</picture_is_metafile>
    <hide_bits>0</hide_bits>
    <option_bits>0</option_bits>
    <p1.x>430.871098</p1.x>
    <p1.y>289.968693</p1.y>
    <p2.x>525.013974</p2.x>
    <p2.y>283.980807</p2.y>
  </BGND_SHAPE_0>
  <BGND_SHAPE_1>
    <shape_name>drawn rectangle</shape_name>
    <wrap_offset>0</wrap_offset>
    <show_transparent>False</show_transparent>
    <shape_code>1</shape_code>
    <shape_style>0</shape_style>
    <picture_is_metafile>False</picture_is_metafile>
    <hide_bits>0</hide_bits>
    <option_bits>0</option_bits>
    <p1.x>382.809599</p1.x>
    <p1.y>335.272227</p1.y>
    <p2.x>544.937057</p2.x>
    <p2.y>485.890637</p2.y>
  </BGND_SHAPE_1>
  <BGND_SHAPE_2>
    <shape_name>map::Bewdley OSM    6S19 screenshot</shape_name>
    <wrap_offset>0</wrap_offset>
    <show_transparent>False</show_transparent>
    <shape_code>-1</shape_code>
    <shape_style>0</shape_style>
    <picture_is_metafile>False</picture_is_metafile>
    <hide_bits>0</hide_bits>
    <option_bits>0</option_bits>
    <p1.x>0</p1.x>
    <p1.y>0</p1.y>
    <p2.x>6505.92284</p2.x>
    <p2.y>3397.68367</p2.y>
    <image_width>1978</image_width>
    <image_height>1033</image_height>
    <BITMAP>
      <SourceSize>6131942</SourceSize>
      <CompressedSize>728739</CompressedSize>
      <Buffer>
      hT4MAGsBCwBYpAkA/wAD/wIED8DwBfwGCz8K/ggHAQ48gAkM+xEvDRgoECMSFO8TvyAXFRYfGjAb
      GR4dHDL9+CJ/KyEuPiwkJ+AlOyr6JkApLTgzMTQ6gvk2PTU386BHOfew9exB9rxgQkNETUXuTEi+
      9ErPRpZLT/JJabu4TlBaVFGlU1jrUuRX8VVWXOOvWepfXdBbXnB0w9vf6G5kZXthjG+rZmLMY8qE
      7bprzmfni+aIrKOOyGjpbNiPanrc5Yp8bYPikN5zcXV3dn6uctmz3b2F4Z+qeNN9zdTLgXmHponV
      t7mikaTFntqG19LEx8GtsbLWqLSYwo3Rnam2xpuZk5ynkqG1lMmal5X//PiE++v+7+/7/u+7f///
      /3v/+/////////////////////+////v/////////////////////////////////////4qPGCeh
      EzoTJ/LII0/oxIoMOmJH/Igr0om8jzziiLmEjzQj6oGOPOESNnETOiI78h/yivwipoi/EjdhI/KE
      TeyMKAs68sSPrBM6sRM3IjnyGuKK/CK+yOsSO/LIJqETPiPLDE3oyDrxEzvihM+Mg478B6uIL+KL
      uCuhIk6shI80I2rITdjIOzJG2Igj3ogWYSM+gityG+KNvCeiiD3hI03YhM7II7ITNrKK/BI6oRM6
      Y6d+ue+16l/72eNlqtrbdeme13y7oXvdPvLESeiEzsgz+iOP/CK+ETuhEzbzun35l919677X5t9l

             ...

There is an option setting to make it easily readable as above for bug tracking, but for normal use it will be in the compact style as below (I'm not convinced the compressed image data will be reliable with inserted line feed characters and indents as above, although it has worked fine in my tests.)

<?xml version="1.0" encoding="UTF-8"?>
<BGS3><HEADER><program_name>Templot2 background shapes, saved from version 2.25.a</program_name><program_version>225</program_version><file_date>27/11/2019 01:55:11</file_date><shapes_count>6</shapes_count></HEADER><BGND_SHAPE_0><shape_name>baseboard joint</shape_name><wrap_offset>0</wrap_offset><show_transparent>False</show_transparent><shape_code>0</shape_code><shape_style>0</shape_style><picture_is_metafile>False</picture_is_metafile><hide_bits>0</hide_bits><option_bits>0</option_bits><p1.x>430.871098</p1.x><p1.y>289.968693</p1.y><p2.x>525.013974</p2.x><p2.y>283.980807</p2.y></BGND_SHAPE_0><BGND_SHAPE_1><shape_name>drawn rectangle</shape_name><wrap_offset>0</wrap_offset><show_transparent>False</show_transparent><shape_code>1</shape_code><shape_style>0</shape_style><picture_is_metafile>False</picture_is_metafile><hide_bits>0</hide_bits><option_bits>0</option_bits><p1.x>382.809599</p1.x><p1.y>335.272227</p1.y><p2.x>544.937057</p2.x><p2.y>485.890637</p2.y></BGND_SHAPE_1><BGND_SHAPE_2><shape_name>map::Bewdley OSM    6S19 screenshot</shape_name><wrap_offset>0</wrap_offset><show_transparent>False</show_transparent><shape_code>-1</shape_code><shape_style>0</shape_style><picture_is_metafile>False</picture_is_metafile><hide_bits>0</hide_bits><option_bits>0</option_bits><p1.x>0</p1.x><p1.y>0</p1.y><p2.x>6505.92284</p2.x><p2.y>3397.68367</p2.y><image_width>1978</image_width><image_height>1033</image_height><BITMAP><SourceSize>6131942</SourceSize><CompressedSize>728739</CompressedSize><Buffer>hT4MAGsBCwBYpAkA/wAD/wIED8DwBfwGCz8K/ggHAQ48gAkM+xEvDRgoECMSFO8TvyAXFRYfGjAbGR4dHDL9+CJ/KyEuPiwkJ+AlOyr6JkApLTgzMTQ6gvk2PTU386BHOfew9exB9rxgQkNETUXuTEi+9ErPRpZLT/JJabu4TlBaVFGlU1jrUuRX8VVWXOOvWepfXdBbXnB0w9vf6G5kZXthjG+rZmLMY8qE7bprzmfni+aIrKOOyGjpbNiPanrc5Yp8bYPikN5zcXV3dn6uctmz3b2F4Z+qeNN9zdTLgXmHponVt7mikaTFntqG19LEx8GtsbLWqLSYwo3Rnam2xpuZk5ynkqG1lMmal5X//PiE++v+7+/7/u+7f////3v/+/////////////////////+////v/////////////////////////////////////4qPGCehEzoTJ/LII0/oxIoMOmJH/Igr0om8jzziiLmEjzQj6oGOPOESNnETOiI78h/yivwipoi/EjdhI/KETeyMKAs68sSPrBM6sRM3IjnyGuKK/CK+yOsSO/LIJqETPiPLDE3oyDrxEzvihM+Mg478B6uIL+KLuCuhIk6shI80I2rITdjIOzJG2Igj3ogWYSM+gityG+KNvCeiiD3hI03YhM7II7ITNrKK/BI6oRM6Y6d+ue+16l/72eNlqtrbdeme13y7oXvdPvLESeiEzsgz+iOP/CK+ETuhEzbzun35l919677X5t9llWl3XXyfvr+au2vvjTxxEzbhMyLG6Mgjv8wX7IgTO/Pr/efvWqfrvbXOqWW4+d2Jrm9ynVpq19f8
...


In the next program update soon.

cheers,

Martin.



Templot Club > Forums > Templot talk > BGS file format
about Templot Club

Templot Companion - User Guide - A-Z Index Templot Explained for beginners Please click: important information for new members and first-time visitors.
indexing link for search engines

back to top of page


Please read this important note about copyright: Unless stated otherwise, all the files submitted to this web site are copyright and the property of the respective contributor. You are welcome to use them for your own personal non-commercial purposes, and in your messages on this web site. If you want to publish any of this material elsewhere or use it commercially, you must first obtain the owner's permission to do so.
The small print: All material submitted to this web site is the responsibility of the respective contributor. By submitting material to this web site you acknowledge that you accept full responsibility for the material submitted. The owner of this web site is not responsible for any content displayed here other than his own contributions. The owner of this web site may edit, modify or remove any content at any time without giving notice or reason. Problems with this web site? Contact webmaster@templot.com.   This web site uses cookies: click for information.  
© 2020  

Powered by UltraBB - © 2009 Data 1 Systems