projects
/
dos_imgv
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f138909
)
resolution commandline argument
author
John Tsiombikas
<nuclear@member.fsf.org>
Tue, 7 Dec 2021 06:44:17 +0000
(08:44 +0200)
committer
John Tsiombikas
<nuclear@member.fsf.org>
Tue, 7 Dec 2021 06:44:17 +0000
(08:44 +0200)
src/main.c
patch
|
blob
|
history
diff --git
a/src/main.c
b/src/main.c
index
e7d464b
..
9367eca
100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-30,6
+30,7
@@
static struct video_mode *vmlist;
static int vmlist_size, cur_vm = -1;
static void *backbuf;
static int vmlist_size, cur_vm = -1;
static void *backbuf;
+static int opt_width, opt_height;
static int opt_bpp = 16;
static const char *opt_fname;
static int opt_bpp = 16;
static const char *opt_fname;
@@
-100,7
+101,11
@@
int main(int argc, char **argv)
init_mouse();
init_mouse();
- modeidx = find_best_mode(img.width, img.height);
+ if(!opt_width) {
+ opt_width = img.width;
+ opt_height = img.height;
+ }
+ modeidx = find_best_mode(opt_width, opt_height);
if(switch_mode(modeidx) == -1) {
goto end;
}
if(switch_mode(modeidx) == -1) {
goto end;
}
@@
-339,12
+344,19
@@
int parse_args(int argc, char **argv)
int i;
static const char *usage_fmt = "Usage: %s [options] <image file>\n"
"Options:\n"
int i;
static const char *usage_fmt = "Usage: %s [options] <image file>\n"
"Options:\n"
+ " -s <WxH>: choose screen resolution if available\n"
" -bpp <n>: video mode color depth (8, 15, 16, 24, 32)\n"
" -h,-help: print usage information and exit\n";
for(i=1; i<argc; i++) {
if(argv[i][0] == '-') {
" -bpp <n>: video mode color depth (8, 15, 16, 24, 32)\n"
" -h,-help: print usage information and exit\n";
for(i=1; i<argc; i++) {
if(argv[i][0] == '-') {
- if(strcmp(argv[i], "-bpp") == 0) {
+ if(strcmp(argv[i], "-s") == 0) {
+ if(!argv[++i] || sscanf(argv[i], "%dx%d", &opt_width, &opt_height) != 2 ||
+ opt_width <= 0 || opt_height <= 0) {
+ fprintf(stderr, "invalid resolution\n");
+ return -1;
+ }
+ } else if(strcmp(argv[i], "-bpp") == 0) {
if(!argv[++i] || (opt_bpp = atoi(argv[i])) <= 0) {
fprintf(stderr, "invalid -bpp\n");
return -1;
if(!argv[++i] || (opt_bpp = atoi(argv[i])) <= 0) {
fprintf(stderr, "invalid -bpp\n");
return -1;