diff options
author | Richard Grenville <pyxlcy@gmail.com> | 2014-09-07 18:58:09 +0800 |
---|---|---|
committer | Richard Grenville <pyxlcy@gmail.com> | 2014-09-07 18:58:09 +0800 |
commit | e3717f4f7bf3a0a0a015337454f1e381a6e0278f (patch) | |
tree | 154628c6c6fc92922281573b424f076b1ff784f5 /common.h | |
parent | 886cdca8a59d0ce17d380560490ea06b9f089aa3 (diff) | |
download | tdebase-e3717f4f7bf3a0a0a015337454f1e381a6e0278f.tar.gz tdebase-e3717f4f7bf3a0a0a015337454f1e381a6e0278f.zip |
Misc #204: Add glx_take_screenshot() & others
- Add glx_take_screenshot() for taking a screenshot. With ImageMagick
the output data could be viewed in this way:
display -size [SCREEN-WIDTH]x[SCREEN-HEIGHT] -depth 8 -flip
rgb:[PATH]
(#204)
- Add D-Bus command `opts_get string:paint_on_overlay_id` to get X
Composite overlay window ID. (#204)
- Code cleanup.
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -2208,6 +2208,9 @@ glx_render_(session_t *ps, const glx_texture_t *ptex, void glx_swap_copysubbuffermesa(session_t *ps, XserverRegion reg); +unsigned char * +glx_take_screenshot(session_t *ps, int *out_length); + #ifdef CONFIG_VSYNC_OPENGL_GLSL GLuint glx_create_shader(GLenum shader_type, const char *shader_str); @@ -2485,6 +2488,28 @@ c2_matchd(session_t *ps, win *w, const c2_lptr_t *condlst, #endif /** + * @brief Dump the given data to a file. + */ +static inline bool +write_binary_data(const char *path, const unsigned char *data, int length) { + if (!data) + return false; + FILE *f = fopen(path, "wb"); + if (!f) { + printf_errf("(\"%s\"): Failed to open file for writing.", path); + return false; + } + int wrote_len = fwrite(data, sizeof(unsigned char), length, f); + fclose(f); + if (wrote_len != length) { + printf_errf("(\"%s\"): Failed to write all blocks: %d / %d", path, + wrote_len, length); + return false; + } + return true; +} + +/** * @brief Dump raw bytes in HEX format. * * @param data pointer to raw data |