Color space conversion
From Attie's Wiki
GStreamer
For a list of available formats, see: GStreamer Docs
#!/bin/bash IN_FILE="${1}" IN_FORMAT="RGB16" IN_WIDTH="1024" IN_HEIGHT="600" OUT_FILE="$(echo "${IN_FILE}" | sed -re 's/\.[^\.]*//').png" gst-launch-1.0 -v filesrc "location=${IN_FILE}" blocksize=$(stat "${IN_FILE}" -c%s) ! \ video/x-raw,format=${IN_FORMAT},width=${IN_WIDTH},height=${IN_HEIGHT},framerate=1/1 ! \ videoconvert ! \ video/x-raw,format=RGB,framerate=1/1 ! \ pngenc ! \ filesink "location=${OUT_FILE}"
RGB565 to RGB888
A really nasty little app to convert between RAW RGB565 → RGB888. Useful for dumping a 16-bit linux framebuffer!
#include <stdio.h> #include <stdlib.h> /* xxxx xxxx xxxx xxxx rrrr rggg gggb bbbb */ void write_red(int fdout, char *pixel) { char b; b = pixel[1]; b &= 0b11111000; write(fdout, &b, 1); } void write_green(int fdout, char *pixel) { char b, b2; b = pixel[1]; b <<= 5; b2 = pixel[0]; b2 >>= 3; b2 &= 0b00011100; b |= b2; b &= 0b11111100; write(fdout, &b, 1); } void write_blue(int fdout, char *pixel) { char b; b = pixel[0]; b <<= 3; b &= 0b11111000; write(fdout, &b, 1); } int main(int argc, char *argv[]) { char pixel[2]; int fdin; int fdout; fdin = fileno(stdin); fdout = fileno(stdout); while (read(fdin, pixel, 2) == 2) { write_red(fdout, pixel); write_green(fdout, pixel); write_blue(fdout, pixel); } return 0; }