A python binding to FloatImg library available at https://git.tetalab.org/tTh/FloatImg
Go to file
2021-05-12 08:28:06 +02:00
floatimg refactor FloatImg class method to function imported in floatimg module. add tests for file dump / load : coverage of exixting python code is 100%, yeah 2021-05-12 08:28:06 +02:00
tests refactor FloatImg class method to function imported in floatimg module. add tests for file dump / load : coverage of exixting python code is 100%, yeah 2021-05-12 08:28:06 +02:00
.gitignore Initial commit 2021-05-10 07:08:09 +02:00
README.md refactor FloatImg class method to function imported in floatimg module. add tests for file dump / load : coverage of exixting python code is 100%, yeah 2021-05-12 08:28:06 +02:00
requirements-devel.txt FloatImg class definition and some basic operations 2021-05-11 13:53:41 +02:00

python-FloatImg

A pythonesque binding to FloatImg library available at https://git.tetalab.org/tTh/FloatImg

python-FloatImg requires a quite recent Python 3 implementation (tested with 3.6.9).

Installation

python-FloatImg requires a shared object file (.so) that is not yet officialy available from FloatImg.

The file floatimg/settings.py contains the path to the .so file.

Usage

The FloatImg class encapsulate core and file functionnalities of FloatImg library. Import if from the main module:

import floatimg

Image creation

FloatImg has two class methods to create an image.

img = floatimg.create(640, 480, floatimg.RGB)

Or use the create_rgb shortcut:

img = floatimg.create_rgb(640, 480)

Note that calling the destroy method of the instance is not necessary as it will be called automatically at instance destruction.

Or completely duplicate an existing image:

# without copying data
new_img = img.clone()

# with copying data
new_img = img.clone(1)

Image manipulation

Clear image

img.clear()

Copy pixels to another image

img.copy_data(another_img)

Set pixel value

img.put_rgb(x, y, (r, g, b))

Get pixel value

r, g, b = img.get_rgb(x, y)

File manipulation

Dump image to file

img.dump_to_file("/tmp/image_dump")

Restore image data from a dump file

img.load_from_dump("/tmp/image_dump")

Create a new image from a dump file

img = floatimg.create_from_dump("/tmp/image_dump")

Get dump metadata

witdh, height, img_type = floatimg.fileinfos("/tmp/image_dump")

Development

Run tests

Install development requirements (you may add --user if not in a virtual environment or not in system-wide install):

pip install -r requirements-devel.txt

Ensure floatimg containing path is in the PYTHONPATH, this will run the tests and show a coverage report:

pytest --cov=floatimg tests/*