diff options
author | scuri <scuri> | 2008-10-17 06:10:33 +0000 |
---|---|---|
committer | scuri <scuri> | 2008-10-17 06:10:33 +0000 |
commit | 7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf (patch) | |
tree | d0857278bde2eff784227c57dcaf930346ceb7ac /test/screencapture.c |
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'test/screencapture.c')
-rw-r--r-- | test/screencapture.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/screencapture.c b/test/screencapture.c new file mode 100644 index 0000000..1ac8d2c --- /dev/null +++ b/test/screencapture.c @@ -0,0 +1,36 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cd.h> +#include <cdnative.h> +#include <im.h> + +void main() +{ + cdCanvas *cd_canvas; + unsigned char *red, *green, *blue; + int width, height, size; + + cd_canvas = cdCreateCanvas(CD_NATIVEWINDOW, NULL); + if (!cd_canvas) + { + printf("Error creating canvas.\n"); + return; + } + + cdActivate(cd_canvas); + + cdGetCanvasSize(&width, &height, NULL, NULL); + size = width * height; + red = (unsigned char*)calloc(size, 1); + green = (unsigned char*)calloc(size, 1); + blue = (unsigned char*)calloc(size, 1); + + cdGetImageRGB(red, green, blue, 0, 0, width, height); + imSaveRGB(width, height, IM_JPG|IM_COMPRESSED, red, green, blue, "scap.jpg"); + + cdKillCanvas(cd_canvas); + + free(red); + free(green); + free(blue); +} |