From 5df5db793cceaa7a562039f78fb72c1d68d0c1d8 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 29 Sep 2011 14:25:13 -0400 Subject: Add a raw fb0 dump to XWD format converter. --- util/rawtoxwd.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 util/rawtoxwd.c diff --git a/util/rawtoxwd.c b/util/rawtoxwd.c new file mode 100644 index 0000000..c77905d --- /dev/null +++ b/util/rawtoxwd.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include + +static XWDFileHeader fh = { + .header_size = sizeof(XWDFileHeader), + .file_version = XWD_FILE_VERSION, + .pixmap_format = ZPixmap, + .pixmap_depth = 24, + .pixmap_width = 1600, + .pixmap_height = 900, + .byte_order = LSBFirst, + .bitmap_unit = 32, + .bitmap_bit_order = LSBFirst, + .bitmap_pad = 32, + .bits_per_pixel = 24, + .bytes_per_line = 4800, + .visual_class = DirectColor, + .red_mask = 0xff0000, + .green_mask = 0x00ff00, + .blue_mask = 0x0000ff, + .bits_per_rgb = 8, + .colormap_entries = 0, + .ncolors = 0, + .window_width = 1600, + .window_height = 900, +}; + +int +main(int argc, char *argv[]) +{ + int i; + ssize_t rc; + CARD32 pixel, *ptr; + + /* structure values are MSBFirst */ + ptr = (CARD32 *)&fh; + for (i = 0; i < sizeof(fh); i+=4) { + *ptr = htonl(*ptr); + ptr++; + } + + write(1, &fh, sizeof(fh)); + + for (i = 0; i < 1600 * 900; i++) { + rc = read(0, &pixel, 4); + if (rc <= 0) + break; + write(1, &pixel, 3); + } + + return 0; +} -- cgit v1.2.3