BDS Software

Graphic Formats

Let us design a map consisting of 400 squares laid out in a 20x20 grid, and let the square numbering be zero-based; i.e. 0-19 in the x-direction and 0-19 in the y-direction. Further, let us define square position numbers in (nx, ny) form.


20x20 Grid

Then, let the interior of each square (not including the borders) be 31x31 pixels, so that there is a distinct center at pixel (15, 15) relative to the upper-left corner of that interior space (pixel numbering being zero-based as well). Also, let us generally define pixel locations as (x, y) relative to the upper-left corner of the entire map.

Then, let there be borders all around the map and between squares, of width = 1 pixel each.

Thus, the North-South (NS) border at the left of the entire map is at x = 0 relative to the upper-left corner of that entire map.

The NS border on the right of the first column of squares will then be at x = 32 relative to the upper-left corner of the map. The right NS border of the second column will be at x = 64. etc.

In general, for square x-positions numbered nx = 0 through 19, the x-coordinate of the right NS border will be x = (nx + 1) * 32. e.g., for square x-position = nx = 19, x = (19 + 1) * 32 = 20 * 32 = 640.

The y-coordinates of the East-West (EW) borders will be calculated similarly.

Thus, the entire map image, all borders included, will require a space of 641x641 pixels.

[Incidentally, for square x-positions numbered nx = 0 through 19, the x-coordinate of the upper left corner of the interior space (i.e. just "inside" the borders) will be x = 1 + (nx * 32), i.e. 1, 33, 65, 97 ... 545, 577, 609; and similarly for the y-coordinates.]

We have a .bmp image, BlankSector.bmp, previously made to these specifications, which is of size 1.17 MB (1,233,338 bytes).

I used Corel Paint Shop Pro 9 to convert this to a .png image of size 2.79 KB (2,859 bytes), an exceptional reduction in size! [0.23% of the .bmp].

I then imported BlankSector.png into Inkscape 0.91 and saved it to an .svg image of size 5.51 KB (5,648 bytes). [0.46% of the .bmp]. This was a surprising result, since I had expected the .svg file to be smaller than the .png file. Inspecting the image, I also noticed apparent doubling of the rightmost and bottom-most borders, i.e. at x = 640 and at y = 640, i.e. seemingly as a drop shadow.

I then imported BlankSector.bmp into Inkscape and saved it to BlankSector2.svg, an image of size 6.28 KB (6,432 bytes). [0.52% of the .bmp]. Intriguing! In Inkscape, this image also showed the drop-shadow.

So, without using Inkscape, I proceeded to specify the .svg file in the TextPad 4.7.0 text editor, as follows:

<!-- See ConfigurationNote.txt file --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="641" height="641" viewBox = "0 0 640 640" version = "1.1" xmlns="http://www.w3.org/2000/svg"> <!-- North-South Borders --> <line x1="0" y1="0" x2="0" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="32" y1="0" x2="32" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="64" y1="0" x2="64" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="96" y1="0" x2="96" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="128" y1="0" x2="128" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="160" y1="0" x2="160" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="192" y1="0" x2="192" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="224" y1="0" x2="224" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="256" y1="0" x2="256" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="288" y1="0" x2="288" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="320" y1="0" x2="320" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="352" y1="0" x2="352" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="384" y1="0" x2="384" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="416" y1="0" x2="416" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="448" y1="0" x2="448" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="480" y1="0" x2="480" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="512" y1="0" x2="512" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="544" y1="0" x2="544" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="576" y1="0" x2="576" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="608" y1="0" x2="608" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="640" y1="0" x2="640" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> <!-- East-West Borders --> <line x1="0" y1="0" x2="640" y2="0" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="32" x2="640" y2="32" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="64" x2="640" y2="64" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="96" x2="640" y2="96" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="128" x2="640" y2="128" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="160" x2="640" y2="160" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="192" x2="640" y2="192" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="224" x2="640" y2="224" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="256" x2="640" y2="256" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="288" x2="640" y2="288" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="320" x2="640" y2="320" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="352" x2="640" y2="352" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="384" x2="640" y2="384" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="416" x2="640" y2="416" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="448" x2="640" y2="448" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="480" x2="640" y2="480" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="512" x2="640" y2="512" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="544" x2="640" y2="544" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="576" x2="640" y2="576" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="608" x2="640" y2="608" style="stroke:rgb(0,0,0);stroke-width:1" /> <line x1="0" y1="640" x2="640" y2="640" style="stroke:rgb(0,0,0);stroke-width:1" /> </svg>

I placed this code in a separate editor window and saved it as BlankSector3.svg with a resulting file size of 3.86 KB (3,958 bytes). [0.32% of the .bmp]. Fascinating! When loaded into Inkscape, this image also shows the drop-shadow. I thus suspect that to be a display artifact of the Inkscape program itself. Also, although this is the smallest of the three .svg files, it is still larger than the .png file.

So, I will plan to use BlankSector.png as the base map for all games I develop around the 20x20 grid.


-----

However, I also suspected that the different file sizes encountered above might be influenced by the lack of complexity of the simple gridline layout of the image.

So I made a similar test run, starting with a somewhat more complex 578x601 ChessBoard.bmp image which has a file size of 1.02 MB (1,077,046 bytes).


ChessBoard

ChessBoard.png = 88.3 KB (90,459 bytes). [8.40% of the .bmp].

ChessBoard.svg (starting with ChessBoard.png; in Inkscape) = 121 KB (126,966 bytes). [11.79% of the .bmp].

ChessBoard2.svg (starting with ChessBoard.bmp; in Inkscape) = 139 KB (142,605 bytes). [13.24% of the .bmp].

Given the increased complexity of the ChessBoard image, I didn't try to code an .svg image in TextPad.

So, the ChessBoard.bmp reductions are not as dramatic as those with BlankSector.bmp, but they are still quite significant. Again the .png reduction is superior to the .svg reduction.


-----

Going for even more complexity, I pulled up a 578x771 pixel photograph tree.jpg of file size 149 KB (153,110 bytes). To maintain a parallel comparison methodology, I used Paint Shop Pro to convert it to tree.bmp with a file size of 1.27 MB (1,338,510 bytes). [874.21% of the .jpg].


Tree

tree.png = 748 KB (766,356 bytes). [57.25% of the .bmp]. [500.53% of the .jpg].

tree.svg (from tree.png) = 0.98 MB (1,037,010 bytes). [77.48% of the .bmp]. [677.30% of the .jpg].

tree2.svg (from tree.bmp) = 1.12 MB (1,175,125 bytes). [87.79% of the .bmp]. [767.50% of the .jpg].


-----

Which leads me to conclude that, as the complexity goes up, the .png and .svg reductions from .bmp go down. But the .png images seem to be consistently smaller than the .svg images.

Thus, except where I may need to avail myself of the scaling capabilities of .svg images, .png images will be better for situations in which the image will not have to change size.

Also, .jpg images will continue to generally be superior for photographic images and other images of similar complexity.


-----

Please feel free to download and inspect any of these images for yourself:


BlankSector.bmp

BlankSector.png

BlankSector.svg

BlankSector2.svg

BlankSector3.svg

ChessBoard.bmp

ChessBoard.png

ChessBoard.svg

ChessBoard2.svg

tree.jpg

tree.bmp

tree.png

tree.svg

tree2.svg


                                                                                                                                                                M.D.J. 2018/06/23