Announcing - png2embeddedjson #652
chalkers
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I created an npm module that creates Bitmaps for the graphics library for Kaluma. Here's a snippet from the readme
png2embeddedjson
Convert PNG images to embedded JSON with Base64-encoded RGB565 data.
Description
png2embeddedjson
is a command-line tool and a Node.js module that converts PNG images into a JSON format containing Base64-encoded RGB565 data. This is useful for embedding images directly into applications or systems that utilize JSON for configuration or data representation, such as embedded systems or microcontrollers. For example, it can be used for displaying images on a GC9A01 display on an RP2040 microcontroller powered by the Kaluma runtime.The output JSON contains:
width
: The width of the image in pixels.height
: The height of the image in pixels.bpp
: Bits per pixel used (default is 16).data
: Base64-encoded string of the RGB565 image data.Installation
Install the package globally using npm:
Usage
CLI
<input.png>
: Path to the input PNG image.[output.json]
: (Optional) Path to save the output JSON file. If not provided, the JSON will be printed to the console.Examples:
Convert an image and save the output to a file:
Convert an image and display the JSON in the console:
API
Use the package programmatically in Node.js applications:
Here's a sample BITMAP that was generated by this module:
Enjoy!
Beta Was this translation helpful? Give feedback.
All reactions