blob: 235e958f986e01818bb905a0c8dfcaff3bde451b [file] [log] [blame]
Talustus3019a912013-04-06 11:50:07 +02001/**
2 * fb2png Save screenshot into .png.
3 *
4 * Copyright (C) 2012 Kyan <kyan.ql.he@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
Matt Mower908a2772017-01-11 15:31:00 -060020
Talustus3019a912013-04-06 11:50:07 +020021#include <limits.h>
Matt Mower908a2772017-01-11 15:31:00 -060022#include <stdio.h>
Talustus3019a912013-04-06 11:50:07 +020023#include <stdlib.h>
Matt Mower908a2772017-01-11 15:31:00 -060024#include <string.h>
25
Talustus3019a912013-04-06 11:50:07 +020026#include "fb2png.h"
27
28#ifdef ANDROID
29 #define DEFAULT_SAVE_PATH "/data/local/fbdump.png"
30#else
31 #define DEFAULT_SAVE_PATH "fbdump.png"
32#endif
33
34int main(int argc, char *argv[])
35{
36 char fn[PATH_MAX];
37 int ret;
38
39 if (argc == 2 && argv[1][0] != '-') {
40 if (strlen(argv[1]) >= PATH_MAX) {
41 printf("Output path is too long!\n");
42 exit(-1);
43 }
44 sprintf(fn, "%s", argv[1]);
45 } else if (argc == 1) {
46 sprintf(fn, "%s", DEFAULT_SAVE_PATH);
47 } else {
48 //if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
49 printf(
50 "Android Screenshooter - fb2png\n"
51 "Author: Kyan He <kyan.ql.he@gmail.com>\n"
52 "Modified by Phil3759 & McKael @xda\n"
53 "Base version 0.0.2 ---> v0.0.5 <2013>\n"
54 "Usage: fb2png [path/to/output.png]\n"
55 " The default output path is /data/local/fbdump.png\n"
56 );
57 exit(0);
58 }
59
60 if (0 == (ret = fb2png(fn)))
61 printf("Saved image to %s\n", fn);
62
63 exit(ret);
64}