Introduction
Introduction Statistics Contact Development Disclaimer Help
add farbeld support, kudos to z3bra! - xscreenshot - screen capture tool
git clone git://git.codemadness.org/xscreenshot
Log
Files
Refs
README
LICENSE
---
commit 8a6fbfbed1428dc71588d6a1b86730e0da055163
parent cb8ad238bc437ee427cddac7507d90d89dc7051c
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 16 Nov 2015 17:50:12 +0100
add farbeld support, kudos to z3bra!
Diffstat:
M README | 8 ++++----
M xscreenshot.c | 13 +++++++++----
2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/README b/README
@@ -13,8 +13,8 @@ Dependencies
Optional dependencies
---------------------
-- To convert imagefile data you can use if2png from:
- http://git.2f30.org/imagefile
+- To convert farbfeld data you can use ff2png from:
+ http://git.2f30.org/farbfeld
Compile
-------
@@ -26,8 +26,8 @@ $ make
Usage
-----
-xscreenshot [winid] > file.if
-if2png < file.if > file.png
+xscreenshot [winid] > file.ff
+ff2png < file.ff > file.png
Known issues
diff --git a/xscreenshot.c b/xscreenshot.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
+#include <endian.h>
#include <X11/X.h>
#include <X11/Xlib.h>
@@ -32,6 +33,7 @@ main(int argc, char *argv[])
Window win;
XWindowAttributes attr;
uint32_t tmp, w, h;
+ uint16_t rgba[4];
dpy = XOpenDisplay(NULL);
if(!dpy)
@@ -59,7 +61,7 @@ main(int argc, char *argv[])
die("Can't XGetImage");
/* write header with big endian width and height-values */
- fprintf(stdout, "imagefile");
+ fprintf(stdout, "farbfeld");
tmp = htonl(img->width);
fwrite(&tmp, sizeof(uint32_t), 1, stdout);
tmp = htonl(img->height);
@@ -69,9 +71,12 @@ main(int argc, char *argv[])
for(h = 0; h < (uint32_t)img->height; h++) {
for(w = 0; w < (uint32_t)img->width; w++) {
tmp = XGetPixel(img, w, h);
- tmp = ((tmp & img->red_mask) >> 16) | (tmp & img->gre…
- | ((tmp & img->blue_mask) << 16) | (255 << 24);
- if(fwrite(&tmp, sizeof(uint32_t), 1, stdout) != 1)
+ rgba[0] = htobe16((tmp & img->red_mask) >> 8);
+ rgba[1] = htobe16(tmp & img->green_mask);
+ rgba[2] = htobe16((tmp & img->blue_mask) << 8);
+ rgba[3] = htobe16(65535);
+
+ if(fwrite(&rgba, 4*sizeof(uint16_t), 1, stdout) != 1)
die("fwrite() failed");
}
}
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.