acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
sjpg.md (2474B)
1 ```eval_rst 2 .. include:: /header.rst 3 :github_url: |github_link_base|/libs/sjpg.md 4 ``` 5 6 # JPG decoder 7 8 Allow the use of JPG images in LVGL. Besides that it also allows the use of a custom format, called Split JPG (SJPG), which can be decoded in more optimal way on embedded systems. 9 10 ## Overview 11 - Supports both normal JPG and the custom SJPG formats. 12 - Decoding normal JPG consumes RAM with the size fo the whole uncompressed image (recommended only for devices with more RAM) 13 - SJPG is a custom format based on "normal" JPG and specially made for LVGL. 14 - SJPG is 'split-jpeg' which is a bundle of small jpeg fragments with an sjpg header. 15 - SJPG size will be almost comparable to the jpg file or might be a slightly larger. 16 - File read from file and c-array are implemented. 17 - SJPEG frame fragment cache enables fast fetching of lines if available in cache. 18 - By default the sjpg image cache will be image width * 2 * 16 bytes (can be modified) 19 - Currently only 16 bit image format is supported (TODO) 20 - Only the required partion of the JPG and SJPG images are decoded, therefore they can't be zoomed or rotated. 21 22 ## Usage 23 24 If enabled in `lv_conf.h` by `LV_USE_SJPG` LVGL will register a new image decoder automatically so JPG and SJPG files can be directly used as image sources. For example: 25 ``` 26 lv_img_set_src(my_img, "S:path/to/picture.jpg"); 27 ``` 28 29 Note that, a file system driver needs to registered to open images from files. Read more about it [here](https://docs.lvgl.io/master/overview/file-system.html) or just enable one in `lv_conf.h` with `LV_USE_FS_...` 30 31 32 33 ## Converter 34 35 ### Converting JPG to C array 36 - Use lvgl online tool https://lvgl.io/tools/imageconverter 37 - Color format = RAW, output format = C Array 38 39 ### Converting JPG to SJPG 40 python3 and the PIL library required. (PIL can be installed with `pip3 install pillow`) 41 42 To create SJPG from JPG: 43 - Copy the image to convert into `lvgl/scripts` 44 - `cd lvgl/scripts` 45 - `python3 jpg_to_sjpg.py image_to_convert.jpg`. It creates both a C files and an SJPG image. 46 47 The expected result is: 48 ```sh 49 Conversion started... 50 51 Input: 52 image_to_convert.jpg 53 RES = 640 x 480 54 55 Output: 56 Time taken = 1.66 sec 57 bin size = 77.1 KB 58 walpaper.sjpg (bin file) 59 walpaper.c (c array) 60 61 All good! 62 ``` 63 64 65 ## Example 66 ```eval_rst 67 68 .. include:: ../../examples/libs/sjpg/index.rst 69 70 ``` 71 72 ## API 73 74 ```eval_rst 75 76 .. doxygenfile:: lv_sjpg.h 77 :project: lvgl