From 3aa4f170a839f52e941413241fe7ff530ea18635 Mon Sep 17 00:00:00 2001 From: thirdr Date: Mon, 8 Apr 2024 08:41:31 +0100 Subject: [PATCH] adding pngdec --- micropython/modules/picographics/README.md | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/micropython/modules/picographics/README.md b/micropython/modules/picographics/README.md index 0ed64688..b5224d39 100644 --- a/micropython/modules/picographics/README.md +++ b/micropython/modules/picographics/README.md @@ -583,3 +583,42 @@ The arguments for `decode` are as follows: 2. Decode Y 3. Flags - one of `JPEG_SCALE_FULL`, `JPEG_SCALE_HALF`, `JPEG_SCALE_QUARTER` or `JPEG_SCALE_EIGHTH` 4. If you want to turn off dither altogether, try `dither=False`. This is useful if you want to [pre-dither your images](https://ditherit.com/) or for artsy posterization effects. + +### PNG Files + +We've included BitBank's PNGDEC - https://github.com/bitbank2/PNGDEC - so you can display PNG files on your LCDs. + +Eg: + +```python +import picographics +import pngdec + +display = PicoGraphics(display=DISPLAY_PICO_DISPLAY, pen_type=PEN_RGB332) + +# Create a new PNG decoder for our PicoGraphics +png = pngdec.PNG(display) + +# Open the PNG file +png.open_file("filename.jpeg") + +# Decode the PNG +png.decode(0, 0) + +# Display the result +display.update() +``` + +PNG files must be small enough to load into RAM for decoding. + +PNGDEC Supports the following PNG types: + +1. True Colour +2. True Colour (with Alpha) +3. Indexed +4. Grayscale + +The arguments for `decode` are as follows: + +1. Decode X - where to place the decoded JPEG on screen +2. Decode Y \ No newline at end of file