MyNixOS website logo
Description

Processing popular picture formats into .c or .raw format in RGB565

About:

This package was created because I could not find a tool that can be used on UNIX systems to parse a picture into an array of RGB565 values and save them to a '.c' or '.raw' file. Both formats are used by the UTFT library to display pictures on to a TFT display.

This package includes, but not limited to, an executable which is made to be as identical as possible to the corresponding tool that is also downloaded with the UTFT library.

Usage:

./UTFTConverter <filespec> /c|r [/o <path>] [/t AVR|ARM|PIC32]

<filespec>:  File(s) to convert
parameters: /c            - Create output as .c array files
            /r            - Create output as .raw files
            /o <path>     - Set the output directory to <path>
            /t <platform> - Select target plaform
                            AVR   : Most Arduinos, Bobuion
                            ARM   : Arduino Due, Teensy, TI CC3200 LaunchPad
                            PIC32 : All chipKit boards

You must specify either /c or /r. All other parameters are optional.
If /o is ommited the current directory will be used for output.
If /t is ommited the target platform will be set to AVR.'

Supported formats:

The binary tests if the pictures are encoded correctly via magic bytes using ImageType. If the extention is wrong, but the encoding is correct, it will still try to convert the picture.

The exported library is using JuicyPixels to convert incoming

  • '.gif'

  • '.png'

  • '.jpg' / '.jpe' / '.jpeg'

  • '.bmp'

  • '.tga'

and translates every pixel to a RGB565 format, which is a 4 digit hex number.

Library:

The only really reusable library is the Format.RGB565. It support the conversion from

  • RGB to RGB565 as (Word8, Word8, Word8) -> Int

  • Int to Hex as Int -> String

Example usage:

>>> toRGB565 (0, 0, 255)
31
>>> toRGB565Hex (0, 0, 255)
"001F"
>>> toHex 100
64
>>> toNHex 6 100
"0064"

UTFTConverter

This is my take at an offline converter from the below defined formats to .c or .raw format.

I will try to make the tool as identical as possible to the corresponding tool at RinkyDink.

Usage:

./UTFTConverter <filespec> /c|r [/o <path>] [/t AVR|ARM|PIC32]

<filespec>:  File(s) to convert
parameters: /c            - Create output as .c array files
            /r            - Create output as .raw files
            /o <path>     - Set the output directory to <path>\n
            /t <platform> - Select target plaform
                            AVR   : Most Arduinos, Bobuion
                            ARM   : Arduino Due, Teensy, TI CC3200 LaunchPad
                            PIC32 : All chipKit boards\n

You must specify either /c or /r. All other parameters are optional.
If /o is ommited the current directory will be used for output.
If /t is ommited the target platform will be set to AVR.

Differences to the Windows tool:

  • You can specifiy as many files as you want, not only a directory (mydir/*.jpg still works, the shell does all the work for you)
  • If you specify a target platform while converting to .raw the platform will not be printed
  • If you specify a non-existing directory as target, it will be created
  • The length of the array is NOT preceded by 0x
  • You can use the flags in any order you want
  • This tool will check the files via magic bytes

Binaries

  • precompiled binary for Ubuntu distributions in bin/UTFTConverter_u (compiled on Linux Mint 17)
  • precompiled binary for Windows in bin/UTFTConverter_w.exe (compiled on Windows 7)

Installation via cabal:

Step 1: Install the Glasgow Haskell Compiler and cabal OR the Haskell packaging tool

For Ubuntu distributions:

  • sudo apt-get install ghc
  • download the cabal-install.tar.gz from cabal
  • unpack the .tar.gz file, the cabal-install folder should include a bootstrap.sh
  • run ./bootstrap.sh

For any operation system:

Step 2: When you have ghc and cabal OR the Haskell Platform installed:

If you want the library AND the binary (the easier way):

  • run cabal install UTFTConverter
  • the executable is now at ~/.cabal/bin/UTFTConverter

If you want to build it by hand:

  • download the JuicyPixels library - cabal install JuicyPixels | `stack install
  • download the git repository - git clone http://github.com/cirquit/UTFTConverter
  • run make and the binary is in the same directory OR
  • run cabal install and the binary is in /dist/build/ and in your home directory under ~/.cabal/bin/UTFTConverter OR
  • run stack build && stack install and the binary is somewhere in your .stack-work/

Installation via stack:

  • Install stack Official guide / My simplified guide
  • open your shell and type stack setup
  • after that stack install UTFTConverter
  • look up the messages where your executable lies

To do:

  • maybe add resizing with a basic linear algorithm
  • I'm planning to make a simple API that you can start locally which accepts any below defined formats and responses with the parsed .raw file. (another project)

About:

While working on a streaming project on the Arduino, I needed to convert .jpg's to the .c or .raw format on the fly and send them to the Arduino. Unfortunately, the tools that were included in the corresponding UTFT library were compiled for Windows and there was no public API to do so. That's why I thought it would be a nice first project, that some people could benefit from.

Metadata

Version

0.1.0.1

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows