Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
will move to imlib2
- Loading branch information
Ryan Jacobs
committed
Mar 19, 2015
1 parent
8cd3c58
commit a8e9f8d
Showing
5 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/tl | ||
*.o | ||
.*.sw[op] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* @file frame.c | ||
* @brief Generate each frame. | ||
* @author Ryan Jacobs <ryan.mjacobs@gmail.com> | ||
* @date March 18, 2015 | ||
* @bug No known bugs. | ||
*/ | ||
|
||
#include <X11/Xlib.h> | ||
#include <X11/Xutil.h> | ||
#include <stdio.h> | ||
#include <assert.h> | ||
|
||
#include "frame.h" | ||
|
||
int get_shift(int mask); | ||
|
||
struct frame_t grab_frame(void) { | ||
XImage *img; | ||
Display *dpl; | ||
Screen *scr; | ||
struct frame_t frame; | ||
int x, y; | ||
|
||
dpl = XOpenDisplay(NULL); | ||
assert(dpl); | ||
|
||
scr = XDefaultScreenOfDisplay(dpl); | ||
assert(scr); | ||
|
||
frame.width = XWidthOfScreen(scr); | ||
frame.height = XHeightOfScreen(scr); | ||
|
||
img = XGetImage(dpl, RootWindow(dpl, DefaultScreen(dpl)), | ||
0, 0, frame.width, frame.height, AllPlanes, ZPixmap); | ||
|
||
fprintf(stdout,"P6\n%d %d\n255\n",img->width, img->height); | ||
for (x = 0; x < frame.width; x++) { | ||
for (y = 0; y < frame.height; y++) { | ||
unsigned long pixel; | ||
|
||
pixel = XGetPixel(img, x, y); | ||
} | ||
} | ||
|
||
return frame; | ||
} | ||
|
||
#if 0 | ||
void init_x_and_imlib(char *dispstr, int screen_num) | ||
disp = XOpenDisplay(dispstr); | ||
if (!disp) | ||
gib_eprintf("Can't open X display. It *is* running, yeah?"); | ||
if (screen_num) | ||
scr = ScreenOfDisplay(disp, screen_num); | ||
else | ||
scr = ScreenOfDisplay(disp, DefaultScreen(disp)); | ||
|
||
vis = DefaultVisual(disp, XScreenNumberOfScreen(scr)); | ||
depth = DefaultDepth(disp, XScreenNumberOfScreen(scr)); | ||
cm = DefaultColormap(disp, XScreenNumberOfScreen(scr)); | ||
root = RootWindow(disp, XScreenNumberOfScreen(scr)); | ||
|
||
imlib_context_set_display(disp); | ||
imlib_context_set_visual(vis); | ||
imlib_context_set_colormap(cm); | ||
imlib_context_set_color_modifier(NULL); | ||
imlib_context_set_operation(IMLIB_OP_COPY); | ||
} | ||
#end if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @file frame.h | ||
* @brief Generate each frame. | ||
* @author Ryan Jacobs <ryan.mjacobs@gmail.com> | ||
* @date March 18, 2015 | ||
* @bug No known bugs. | ||
*/ | ||
|
||
#ifndef FRAME_H | ||
#define FRAME_H | ||
|
||
struct frame_t { | ||
int width; | ||
int height; | ||
char *buf; | ||
}; | ||
|
||
struct frame_t grab_frame(void); | ||
|
||
#endif /* FRAME_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ | |
* @bug No known bugs. | ||
*/ | ||
|
||
#include "frame.h" | ||
|
||
int main(int argc, char **argv) { | ||
grab_frame(); | ||
|
||
return 0; | ||
} |