Metadata-Version: 2.4
Name: brulegfx
Version: 0.0.7
Summary: Bitmap utilities (RLE, RGBA quantization, Segmentation)
Author-email: cubicibo <cubicibo@outlook.com>
License-Expression: MIT
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=2.0.1
Dynamic: license-file

# Brule
Collection of C extension modules, mostly developed for SUPer
- Brule: Bitmap RUn LEngth coder and decoder.
- LayoutEngine: An optimal two-rects layout finder for a sequence of images.
- HexTree: RGBA image quantizer (turbo, good quality)
- QtzrUTC: RGBA image quantizer (fast, excellent quality)

## Brule brief
Brule implements a few bitmap-related function that requires a fast C back-end.

## Install
### From PyPi:
Brule is available on PyPi under the name `brulegfx`:
```bash
$ python -m pip install brulegfx
```

### From repository
Given `./brule` the (cloned) repository:
```bash
$ python -m pip install ./brule
```

## RLE Codec example

The run-length codec is operated like this:
```python
>>> from brule import Brule
>>> import numpy as np
>>> bitmap_orig = np.ones((1080, 1920), np.uint8)
>>> rle_data = Brule.encode(bitmap_orig)
>>> bitmap = Brule.decode(rle_data)
>>> assert np.all(bitmap == bitmap_orig)
True
```

## RGBA quantizer examples (HexTree, QtzrUTC)
The image quantizers are used like this:
```python
>>> from brule import HexTree, QtzrUTC
>>> import numpy as np
>>> from PIL import Image
>>>
>>> rgba = np.asarray(Image.open(...).convert('RGBA'))
>>>
>>> #quantize
>>> bitmap1, palette1 = HexTree.quantize(rgba, 255)
>>> bitmap2, palette2 = QtzrUTC.quantize(rgba, 123)
```

## Credits
- https://github.com/DarthSim/quantizr for Qtzr
