pixelate

Crates.iopixelate
lib.rspixelate
version0.1.0
sourcesrc
created_at2019-04-04 08:46:26.480946
updated_at2019-04-04 08:46:26.480946
descriptionFast, pixelated, palette-based PNG renderer
homepage
repositoryhttps://github.com/maciejhirsz/pixelate
max_upload_size
id125798
size48,927
stm32f4 (github:stm32-rs:stm32f4)

documentation

https://docs.rs/pixelate

README

Pixelate

This logo is rendered with this crate

It's only 861 bytes for a 720x128 image. Check out the code.

Why is this even a thing?!

Rendering up-scaled pixelated PNG files can be quite useful for things like:

  • QR codes.
  • Identicons like Blockies.
  • Pixel Art?

Usually a PNG image data, before compression, is a bitmap that packs 3 or 4 bytes per pixel, depending whether transparency is present or not. For all of the cases above this is way more information than necessary.

PNG supports an indexed palette format. Using the indexing palette makes it possible not only to pack a single pixel into a single byte, but for small palettes a pixel can be 4, 2, or even just 1 bit. The logo here is using 3 colors (black, transparent background and shadow), which allows Pixelate to produce a bitmap where each pixel takes only 2 bits.

Not only does this produce smaller images after compression, smaller bitmap is also much faster to compress, as much as 10x for small palettes. This makes it ideal for rendering QR codes or identicons on the fly.

License

Ramhorns is free software, and is released under the terms of the GNU General Public License version 3. See LICENSE.

Commit count: 4

cargo fmt