C# implementation of the BGA image format
Go to file
2024-06-01 03:36:55 +00:00
examples init 2024-05-31 22:30:07 -05:00
obj/Debug/net6.0 init 2024-05-31 22:30:07 -05:00
src init 2024-05-31 22:30:07 -05:00
bgasharp.csproj init 2024-05-31 22:30:07 -05:00
bgasharp.sln init 2024-05-31 22:30:07 -05:00
LICENSE init 2024-05-31 22:30:07 -05:00
Program.cs init 2024-05-31 22:30:07 -05:00
README.md add name info 2024-06-01 03:36:55 +00:00

bgasharp

bgasharp is a new implementation of BGA written in C#. The main source file is around 272 lines long (less if you strip out the Magick.NET specific bits!)

What is BGA?

BGA is a custom image format I built for an old project called Marcos. That project has been on the backburner for a while, but I decided to reimplement the BGA format again given the relative ease of implementation, the horrific speed of the original Ruby version, and my recent obsession with building and implementing weird formats. BGA is short for "Boby's Great Adornment :)" (courtesy of alice) but used to be short for "Basic Graphical Array". Of course, when I named it that, it was basically just a framebuffer with no metadata, and it has in my opinion outgrown that name. Boby's much more professional anyways. Sidenote please play Ring Racers with me

The old implementation of the BGA image format (bga.rb and BGAcraft) are terrible and slow (partially my fault, partially the fault of Ruby. No shade, it's just not great for native image processing!)

The Ruby implementation took more than 4 minutes to convert a 385x389 image of 256 colors to PNG (and that's not all given that I ended up giving up entirely.) The .NET version took 621 milliseconds to do the same and has a much nicer command line interface (Program.cs).

Usage

To convert a PNG to BGA:

$ bgasharp ./input.png ./output.bga
BGA'd file `output.bga' in 201ms

To convert a BGA to a WEBP:

$ bgasharp ./output.bga ./outerput.webp
unBGA'd file `output.bga' in 158ms

bgasharp on the command line supports a wide variety of image formats, courtesy of Magick.NET. It also allows you to print information about a BGA image, like so:

$ bgasharp output.bga
loaded BGA file `output.bga' in 29ms

       image geometry: 385x389px
        metadata size: 0 bytes
  color table entries: 255 colors
    pixel data length: 29.5 kbytes

If a BGA image has metadata and you'd like to get rid of it, you can simply 'strip' it:

$ bgasharp strip output.bga
stripped BGA file `output.bga' in 18ms

Report-a-bug

If you find a bug in bgasharp (don't worry, you will!) please contact me over Discord or email:

Thanks!

License

This project is made available under the terms of the MIT license (which you can find in LICENSE) out of fairness. Please note that if you are a defense contractor and for some reason REALLY want to use BGA, I would really rather you didn't ^^

Project (C) 2024 tobskep.com